I have gone through many answers for this question like:
Error :: duplicate files during packaging of APK
Gradle sync fails after adding Firebase dependency: duplicate files during packaging of APK
But still after adding packagingOptions I am getting duplicate file error.
I am working on library and here is my app build gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.mcxiaoke.volley:library:1.0.14'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3')
}
EDIT
Adding packagingOption to my sample where I am adding my library as dependency solves the problem can anyone let me know why I have to add it to my sample build.gradle? Or is there any way to remove from sample.
Related
When I press on run in Android studio an Edit configuration windows pops up and says "Error: Module not specified".
I have added sources to the application libs folder by manually making a folder structure android/hardware/automotive/vehicle/V2_0 and copied the files in there.
Build completes without errors.
I haven't edited the MainActivity -class so it is all pre-generated code.
I believe this error has something to do with incorrect syntax when including but it seems to be hard to get it working :)
this is my settings.gradle file:
include ':app'
project(':app').projectDir = new File('libs/android/hardware/automotive/vehicle/V2_0')
and this is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.s26150.testingopencar"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile project(":android.hardware.automotive.vehicle.V2_0")
testCompile 'junit:junit:4.12'
}
What could be the issue here?
thanks in advance.
Error description:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/api/client/googleapis/auth/clientlogin/ClientLogin$Response.class
build.gradle code here
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion '23.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.jasp.eventapp"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.8.2'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.couchbase.lite:couchbase-lite-android:1.4-46'
//compile 'com.google.api-client:google-api-client-android:1.22.0'
//compile 'com.google.api-client:google-api-client-xml:1.22.0'
compile 'com.google.api.client:google-api-client:1.4.1-beta'
compile 'com.google.api-client:google-api-client-jackson2:1.22.0'
compile files('libs/google-api-client-1.5.0-beta.jar')
compile 'com.google.android.gms:play-services:9.2.1'
}
Any version problem in imported libs...?How can I handle this...?I tried by cleaning the project
Build - > Clean
after that rebuild, But no effect...Can any one please help me...
This error occurs when you are using duplicate version of same library, or when you use a library project which has same dependency
compile 'com.google.api.client:google-api-client:1.4.1-beta'
compile 'com.google.api-client:google-api-client-jackson2:1.22.0'
compile files('libs/google-api-client-1.5.0-beta.jar')
these three looks like same library , removing duplicate version of the library should fix your error
I had the same problem with Feign library. Look in the .idea\libraries directory in your project, find the same library with different versions and remove one. It should be help.
I am trying to implement facebook mobile ads in an android app. Everything went fine but in build gradle i m getting error.
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry:
com/facebook/ads/AbstractAdListener.class.
And build.gradle codes are
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.mohit.warmodroid.practicefbads"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
multiDexEnabled true
}
}
}
dependencies
{
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile ('junit:junit:4.12'){
exclude group: 'com.facebook.ads', module: 'classes.jar'
}
compile 'com.android.support:appcompat-v7:23.0.1'
compile ('com.android.support:design:23.0.1'){
exclude group: 'com.facebook.ads', module: 'classes.jar'
}
compile('com.facebook.android:audience-network-sdk:4.7.0'){
exclude group: 'com.facebook.ads', module: 'classes.jar'
}
compile 'com.android.support:multidex:1.0.0'
}
I tried everything availble on stackoverflow.com but unable to clear it.
Please help me out.
In the Gradle settings and project configurations there is an old version of AudienceNetwork.jar, existing in the \libs folder. Remove this jar file from \libs and rebuild the project: this should fix the problem.
I am trying to use Firebase in my Android Studio project and it is giving me an empty Gradle error.
I have tried using the Firebase SDK with Gradle, as well as putting the jar in my libs folder and both give the same blank Gradle error.
i have followed the Android quickstart here: https://www.firebase.com/docs/android/quickstart.html
I put in the packagingOptions and that didn't work. Without an actual error message it's very hard to debug! I haven't written any code for Firebase, i am only trying to get it to run with the Firebase Android SDK without getting a Gradle error
My project works when Firebase is not included.
Any ideas?
Thanks!
Have this content in your build.gradle (Module:app)
android {
//so default auto generated blocks will be here ...
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
} // end of android node
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.firebase:firebase-client-android:2.3.1'
}
Thanks for your help guys, it looks like it was a dex limit error. Adding the Firebase SDK must have put me over the limit, to fix this i had to add multiDexEnabled true in the defaultConfig section of my app:build.gradle file as well as compile 'com.android.support:multidex:1.0.0' in the dependencies
you might need to enable 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'
}
The complete app/build.gradle from one of my projects:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.firebaseuser.nanochat"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.firebase:firebase-client-android:2.3.1+'
}
I want use JUnit 4 framework in my android app and for that reason I added test support library and now my project now working. Here is the stack trace:
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK LICENSE.txt
File 1: C:\Users\Damian\.gradle\caches\modules-2\files-2.1\junit\junit-dep\4.10\64417b3bafdecd366afa514bd5beeae6c1f85ece\junit-dep-4.10.jar
File 2: C:\Users\Damian\.gradle\caches\modules-2\files-2.1\junit\junit-dep\4.10\64417b3bafdecd366afa514bd5beeae6c1f85ece\junit-dep-4.10.jar
This is my build.gradle file:
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "project.myapp.damian.myapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
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.0.0'
compile 'com.android.support.test:testing-support-lib:0.1'
compile 'com.android.support.test.espresso:espresso-core:2.0'
compile 'com.android.support.test.uiautomator:uiautomator-v18:2.0.0'
}
Look here and read the error message regarding the ignoring of license files.
Pasted from android studio.
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'LICENSE.txt'
}
}