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

前端 未结 23 2443
甜味超标
甜味超标 2020-11-22 02:54

I\'m getting this error executing my Android app (I cleaned it and then built it, but the error is still present)

  • Sync: OK
  • Make Project: OK
相关标签:
23条回答
  • 2020-11-22 03:04

    I Reject Embedded JDK ( in 32bit ) because embedded JDK is 64bit

    Right click your Project -> Open Module Setting -> SDK Location -> Uncheck Use embedded JDk then set your JDK Path, eg in Ubuntu /usr/lib/jvm/java-8-openjdk-i386

    0 讨论(0)
  • 2020-11-22 03:04

    For me i was adding the whole playstore dependencies

    compile 'com.google.android.gms:play-services:8.4.0'

    But i needed google map only , so i made it more specific and the error was resolved.

    compile 'com.google.android.gms:play-services-maps:8.4.0'

    0 讨论(0)
  • 2020-11-22 03:05

    If you want to see what exactly is causing the error, try building your project via gradle terminal, like this ./gradlew assembleDebug --stacktrace --debug . I've seen the following error in my case com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

    This happened when I was trying to entegrate Google Maps to my project. To fix it, I simply checked libraries I was including

    compile 'com.google.android.gms:play-services:9.8.0'

    I simply changed it to

    compile 'com.google.android.gms:play-services-maps:9.8.0'

    and problem was gone

    0 讨论(0)
  • 2020-11-22 03:09

    Possible problem: You have exceeded dex 65k methods limit, may be you added some library or several methods before problem occurred?

    0 讨论(0)
  • 2020-11-22 03:11

    I didn't know (by then) that "compile fileTree(dir: 'libs', include: ['*.jar'])" compile all that has jar extension on libs folder, so i just comment (or delete) this lines:

    //compile 'com.squareup.retrofit:retrofit:1.9.0'
    //compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
    //compile 'com.squareup.okhttp:okhttp:2.2.0'
    
    //compile files('libs/spotify-web-api-android-master-0.1.0.jar')
    //compile files('libs/okio-1.3.0.jar')
    

    and it works fine. Thanks anyway! My bad.

    0 讨论(0)
  • 2020-11-22 03:12

    I think it's conflicts of .jar file in your project.

    I have removed android-support-v4.jar from libs folder and its working !!!

    if your project gives error, check in your build.gradle file

    dependencies {

    }

    0 讨论(0)
提交回复
热议问题