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

后端 未结 5 1682
渐次进展
渐次进展 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:11

    I had copied the required library inside my_project/app/libs and also added the dependency in build.gradle. So, in my case I removed the library that I had copied in my_project/app/libs. As gradle maintains all the dependency I don't have to put the library in /libs. This fixed my problem.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-03 19:23

    Fixing JDK path solves the problem.

    Right click on Project > Open Module settings > SDK Location > Under JDK location give path to JDK folder.

    0 讨论(0)
  • 2020-12-03 19:31

    Maybe you have a dependency that causes incompatibility

    for example:

    0 讨论(0)
  • 2020-12-03 19:34

    I think you should change your java JDK change jvm v8 for jdk7. This link can help you: Is it possible to use Java 8 for Android development?

    Other possible issue its dependency error, clean gradle before build. And change your jackson library for this:

    compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+'
    compile 'com.fasterxml.jackson.core:jackson-core:2.2.+'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+'
    
    0 讨论(0)
提交回复
热议问题