When I try to run my app on my phone I get the following error
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.8.0_65\bin\java.exe'' finished with non-zero exit value 2
I am relatively new to programming so from doing some research this could be because duplicate libraries or exceeding memory. So I have tried several suggested options like removing this line from dependencies
compile fileTree(dir: 'libs', include: ['*.jar'])
also adding adding these to the build.gradle(app) file
defaultConfig { ... ... multiDexEnabled true }
and
dexOptions { preDexLibraries = false javaMaxHeapSize "4g" }
Gradle syncs just fine, problem is when I try to run on phone. I can run other apps in Android Studio just fine, just this particular one. If there is duplicate of libraries, how do I check and which ones are?
The gradle file is as below
apply plugin: 'com.android.application'
android { compileSdkVersion 23 buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.myweb.MyApp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.1' compile 'com.android.support:design:23.2.1'
/*Added*/
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.firebaseui:firebase-ui:0.4.3'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.firebase:firebase-client-android:2.5.2'
} apply plugin: 'com.google.gms.google-services'
and gradle console log
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]
Configuration on demand is an incubating feature. :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2400Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72400Library UP-TO-DATE :app:prepareComAndroidSupportCardviewV72321Library UP-TO-DATE :app:prepareComAndroidSupportCustomtabs2321Library UP-TO-DATE :app:prepareComAndroidSupportDesign2400Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72400Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42400Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2400Library UP-TO-DATE :app:prepareComFacebookAndroidFacebookAndroidSdk4110Library UP-TO-DATE :app:prepareComFirebaseuiFirebaseUi043Library UP-TO-DATE :app:prepareComFirebaseuiFirebaseUiAuth043Library UP-TO-DATE :app:prepareComFirebaseuiFirebaseUiDatabase043Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAuth921Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesAuthBase921Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBase940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBasement940Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesTasks940Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAnalytics940Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAnalyticsImpl940Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAuth921Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAuthCommon921Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseAuthModule921Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseCommon940Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseCore940Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseDatabase940Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseDatabaseConnection940Library UP-TO-DATE :app:prepareComGoogleFirebaseFirebaseIid940Library 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:processDebugGoogleServices Parsing json file: C:\Users\Admin\AndroidStudioProjects\MyApp\app\google-services.json :app:generateDebugResources :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:preDebugAndroidTestBuild UP-TO-DATE :app:prepareDebugAndroidTestDependencies :app:compileDebugAndroidTestAidl UP-TO-DATE :app:processDebugAndroidTestManifest UP-TO-DATE :app:compileDebugAndroidTestRenderscript UP-TO-DATE :app:generateDebugAndroidTestBuildConfig UP-TO-DATE :app:generateDebugAndroidTestAssets UP-TO-DATE :app:mergeDebugAndroidTestAssets UP-TO-DATE :app:generateDebugAndroidTestResValues UP-TO-DATE :app:generateDebugAndroidTestResources UP-TO-DATE :app:mergeDebugAndroidTestResources UP-TO-DATE :app:processDebugAndroidTestResources UP-TO-DATE :app:generateDebugAndroidTestSources UP-TO-DATE :app:processDebugJavaRes UP-TO-DATE :app:compileDebugJavaWithJavac UP-TO-DATE :app:compileDebugNdk UP-TO-DATE :app:compileDebugSources UP-TO-DATE :app:preDexDebug UP-TO-DATE :app:dexDebug AGPBI: {"kind":"simple","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","sources":[{}]} AGPBI: {"kind":"simple","text":"com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzaga;","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:188)","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:277)","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:245)","sources":[{}]} AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.Main.main(Main.java:106)","sources":[{}]}
FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_65\bin\java.exe'' finished with non-zero exit value 2
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.719 secs