Duplicated files copied in APK. Android - java

I'm trying to send a file to my Datastore of google. When I try to run the application I take the following error:
Error:Execution failed for task
':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files
copied in APK
com/google/appengine/repackaged/org/apache/commons/codec/language/bm/sep_approx_spanish.txt
File1:
C:\Users\Javier.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-endpoints\1.9.28\bf2e8a74bd28e388b3487fc78a0c7adfa592fd5d\appengine-endpoints-1.9.28.jar
File2:
C:\Users\Javier.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-api-1.0-sdk\1.9.34\7c15c22fd362478e9758081d28e51590304d5ff4\appengine-api-1.0-sdk-1.9.34.jar
I tried exclude the file with
packagingOptions {
exclude 'sep_approx_spanish.txt'
}
but it doesn't work. My Build.gradle is the next:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.javier.wh"
minSdkVersion 23
targetSdkVersion 24
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 'sep_approx_spanish.txt'
}
}
dependencies {
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.0.1'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.android.support:support-v4:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.google.code.findbugs:jsr305:2.0.1'
testCompile 'junit:junit:4.12'
compile project(path: ':backend', configuration: 'android-endpoints')
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.34'
compile 'com.google.appengine:appengine-endpoints:1.9.28'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.28'
compile 'javax.servlet:servlet-api:2.5'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.guava:guava:19.0'
compile 'com.googlecode.objectify:objectify:5.1.12'
}
Someone had the same problem?
Help please!

Put below line in your app build.gradle inside android block
packagingOptions {
pickFirst 'com/google/appengine/repackaged/org/apache/commons/codec/language/bm/sep_approx_spanish.txt'
}

Related

Cannot Build release apk version

The Problem occur when i generate release version of the APK . I have already view this question and try all things mention but problem still exists Please point me in the right direction
Error
Error:Execution failed for
task:app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
android/support/design/widget/CoordinatorLayout$1.class
gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.example.wildstone.cv_maker"
minSdkVersion 19
versionCode 1
versionName "1.0"
targetSdkVersion 27
multiDexEnabled true //important
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:27.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.itextpdf:itextg:5.5.10'
testCompile 'junit:junit:4.12'
}
This generally happens when you are using different versions of SDK and support libraries.
Replace the versions of these
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
to
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
and it should work.

Building an APK generates Error:Execution failed for task

When I try to build with my current gradle.build file, I get an error, then following that my gradle build.
Why is it causing this 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/zzaf$zzd.class
this is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.usmans.videodownloader"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
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.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
// glide
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.io.tools.android.ramiloif.folderchooser:folderchooser-dialog:1.0.6'
I don't know what is causing this. What can I do to solve this issue?
Change and exclude gms from facebook library.
compile ('com.facebook.android:audience-network-sdk:4.+'){
exclude group:"com.google.android.gms"
}
Then clean and rebuild your project.
Hope it works :)

Android studio failed to instantiate one or more classes after update to SDK 26

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.

Couldnt find solution for - Error:Execution failed for task

I have tried everything what i found while googling but still have a mistake.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbut.class
My gradle
apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
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')
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
// FirebaseUI Auth only
compile 'com.firebaseui:firebase-ui-auth:1.2.0'
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:1.2.0'
compile 'com.google.firebase:firebase-storage:10.2.6'
// Single target that includes all FirebaseUI libraries above
compile 'com.firebaseui:firebase-ui:1.2.0'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
This is because of your "multidex" dependency and "multiDexEnabled true" in debug flavor.

Picasso crashed with NoClassDefFoundError

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.

Categories