Am getting an unexpected error in Android studio while running the app,following is the error message which am getting
Error:duplicate files during packaging of APK
/home/jithu/libs/android/android/aa/app/build/outputs/apk/app-debug-unaligned.apk
Path in archive: META-INF/DEPENDENCIES Origin 1:
/home/jithu/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.6/cf8bacbf0d476c7f2221f861269365b66447f7ec/httpmime-4.3.6.jar
Origin 2:
/home/jithu/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.1/f5aa318bda4c6c8d688c9d00b90681dcd82ce636/httpcore-4.4.1.jar
Am pasting my build.gradle file also
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'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'com.google.code.gson:gson:2.2.4'
compile "org.apache.httpcomponents:httpcore:4.4.1"
compile "org.apache.httpcomponents:httpmime:4.3.6"
}
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
// ...
}
Well you are missing the flow of build gradle.
As you are trying to use 2 android {..} snippet it is not detecting the 2nd one. As a result your exclusion of duplicate meta files are not working.
Possible solution:
Just change the order of your build gradle like below:
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/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'com.google.code.gson:gson:2.2.4'
compile "org.apache.httpcomponents:httpcore:4.4.1"
compile "org.apache.httpcomponents:httpmime:4.3.6"
}
If it still didn't work then check out the following:
Is it your library build gradle?
I excluded my duplicate meta files from my main projects build gradle. So make sure to exclude the meta files from build gradle of app module rather than library module.
Related
I would like someone to help me with this Android Studio error. I have bought an Android Application in internet, and I have also the android studio project files.
The thing is that this application has been made with an older version of Android studio I think, probably like 1 year and a half ago.
I get this error Could not find method ImplementationSdkVersion() for arguments [26] on object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension. after replacing all compile with implementation because those showed warnings and when I tried to get an APK from my android studio project that APK crashed on my Samsung.
This is the gradle module app code:
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
ImplementationSdkVersion 26
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "codecanyon.carondeal"
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'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
productFlavors {
}
}
repositories {
mavenCentral() // jcenter() works as well because it pulls from Maven Central
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
Implementation('org.apache.httpcomponents:httpmime:4.3') {
exclude module: "httpclient"
}
//implementation 'com.android.support:cardview-v7:26.0.0'
implementation 'com.android.support:appcompat-v7:26.0.0-alpha1'
implementation 'com.android.support:design:26.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.android.support:cardview-v7:26.0.0-alpha1'
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
implementation 'com.android.support:support-v4:26.0.0-alpha1'
implementation 'com.daimajia.swipelayout:library:1.2.0#aar'
testimplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Oh I finally found the solution. I just changed the
ImplementationSdkVersion 26
to
compileSdkVersion 26
and it worked. :) ^_^
it is because you replaced all compile with implementation
After downloading SDK 26 and updated my project I had some library conflicts which I successfully fixed. But I have this persistent issue that it is tackled nowhere in the forums or SO.
My XML preview is broken. I can build and run the program but I can't see anything because of that:
I tried:
Changing the theme from Theme.AppCompat.Light.DarkActionBar to
Base.Theme.AppCompat.Light.DarkActionBar
Updating my gradle in a similar way
Invalidate Cache / Restart
Checked and updated all my libraries and removed all errors regarding gradle
Changed the api on the preview
All SDKs are updated.
Everything was fine right before I update to SDK 26. All the solutions available do nothing. Help would be very much appreciated
EDIT
my gradle.build
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "gr.softweb.sakouli"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(path: ':linkedin-sdk')
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
// configurations.all {
// resolutionStrategy.eachDependency { DependencyResolveDetails details ->
// def requested = details.requested
// if (requested.group == 'com.android.support') {
// if (!requested.name.startsWith("multidex")) {
// details.useVersion '26.0.1'
// }
// }
// }
// }
compile 'com.facebook.android:facebook-android-sdk:4.26.0'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support:customtabs:26.0.0'
compile 'com.koushikdutta.ion:ion:2.2.1'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.roughike:bottom-bar:2.3.1'
compile 'com.ncapdevi:frag-nav:2.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'co.lujun:androidtagview:1.1.4'
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.braintreepayments.api:drop-in:3.1.0'
testCompile 'junit:junit:4.12'
apply plugin: 'com.google.gms.google-services'
}
Updating the following:
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
to the following solved the problem for me:
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
Build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.myandroidgoogleappengine"
minSdkVersion 15
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'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-database:11.2.2'
}
apply plugin: 'com.google.gms.google-services'
I had the same problem .Just updated 26.0.0 to 26.0.0-alpha1 and the problem is solved.
Hi i am trying to build APK but i Fetching this problem in Android Studio.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/INetworkTaskCallback$Stub.class
Gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.mouad.fixmyphone"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
The documentation for Firebase JobDispatcher says to include only one of these:
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
You are including both. Because your app does not have a dependency on com.google.android.gms:play-services-gcm, you should only include this library:
compile 'com.firebase:firebase-jobdispatcher:0.5.2'
Remove this line from your dependencies:
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
Hi im new to retrofit and I got this error:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.retrofit2/retrofit/pom.properties
File1: C:\Users\LouDoms\Documents\PICZON\LoOck2\app\libs\retrofit-2.0.0-beta3.jar
File2: C:\Users\LouDoms\.gradle\caches\modules-2\files-2.1\com.squareup.retrofit2\retrofit\2.0.0-beta3\97675641051febfee098903cc0eff62f2826e34e\retrofit-2.0.0-beta3.jar
I tried to include the packaging options but they didn't work. Someone help me please as I don't know what to do or what to remove.
My gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.loudoms.loock"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
compile 'com.jakewharton:butterknife:7.0.1'
}
This question is because ModuleA and ModuleB has same jar(also this jar has META-INF direct),
method is:create a new Module(select Library),then take the jar join to this Module's "libs" direct,then let ModuleA and ModuleB dependent this Module Library.
In this way,no DuplicateFileException.
I have been using Picasso for quite a while now. I have encountered a weird problem today.
I simply loaded an image url to an imageview with this code,
Picasso.with(_context)
.load(groupDeatils.getThumbnail()).transform(new CircleTransform())
.into(group_pic);
This is my gradle build,
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.km.contribill"
minSdkVersion 15
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/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
dexOptions {
incremental true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.shamanland:fab:0.0.8'
compile 'com.squareup.picasso:picasso:2.5.2'
compile project(':library')
}
After building the project when I run it and go to the page I am getting this error,
java.lang.NoClassDefFoundError: com.squareup.picasso.Utils
Any help would be appreciated.