Android with Gradle (Java finished with non-zero exit value 2)

后端 未结 5 1695
渐次进展
渐次进展 2020-12-03 18:39

This is my .gradle file:

apply plugin: \'com.android.application\'

android {
    compileSdkVersion 21
    buildToolsVersion \"21.1.2\"

    defaultConfig {
         


        
5条回答
  •  执念已碎
    2020-12-03 19:17

    Uncomfortably this issue may have several reasons. In my case, it was because of the max line number is exceeded. It is so annoying that the message Android Studio shows does not mean anything, but somehow i found the solution as below:

    https://developer.android.com/tools/building/multidex.html

    You have to create a class that extends MultiDexApplication, and override the following method:

        @Override
        protected void attachBaseContext(Context base) {
            super.attachBaseContext(base);
            MultiDex.install(this);
        }
    

    Do not forget to add "name" inside tag in your AndroidManifest file as described in the above link.

提交回复
热议问题