"Multiple dex files define Landroid/support/annotation/AnimRes" in Gradle Build - java

i have a project with a library in libs folder.
When i run the app the android studio is give this Error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2
And app doesn't Run, what is the problem?
i run this app on android studio 1.2 in windows and that is fine but in android studio 1.3 on Ubuntu 14.04 with Openjdk 1.7 i have Error.
Any way to fix this?
this my Directories:
here app Build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '23.0.0'
defaultConfig {
applicationId "ir.vtj.Myapp"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(":sundate")
compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.+'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.daimajia.easing:library:1.0.0#aar'
compile 'com.daimajia.androidanimations:library:1.1.2#aar'
compile 'com.daimajia.androidviewhover:library:1.0.4#aar'
compile 'com.github.bumptech.glide:glide:3.6.0'
}
And Here Sundate Build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 10
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.0'
}
And Settings.gradle
include ':app'
include ':sundate'
project(':sundate').projectDir = new File('libs/sundate')

Related

Error:Execution failed for task ':app:dexDebug'. in android

I am new in android programming. when I am running my app it shows this kind of 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.7.0_67\bin\java.exe'' finished with non-zero exit value 2
it is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "uz.ums"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
useLibrary 'org.apache.http.legacy'
}
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.0.1'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:recyclerview-v7:+'
compile files('libs/picasso-2.5.2.jar')
compile 'com.squareup.okhttp3:okhttp:3.0.1'
}
I cleaned project and rebuild but this didn't help to me.What can you suggest to me! Thanks beforehand
You can try this one
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}

Gradle - java.exe finished with non-zero exit value 1

I couldn't solve the problem in any way. I am waiting for your help in this regard.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
multiDexEnabled = true
applicationId "com.apaweb.track"
minSdkVersion 16
targetSdkVersion 22
versionCode 14
versionName "2.0.3"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.+'
compile 'com.android.support:design:22.+'
compile 'com.android.support:cardview-v7:22.+'
compile 'com.android.support:recyclerview-v7:22.+'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.tuenti.smsradar:library:1.0.4'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.koushikdutta.async:androidasync:2.+'
}
I think that was the problem after updating the java.
JDK 1.7, JDK 1.8 and JDK 9 are installed in the system. I am using JDK 1.7 now.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_80\bin\java.exe'' finished with non-zero exit value 1
I solved the problem. By upgrading Android studio and gradle versions.

Dex Exception - I can't resolve

I have this error and I can't resolve it, I looking for interhet but not working...
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzzf;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "sk.tipos.paradox02.citaj"
minSdkVersion 11
targetSdkVersion 23
versionCode 26
versionName '2.0021'
}
buildTypes {
release {
minifyEnabled false
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.release
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
// signingConfig signingConfigs.release
}
}
productFlavors {
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.google.android.gms:play-services-analytics:9.0.0'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile 'com.google.firebase:firebase-ads:9.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.gms:google-services:3.0.0'
compile 'com.google.firebase:firebase-crash:9.0.0'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.android.support:design:23.0.0'
}
Error shown if I launch app. If rebuild project everything OK but when run project..
you are have several duplicate versions of library, keep only what you need nothing extra, Even after removing the duplicate libraries you are facing this error then try enabling multidex
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
in manifest inside application tag
<application
android:name="android.support.multidex.MultiDexApplication">
</application>
refer this
You've got both version 10.0.1 and 9.0.0 of 'com.google.firebase:firebase-ads'.
Remove the 10.0.1 version, as everything else is 9.0.0 and they should always have the same version.
This can be a lot of problems, but I believe this one is related to multidexing. You are enabling multidexing for the project and that's ok but this needs the multidex support library to be able to work on pre-Lolliopop.
Please add this to your dependencies
compile 'com.android.support:multidex:1.0.1'

Facebook Audience Network Ad Sdk dependency giving run time error in Android App

While adding below dependency in build.gradle
compile 'com.facebook.android:audience-network-sdk:4.+'
The run project is giving error
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzf.class
App, build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.xyz.abc"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/maven/com.squareup.picasso/picasso/pom.properties'
pickFirst 'META-INF/maven/com.squareup.picasso/picasso/pom.xml'
}
}
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
What can be possible solution for it?
Try this
compile('com.facebook.android:audience-network-sdk:4.13.0')
{
exclude group: 'com.google.android.gms'
}
Update Gradle and Android Studio to latest version and it starts working.

Duplicated entry at building Android application

I'm building android application and I have problem to build it. My build.gradle file contains:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.nakupniseznam"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
flatDir {
dirs 'aars'
}
}
}
dependencies {
//compile fileTree(include: ['*.jar'], dir: 'libs')
repositories {
maven {
url "http://dl.bintray.com/microsoftazuremobile/SDK"
}
}
compile files('libs/notification-hubs-0.3.jar')
compile files('libs/azure-notifications-handler-1.0.1.jar')
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.guava:guava:18.0'
compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3'
compile 'com.microsoft.azure:azure-notifications-handler:1.0.1#jar'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.2.0'
}
And the build error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/microsoft/windowsazure/notifications/BuildConfig.class
Still the same error.
Try to exclude multidex, but without success and I really don't know why :(

Categories