I have a android studio project contains two modules use same library (jsoup). When i compie app it will show
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/org.jsoup/jsoup/pom.xml File1:
C:\Users\G.gradle\caches\modules-2\files-2.1\org.jsoup\jsoup\1.8.2\64238922c4006c3d0a9951c4c03983ecc6a1e1a0\jsoup-1.8.2.jar
File2:
C:\Users\G\AndroidStudioProjects\twrb\app\build\intermediates\exploded-aar\twrb\webviewtimetablesearcher\unspecified\jars\classes.jar
The dependencies in build.gradle of two modules as show below.
dependencies {
compile 'org.jsoup:jsoup:1.8.2'
}
And this is build.gradle of app.
dependencies {
compile project(':moduleA')
compile project(':moduleB')
}
How to fix it?? Thanks.
This is my whole build.gradle of app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.test.tmp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
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'
exclude 'META-INF/maven/org.jsoup/jsoup/pom.xml'
exclude 'org/jsoup/nodes/entities-base.properties'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.4'
}
}
// Required because retrolambda is on maven central
repositories {
mavenCentral()
}
apply plugin: 'com.android.application' //or apply plugin: 'java'
apply plugin: 'me.tatarka.retrolambda'
dependencies {
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'io.realm:realm-android:0.87.5'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.0'
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
testCompile 'junit:junit:4.12'
androidTestCompile 'junit:junit:4.12'
compile project(':moduleA')
compile project(':moduelB')
}
For resolve it you must add
android {
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
in build.gradle
Related
I'm new to android, so please bear with me if my question is stupid.
I have an android project built in older version of gradle. The app works fine when modifying code in existing activities, but whenever I create a new activity, I get the following error:
Error:(77, 13) Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2
Upgrade plugin to version 3.0.1 and sync project
Show in File
Show in Project Structure dialog
This is the content of app level gradle file:
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias ''
keyPassword ''
storeFile file('')
storePassword ''
}
}
compileSdkVersion 27
buildToolsVersion "23.0.2"
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'
}
defaultConfig {
applicationId ""
minSdkVersion 15
targetSdkVersion 22
multiDexEnabled true
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
repositories {
jcenter()
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
incremental true
}
productFlavors {
}
}
dependencies {
//compile fileTree(include: ['*.jar'], dir: 'libs')
//Fast and simple data storage library for Android
// compile project(':squarecamera')
// compile 'com.github.boxme:squarecamera:1.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.6'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'io.paperdb:paperdb:0.9'
compile 'com.fabiendevos:nanotasks:1.1.0'
compile 'com.flipboard:bottomsheet-core:1.5.0'
compile 'com.flipboard:bottomsheet-commons:1.5.0'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.okhttp:okhttp:1.6.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-jackson:2.0.0-beta2'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile project(':squarecamera')
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
This is my project level gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
And my android studio version is 3.0.1.
When I update the plugin, I get a lot of compatibility issues.
Please help me resolve this. Thanks in advance!
I have been having some issues with this for a while
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/facebook/AccessToken$1.class
I do not know what to do, please help.
this is my build gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23"
aaptOptions {
useNewCruncher false
}
defaultConfig {
applicationId "com.example.dell.treblemusic"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled 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'
}
lintOptions {
abortOnError false
}
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 files('libs/clink210.jar')
compile files('libs/eventbus-2.4.0.jar')
compile files('libs/picasso-2.5.2.jar')
compile project(':PayPalAndroidSDK-2.12.4')
compile 'com.google.android.gms:play-services-wallet:8.4.0'
compile 'com.stripe:stripe-android:1.0.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.stripe:stripe-java:1.37.1'
compile 'com.android.support:multidex:1.0.1'
compile project(':VisaCheckout-Android-SDK-2.9')
compile files('libs/card-io-5.1.1.jar')
compile files('libs/android-volley-1.0.10.jar')
compile 'com.pnikosis:materialish-progress:1.0'
compile files('libs/httpclient-4.2.4.jar')
compile files('libs/apache-httpcomponents-httpcore.jar')
compile files('libs/guava-13.0.1.jar')
compile project (':facebook-android-sdk-4.10.0')
compile 'com.android.support:cardview-v7:22.2.1'
}
You might be using different version of sample modules.
Please follow these steps
Add multidex in the gradle
In the module app gradle
android {
......
defaultConfig {
....
multiDexEnabled true
}
Added the dependency
compile 'com.android.support:multidex:1.0.1'
Add the facebook module and exclude dependent libraires
compile('com.facebook.android:facebook-android-sdk:$faceBookVersion') {
exclude group: 'com.android.support', module: 'multidex'
}
If You are using various Google play services like Location, Authentication etc, you should use same level of Libraries.
eg:
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-appindexing:10.0.1'
dependencies in Module build.gradle are
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.0-alpha7'
compile 'com.android.support:design:26.+'
compile 'org.apache.flink:flink-streaming-java_2.11:1.4.0'
}
but whenever I compile the code it gave me the following error
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK reference.conf File1: /Users/amar/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-actor_2.11/2.4.20/251b1d970698b81dad5aa8b84eec3eea835259d2/akka-actor_2.11-2.4.20.jar File2: /Users/amar/.gradle/caches/modules-2/files-2.1/org.apache.flink/flink-runtime_2.11/1.4.0/c55676f3ca4c7edd82374659471e98b2384868a8/flink-runtime_2.11-1.4.0.jar File3: /Users/amar/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-stream_2.11/2.4.20/7545a4f86cbb372c337dbdb2846110df86a8cc70/akka-stream_2.11-2.4.20.jar File4: /Users/amar/.gradle/caches/modules-2/files-2.1/com.typesafe/ssl-config-core_2.11/0.2.1/3d2e6a36a7427d6f9d3921c91d6ac1f57dc47b57/ssl-config-core_2.11-0.2.1.jar
This problem was solved by following these steps
step # 1 using the dependency from https://mvnrepository.com instead of https://search.maven.org.
step # 2 Also, I found out that as these files are large which crosses the limit of 64K classes that can be included in DEX files, so I have to configure for Multidex details of which are given here
step # 3 most of the issue was being created by Jacktoolchain, so we can disable that and replace it with retro-lambda for which you can follow this tutorial. Make sure to disable Jacktoolchain by commenting or deleting as shown below
// jackOptions { enabled true }
// dexOptions { incremental true }
step # 4 Exclude these packages from packagingOptions as shown below
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
step # 5 You may find it weird, but this hack works like
compile group: 'org.apache.flink', name: 'link-java', version: '1.4.0'
was not working and was giving some error, but it worked when compile is replaced by provided. I don't know why, please let me know if you know
provided group: 'org.apache.flink', name: 'flink-java', version: '1.4.0'
Luckily flink-streaming-java_2.11 library already had provided mentioned in https://mvnrepository.com
provided group: 'org.apache.flink', name: 'flink-streaming-java_2.11', version: '1.4.0'
Final Module build.gradle has these contents
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
repositories {
mavenCentral()
}
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
configurations.all {
// Enforces Gradle to only compile the version number you state for all dependencies, no matter which version number the dependencies have stated.
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
// jackOptions { enabled true }
// dexOptions { incremental true }
multiDexEnabled true
applicationId "com.example.amar.testing"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
customDebugType {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
// not sure if adding compatibility is required here
sourceCompatibility = 1.7
targetCompatibility = 1.7
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.0-alpha7'
compile 'com.android.support:design:26.+'
testCompile 'junit:junit:4.12'
// for multidex
compile 'com.android.support:multidex:1.0.0'
// for CEP
provided group: 'org.apache.flink', name: 'flink-java', version: '1.4.0'
provided group: 'org.apache.flink', name: 'flink-streaming-java_2.11', version: '1.4.0'
}
Final Application build.gradle has these contents
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
sourceCompatibility = 1.7
targetCompatibility = 1.7
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
I tried to build apk it comes out this. What should I do? Please help!!
I don't where is the problem. The project is fine when I build the project, but it come error when I build apk.
Error:Execution failed for
task':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzf.class
Here is the gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId 'com.androidbelieve.SeeDate'
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
useLibrary 'org.apache.http.legacy'
multiDexEnabled true
}
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'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.android.support:support-v4:22.2.1'
compile 'it.neokree:MaterialNavigationDrawer:1.3.3'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.firebase:firebase-client-android:2.5.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebaseui:firebase-ui:0.6.0'
}
apply plugin: 'com.google.gms.google-services'
gradle project
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Did you tried Build/Clean Project in Android Studio Menu
Which dependency does the app:transformClassesWithJarMergingForDebug come from? Maybe you should modify that dependency's version number to be consistent with the major sdk version.
I'm new to Gradle, and downloaded a project from a repository at work.
When I open the project, Gradle cannot sync.
Error:Could not find org.robobinding:codegen:0.8.9.
Searched in the following locations:
file:/C:/Users/Marcelo/AppData/Local/Android/sdk/extras/android/m2repository/org/robobinding/codegen/0.8.9/codegen-0.8.9.pom
file:/C:/Users/Marcelo/AppData/Local/Android/sdk/extras/android/m2repository/org/robobinding/codegen/0.8.9/codegen-0.8.9.jar
file:/C:/Users/Marcelo/AppData/Local/Android/sdk/extras/google/m2repository/org/robobinding/codegen/0.8.9/codegen-0.8.9.pom
file:/C:/Users/Marcelo/AppData/Local/Android/sdk/extras/google/m2repository/org/robobinding/codegen/0.8.9/codegen-0.8.9.jarRequired by:
GollogAndroidApp:gollog:unspecified
Acording to this log error, I guess that Gradle is not searching Robobinding online. I looked at work offline configuration of Gradle at Android Studion and is not checked.
Here is my gradle.build
buildscript {
repositories {
jcenter()
maven() {
name 'RoboBinding AspectJPlugin Maven Repository'
url "https://github.com/RoboBinding/RoboBinding-aspectj-plugin/raw/master/mavenRepo"
}
}
dependencies {
classpath 'org.robobinding:aspectj-plugin:0.8.4'
classpath 'com.android.tools.build:gradle:1.1.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
}
}
apply plugin: 'com.android.application'
apply plugin: 'org.robobinding.android-aspectj'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
lintOptions{
ignoreWarnings true
}
defaultConfig {
applicationId "br.com.fake.fakeproject"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
productFlavors {
dev {
applicationId "br.com.edeploy.fake.fakeproject"
}
prod {
applicationId "br.com.edeploy.fake.fakeproject"
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
ext {
//robobindingVersion = 'latest.integration'
daggerVersion = '1.2.2'
robobindingVersion = '0.8.9'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.android.support:support-v4:23.0.1'
compile 'net.danlew:android.joda:2.8.2'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile("org.robobinding:robobinding:$robobindingVersion:with-aop-and-dependencies") {
exclude group: 'com.google.guava', module: 'guava'
}
aspectPath("org.robobinding:robobinding:$robobindingVersion:with-aop-and-dependencies") {
exclude group: 'com.google.guava', module: 'guava'
}
apt "org.robobinding:codegen:$robobindingVersion"
compile 'com.google.auto.value:auto-value:1.1'
apt "com.squareup.dagger:dagger-compiler:$daggerVersion"
compile "com.squareup.dagger:dagger:$daggerVersion"
/*provided "org.glassfish:javax.annotation:10.0-b28"*/
testCompile "junit:junit:4.12"
testCompile "org.mockito:mockito-all:1.10.19"
}
I have Android and Google repository updated.
I'm using Android Studio 1.4
Tks!
You defined the repository only for your buildscript - not for the project - add this:
repositories {
jcenter()
}
on root level behind: apply plugin: 'com.neenbedankt.android-apt'