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

妖精的绣舞 提交于 2019-12-13 06:01:49

问题


  1. Gradle Build : Working fine.
  2. Rebuild Project: Working fine.
  3. Clean Project: Working Fine.
  4. Run: It shows following:

Error: Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_71\bin\java.exe'' finished with non-zero exit value

Detail Error:

Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72300Library UP-TO-DATE :app:prepareComAndroidSupportMediarouterV72220Library UP-TO-DATE :app:prepareComAndroidSupportMultidex101Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72220Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42300Library UP-TO-DATE :app:prepareComCrashlyticsSdkAndroidAnswers102Library UP-TO-DATE :app:prepareComCrashlyticsSdkAndroidBeta102Library UP-TO-DATE :app:prepareComCrashlyticsSdkAndroidCrashlytics210Library UP-TO-DATE :app:prepareComDigitsSdkAndroidDigits180Library UP-TO-DATE :app:prepareComFacebookAndroidFacebookAndroidSdk460Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServices810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAds810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAnalytics810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppinvite810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAppstate810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBase810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBasement810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesCast810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesDrive810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesFitness810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesGames810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesGcm810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesIdentity810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesLocation810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesMaps810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesMeasurement810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesNearby810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesPanorama810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesPlus810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesSafetynet810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesVision810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesWallet810Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesWearable810Library UP-TO-DATE :app:prepareComTwitterSdkAndroidTweetComposer090Library UP-TO-DATE :app:prepareComTwitterSdkAndroidTweetUi150Library UP-TO-DATE :app:prepareComTwitterSdkAndroidTwitter180Library UP-TO-DATE :app:prepareComTwitterSdkAndroidTwitterCore150Library UP-TO-DATE :app:prepareIoFabricSdkAndroidFabric135Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:fabricGenerateResourcesDebug :app:processDebugResources :app:generateDebugSources :app:processDebugJavaRes UP-TO-DATE :app:compileDebugJavaWithJavac UP-TO-DATE :app:compileDebugNdk UP-TO-DATE :app:compileDebugSources UP-TO-DATE :app:collectDebugMultiDexComponents UP-TO-DATE :app:packageAllDebugClassesForMultiDex UP-TO-DATE :app:shrinkDebugMultiDexComponents UP-TO-DATE :app:createDebugMainDexClassList UP-TO-DATE :app:dexDebug Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Invalid maximum heap size: -Xmx4g The specified size exceeds the maximum representable size. Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_71\bin\java.exe'' finished with non-zero exit value 1 Information:BUILD FAILED Information:Total time: 12.312 secs Information:1 error Information:0 warnings Information:See complete output in console

I have added 3 jar files in my lib folder of "quickblox". I have refereed to all the post related to my problem, but i was not able to successfully build the project. Also i have enable

multiDexEnabled true

My Build Gradle file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '23.0.0'

defaultConfig {
    applicationId "xxx.xxx.xxx"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
    multiDexEnabled  true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

dexOptions {
    javaMaxHeapSize "4g"
}

}


buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}



apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.retrofit:retrofit-mock:1.9.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.3.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:multidex:1.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.1.0@aar') {
    transitive = true;
}
compile('com.twitter.sdk.android:twitter:1.8.0@aar') {
    transitive = true;
}
compile files('libs/quickblox-android-sdk-chat-2.3.1.jar')
compile files('libs/quickblox-android-sdk-core-2.3.1.jar')
compile files('libs/quickblox-android-sdk-messages-2.3.1.jar')
}

回答1:


In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:

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

with these lines:

compile 'com.google.android.gms:play-services-fitness:8.1.0'
compile 'com.google.android.gms:play-services-wearable:8.1.0'

For more info refer : https://developers.google.com/android/guides/setup#split

It is similar to instead of using import.example.pkg1.* we do import.example.pkg1.RequiredClass
So Include only those play service package you need and check...

Also check for other libraries as well...whether they contain Classes with same name or not then in that case you will do work around with one library



来源:https://stackoverflow.com/questions/32844287/java-finished-with-non-zero-exit-value-1-android-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!