Good day.
After updating google repository in AndroidStudio, I have an issue
> Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry:
> android/support/v7/cardview/BuildConfig.class
I'm trying to exclude group android.support from play-services, it did not help.
When I started my project on another PC I have:
> Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry:
> android/support/annotation/AnimRes.class
my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "ru.alexeyk.myevents"
minSdkVersion 14
targetSdkVersion 23
versionCode 16
versionName "1.121"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.github.nkzawa:socket.io-client:0.4.2') {
exclude group: 'org.json', module: 'json'
}
compile files('libs/sentry-1.1.4.jar')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-annotations:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.github.machinarius:preferencefragment:0.1.2'
compile 'com.edmodo:cropper:1.0.1'
compile 'com.makeramen:roundedimageview:2.1.1'
compile 'org.ocpsoft.prettytime:prettytime:4.0.0.Final'
compile 'com.yandex.android:mobmetricalib:2.00#aar'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.google.android.gms:play-services-ads:8.1.0'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
}
In terminal execute in root project folder:
./gradlew clean
It helped me.
AndroidStudio Menu:
Build/Clean Project
Update old dependencies
All the above not working for me.. Because I am using Facebook Ad dependency..
Incase If anybody using this dependency compile 'com.facebook.android:audience-network-sdk:4.16.0'
Try this code instead of above
compile ('com.facebook.android:audience-network-sdk:4.16.0'){
exclude group: 'com.google.android.gms'
}
Open your system command prompt/terminal -> Go to your Project folder path (root project folder ) -> Execute following command : command :- gradlew clean or ./gradlew clean
Make sure that all your gradle dependencies are of same version. -> Example :- your appcompat and recyclerview dependencies should have same version.
-> Change your gradle dependencies to same version like :-
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
-> Rebuild your project and it will work fine.
Use project root in terminal like this:-/Users/rajnish/Desktop/RankProjects/ProjectCloud
After that enter this command ./gradlew clean
It will work.
There may be different reason for reported issue, few days back also face this issue 'duplicate jar', after upgrading studio. From all stackoverflow I tried all the suggestion but nothing worked for me.
But this is for sure some duplicate jar is there, For me it was present in one library libs folder as well as project libs folder. So I removed from project libs folder as it was not required here. So be careful while updating the studio, and try to understand all the gradle error.
I got this error because I did not have the correct line in my build.gradle. I am using the org.apache.http.legacy.jar library, which requires this:
android{
useLibrary 'org.apache.http.legacy'
...
}
So check that you have everything in your gradle file that is required.
I resolved the issue by double checking the "libs" directory and removing redundant jars, even though those jars were not manually added in the dependencies.
see if their duplicate jars or dependencies your adding remove it and your error will be gone:
Eg:
if you add android:supportv4 jar and also dependency you will get the error so remove the jar error will be gone
I resolve this is by changing the version no of recyleview to recyclerview-v7:24.2.1.
Please check your dependencies and use the proper version number.
For me the issue was caused by com.google.android.exoplayer conflicting with com.facebook.android:audience-network-sdk.
I fixed the problem by excluding the exoplayer library from the audience-network-sdk :
compile ('com.facebook.android:audience-network-sdk:4.24.0') {
exclude group: 'com.google.android.exoplayer'
}
Related
I have the error like
"Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzpm$zza$zza.class"
What should i do to remove this error
gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.user.merchant"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
//compile files('libs/google-play-services.jar')
}
As #Vaiden says the issue was:
"It seems that you have at least one library already bundled with GMS"
Every time that you face a duplicate entry error run ./gradlew app:dependencies and make sure that there is no duplicated versions of a same module. For example: in my case I had:
compile 'com.google.android.gms:play-services-gcm:9.0.0'
When I tried to use firebase in my project I add it like:
compile 'com.google.firebase:firebase-core:9.+'
compile 'com.google.firebase:firebase-messaging:9.+'
That makes my app crash cause when I navigate to the: app > build > intermediates > exploded-aar > com.google.android.gms one of the folders (play-services-basement) pull a version 9.4.0 instead 9.0.0 so what I did was to unificate the versions by adding firebase like:
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
In theory you can solve this too by pushing the firebase to 9.4.0 instead.
The bottom line is to try to know which things are your dependencies introducing to the app and check "WHO" is introducing the same thing to the app, once you get there try to set a specific version of that duplicated dependency.
Based from this forum, try to change the gradle inside your C:\Program Files\Android\Android Studio\gradle\ to gradle-2.10. Also, it seems unlikely that a program that is designed to run on an Android device doesn't need all of the jars. Try removing some of them.
Check this related SO questions:
TransformException duplicate entry for common.annotations.Beta
Android dependency issue with gms play services
It seems that you have at least one library already bundled with GMS.
None of the dependencies stated in your gradle build file should have it, so the culprit might be a library jar file in your libs dir. So either you have something in your libs dir you shouldn't have put there, or a library that has GMS bundled inside of it.
Did you remember to delete libs/google-play-services.jar?
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "SOMEID"
minSdkVersion 15
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.guava:guava:18.0'
compile 'com.google.guava:guava:18.0'
compile 'com.google.guava:guava:15.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I am fairly new to android, so please be aware. The application that I have been working on was under Ant build, and now have to change to Gradle to work with other new dependencies. And now, I am getting the following errors after migration through Android Studio->Import->Projects:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK overview-frame.html
File1: /Users/taeyounglee/StudioProjects/adr-android/app/libs/ormlite-android-4.45-javadoc.jar
File2: /Users/taeyounglee/StudioProjects/adr-android/app/libs/ormlite-core-4.45-javadoc.jar
Below are the ones that are in libs folder, I even tried hard-coding the dependencies on the build.gradle as well, but didn't work out:
HockeySDK-3.5.0.jar
http-request-4.2.jar
jsr305-2.0.1.jar
libGoogleAnalyticsV2.jar
ormlite-android-4.45.jar
ormlite-android-4.45-javadoc.jar
ormlite-android-4.45-sources.jar
ormlite-core-4.45.jar
ormlite-core-4.45-javadoc.jar
ormlite-core-4.45-sources.jar
otto-1.3.4.jar
picasso-2.1.1.jar
Any suggestions on this? The app uses ormlite, and requires both .jar files, as when I tried removing either one of those, it just throws compile errors. I tried looking up online about APK overview-frame.html, but can't seem to find reasonable answer. Help much appreciated, and thanks in advance!
If you can avoid it, stop using the jars. Gradle makes pulling dependencies down from Maven or JCenter super easy. When adding libraries like this to your projects, start thinking in terms of adding the dependency via accessing JCenter or Maven instead of manually downloading and placing the jar in your project.
compile 'com.j256.ormlite:ormlite-android:4.45'
compile 'com.j256.ormlite:ormlite-core:4.45'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup:otto:1.3.8'
compile 'net.hockeyapp.android:HockeySDK:3.7.2'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.github.kevinsawicki:http-request:6.0'
Here's their associating website references:
OrmLite
Picasso
Otto
Hockey
Analytics
HTTP Request
I got this below error
Error:(1, 1) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in C:\Users\TARUN\Desktop\GingerBuds\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip
Then I changed the above gradle path, Then following problem occurred,
I am getting this exception, while building my project . I rebuild and clean the project and updated google-play-services , then also i got error. can anyone please help me how to solve this.
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.io.FileNotFoundException: C:\Users\TARUN\Desktop\Gingerbuds\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\8.4.0\jars\classes.jar (The system cannot find the path specified)
Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.kitchenvilla.gingerbuds"
minSdkVersion 15
targetSdkVersion 23
versionCode 24
versionName "1.2.2"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
android {
publishNonDefault true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile 'org.apmem.tools:layouts:1.10#aar'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
}
This bug has been fixed according to Google dev blog: http://tools.android.com/tech-docs/new-build-system
2.0.0-alpha6 (2016/1/15)
Instant Run
Fix alpha5 reported issues :
- cannot build when importing play-services.
You should update android gradle tools version
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
}
This exception is thrown during a failed attempt to open the file denoted by a specified Path-name.
You can use
compile 'com.google.android.gms:play-services:8.3.0'
Update your classpath
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
this will solve it
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha2'
}
and
compile 'com.google.android.gms:play-services:8.3.0'
update gradle version to alpha9 in project level gradle file
classpath 'com.android.tools.build:gradle:2.0.0-alpha9'
i tried to import admob ads to a new app i was making and i ran into this problem...... i found the solution the be the StartAppInApp file being located in the wrong spot or not being there..... my app needed the StartAppInApp-3.1.1.jar file to be located in the libs folder and when i looked at my app there was no libs folder located there at all .....
open your main app folder... then click app and you should have 3 folders.... src ... build.... and libs .....
in my case there was no libs folder..... so i created the libs folder and then went and copied the StartAppInApp-3.1.1.jar file from a different android project i had and i pasted it to the new libs folder i made in my current project... the error is now GONE!
i also made sure to include
compile files('libs/StartAppInApp-3.1.1.jar')
in the dependencies of my app gradle file
not sure if this is a solid answer but if anyone has this problem double check your StartAppInApp-3.1.1.jar location and version and check your gradle dependencies
I imported an Eclipse project in Android Studio. It uses the facebook SDK. In order to import it, I had to make sure the FacebookSDK folder was in the project path. The import was successful and I was able to do a build and there were no errors. However, when I try to run the app in the simulator I get the following error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/facebook/AccessToken$SerializationProxyV1;
From my research, this points to the fact that the com.facebook.android package resides in 2 places: in my project and in the FacebookSDK module, which is a dependency. To resolve this, my research indicates that I need to remove the package from my project and leave it in the FacebookSDK module.
I tried doing this in Android Studio by deleting the package from the Build folder (build\generated\source\r\debug\com.facebook.android). However, when I rebuild the project, it regenerates the package. So I decided to delete the package from Finder outside of Android Studio. But the same thing happens when I run a rebuild.
Please let me know what I am doing wrong, or if there is some way to exclude this package from the build, other than removing it.
By the way, in order to exclude the package from the build, I tried putting this in my project's build.gradle (which I found in an answer on stackoverflow), but the error still occurred:
configurations {
all*.exclude group: 'com.facebook.android'
}
Here's my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId 'org.bicsi.fall2015'
minSdkVersion 14
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
configurations {
all*.exclude group: 'com.facebook.android'
}
dependencies {
compile project(':facebookSDK')
compile 'com.android.support:support-v4:19.1.0'
compile files('libs/Parse-1.3.8.jar')
compile files('libs/PushIOManager.jar')
compile files('libs/crittercism_v4_3_0_sdkonly.jar')
compile files('libs/facebooksdk.jar')
compile files('libs/httpclient-4.0.1.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/stackmob-android-sdk-1.3.5.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
}
Your issue is here:
compile project(':facebookSDK')
compile files('libs/facebooksdk.jar')
You are using the same library (may be with different version) twice.
Remove the jar from your dependency.
Also, using Android Studio and the gradle system I suggest you removing your module locally and using
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
instead of compile project(':facebookSDK')
I would recommend you to place your 'gradle.build' file, showing the dependencies part, so it would be easier to help you.
From your explanation, you are importing twice the facebook module, from the imported module and from your own build, right?
Using compile project to include module and also getting it from maven repository. Maybe something like this?
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile project(':my_project_that_contains_facebook')
}
If thats the case, you can just do the following
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile (project(':my_project_that_contains_facebook')) {
exclude module: 'com.facebook.android'
}
}
What does this error message mean? I don't have duplicated packages in my project
Error:Execution failed for task ':SimpleReader:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms'
You can temporarily disable this error with
android.enforceUniquePackageName=false However, this is temporary and
will be enforced in 1.0
My build.gradle looks like this:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.1'
}
}
apply plugin: 'android'
android {
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 17
}
compileSdkVersion 17
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
buildTypes {
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile 'com.google.android.gms:play-services:4.2.42'
compile files('libs/gson-2.2.4.jar')
compile files('libs/httpmime-4.1.jar')
compile files('libs/httpclient-4.1.1.jar')
compile files('libs/jsoup-1.7.3.jar')
compile project(':libraries:actionbarsherlock')
compile project(':libraries:sherlocknavigationdrawer')
compile project(':libraries:googleplayservices')
compile project(':libraries:androidslidinguppanel')
compile files('libs/protocol-1.0.4.jar')
compile files('libs/sentry-0.1.4.jar')
compile files('libs/commons-lang-2.3.jar')
}
In my case, the problem was because I was including:
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.google.android.gms:play-services:4.4.52'
both the wearable play services, and the regular.
I commented out the wearable part, and it works.
Not sure if I'll need it, but it was included by default by the project wizard
today I met the same problem. I need to use Google Analytics, so I import google analytics lib following the tutorial:
compile 'com.google.android.gms:play-services-analytics:9.0.0'
then compile the project, gradle tell me Error: more than one library with package name 'com.google.android.gms'
I can definitely sure that I only directly import com.google.android.gms one time by google analytics lib.
so I navigate to Project tab in Android Studio to see what are the libs this project depend on, then I found play-services-6.5.87 display in External Libraries, like following screenshot:
so now I know there is another lib depend on play-services-6.5.87, but I don't which lib it is.
then I use a gradle command in console to see the project dependencies:
$ ./gradlew -q app:dependencies
the result tells me that com.facebook.android:audience-network-sdk:4.6.0 depend on it.
so how we fix this problem, two way:
if you don't need this audience-network-sdk, just remove it. my project in fact doesn't need it.
if you also need audience-network-sdk and google-analytics, use exclude group grammar, like following snippet code.
//facebook SDK
compile ('com.facebook.android:audience-network-sdk:4.6.0')
{exclude group: 'com.google.android.gms'}
// google analytics
compile 'com.google.android.gms:play-services-analytics:9.0.0'
in your case, the audience-network-sdk can be any other lib that depends on same lib with other libs. here is just a thinking of how to resolve similar problems.
Try removing compile project(':libraries:googleplayservices') or compile 'com.google.android.gms:play-services:4.2.42'. I am pretty sure they are the same library.
I faced similar issue, i got it resolved by following steps:
ionic platform rm android
ionic platform add android
ionic build android
this is a problem with versions. if you have multiple dependencies of same package path ensure the versions are the same
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
I had confused with this problem for a long time.My issue is little different with the question though same error log. I want my sublib's buildtype same with my application's buildtype. So I assigned the buildtype for sublib as the document tells me.
[Gradle Plugin User Guide][1]
This the error I got.
processing flavorCustomResource
Error: more than one library with com.xxx.libCommon
This is my structure. lib1 and lib2 are independent of each other.
app
-> lib1 -> libCommon
-> lib2 -> libCommon
I got the error only when I build my custom buildtype.However, The release version was Ok.
More details. some parts of my build.gradle
app:
android {
buildTypes {
release{}
custom{}
}
}
configurations {
flavorReleaseCompile
flavorCustomCompile
}
dependencies{
compile project(':lib1')
flavorReleaseCompile project(path: ':lib2', configuration: ':release')
flavorCustomCompile project(path: ':lib2', configuration: ':custom')
}
lib1:
android {
publishNonDefault true
buildTypes {
release{}
custom{}
}
}
dependencies{
releaseCompile project(path: ':libCommon', configuration: ':release')
customCompile project(path: ':libCommon', configuration: ':custom')
}
lib2
dependencies {
compile project(':libCommon')
}
Solution: configure the lib2 as lib1. the problem will be solved.
lib2:
android {
publishNonDefault true
buildTypes {
release{}
custom{}
}
}
dependencies{
releaseCompile project(path: ':libCommon', configuration: ':release')
customCompile project(path: ':libCommon', configuration: ':custom')
}
Reason
The problem is something about Library Publication
The default publish is release. if lib2 is not configured, it will use the default publish libCommon(release version) which is different from lib1 -> libCommon(custom version) assigned by lib1's build.gradle.This comes the error.
I wish my post will help someone struggle with the same issue or give some hint to him/her.