Execution failed for task ':app:transformClassesWithJarMergingForRelease [duplicate] - android

I am trying to build a signed Apk of my project and i get the following error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/internal/zzv$zza$zza.class
When I choose the debug build type I got no errors and everything works fine. I searched for a while to fix this but i found nothing useful.
My build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.danielsous.demos"
minSdkVersion 14
targetSdkVersion 24
multiDexEnabled true
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile files('libs/scanditsdk-android-4.7.5.jar')
compile 'com.android.support:support-v4:24.2.1'
compile 'com.github.attenzione:android-ColorPickerPreference:e3aa301016'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.code.gson:gson:2.7'
}
The other build.gradle:
// 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.1.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
}

I had 1 library and a second library made from an aar file which contained multiple resource with the same names ( pngs files with same names, strings with the same ids, layouts with the same files ). Removing the aar library fixed my issues

It seems that you have more than one libraries added for printHelper.
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.

Related

Unable to publish Android library project on JitPack

I made a small library for Android which I uploaded on my public Github repositroy. The library project contains also a sample app. To enable building on JitPack I followed JitPack's own instructions.
Now that i try build it remotely with JitPack i get following error:
WARNING:
Gradle 'install' task not found. Please add the 'maven' or 'android-maven' plugin.
See the documentation and examples: https://jitpack.io/docs/
Adding maven plugin
Found android library build file in Library
Running: gradle clean -Pgroup= -Pversion=v1.2 install
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Djavax.xml.accessExternalSchema=all
Gradle version Gradle 3.1
FAILURE: Build failed with an exception.
* What went wrong:
Task 'clean' not found in root project 'build'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.532 secs
EXIT_CODE=1
2017-03-22T19:01:33.352614259Z
Exit code: 1
No build artifacts found
Here is the root build file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Build file for the library:
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group=
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
}
}
Build file for the sample app:
apply plugin: 'com.android.application'
buildscript {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId
minSdkVersion 15
targetSdkVersion 25
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:25.2.0'
compile project(':Library')
}
The project is missing a settings.gradle file where you include the library:
include ':Library'
Would also recommend adding the gradle wrapper so that JitPack builds with the correct Gradle version.
Example project: https://github.com/jitpack/android-example

Android says duplicate entry, but it's not

I am converting a project from Eclipse to Android Studio. It wasn't easy. I tried to put the AdMob banner and I got an error like this.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/ads/identifier/AdvertisingIdClient$zza.class
There's only 1 AdvertisingIdClient$zza.class file in the project.
Why am I getting this error?
I have spent many hours on this, but no clues.
Can anyone help me, please?
Thanks for all replies. Here's my gradle files.
app-gradle >>>>
apply plugin: 'com.android.application'
android {
compileSdkVersion 13
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "sw.ko.aaaaa.bbbbb"
minSdkVersion 9
targetSdkVersion 9
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
}
dependencies {
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/commons-email-1.2.jar')
compile files('libs/commons-net-2.0.jar')
compile files('libs/google-play-services.jar')
compile files('libs/mail.jar')
compile files('libs/twitter4j-core-android-2.2.5.jar')
}
apply plugin: 'com.google.gms.google-services'
Another gradle file is...
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
External Libraries...
Android API 13 Platform
1.8
firebase-analytics-9.0.0
firebase-analytics-impl-9.0.0
firebase-common-9.0.0
firebase-core-9.0.0
firebase-iid-9.0.0
multidex-1.0.1
multidex-instrumentation-1.0.1
play-services-base-9.0.0
play-services-basement-9.0.0
play-services-tasks-9.0.0
support-v4-23.0.0
Remove all references to Google Play Services (JAR files and other Gradle lines)
Add this one for Admob
dependencies {
...
compile 'com.google.android.gms:play-services-ads:10.0.1'
}
Add more dependencies for other Google or Firebase services.
I'd prefer to do it this way to keep all versions the same.
ext {
// Variables to keep libraries consistent
googlePlayServicesVersion = '10.0.1'
}
dependencies {
...
compile "com.google.android.gms:play-services-ads:${googlePlayServicesVersion}"
}

Error: Cause: Peer not authenticated -- Gradle build of android project

I researched similar questions but none of the answers solved my problem. When I try to build the starter code for a coding assignment I get the following error:
Error: Cause: Peer not authenticated
My gradle files are the following:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
classpath 'com.google.gms:google-services:1.4.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.sam_chordas.stockhawk"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
compile 'net.simonvt.schematic:schematic:0.6.3'
compile 'com.melnykov:floatingactionbutton:1.2.0'
compile 'com.android.support:design:23.1.1'
compile('com.github.afollestad.material-dialogs:core:0.8.5.7#aar') {
transitive = true
}
}
I didn't manage any of those files as I don't have gradle experience yet.
Could you help me to figure out what went wrong?
Thank you very much.
P.S.:
The log files give me this error:
2016-03-23 13:01:29,664 [3912009] INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/home/madelenko/Desktop/Stock-Hawk master'
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.4-all.zip'.
Followed by a gigantic traceback.

Execution failed for task ':app:transformClassesWithDexForDebug'

I am trying to execute the code but i'm getting error message in messages gradle build that
Execution failed for task ':app:transformClassesWithDexForDebug'.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 2
build.gradle(app module) of my project is.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.paulusworld.drawernavigationtabs"
minSdkVersion 15
targetSdkVersion 23
/* multiDexEnabled true*/
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-support-v23.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
build gradle(project navigationtab)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Having the 'multiDexEnabled' set to 'true' would be a quickfix that could work, but it would also hide the real problem. Consider reviewing your application setup, like the libraries you're including in your project, they might be adding more than you need...
Have a look on what you have on your libs directory, as your gradle is adding all the jars there. And what's this in comparison to the v4 & v7 compile entries?
compile files('libs/android-support-v23.jar')
Also, if you add the appcompat-v7 you don't need to add the support-v4 for instance.
Read this section Avoiding the 65K Limit for further details.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
These has to be in project level gradle file if I am not wrong
Uncomment multiDexEnabled true and you are good to go!!

Gradle failed to refresh Android Studio

Ive been installing and re-installing AndroidStudio since i keep getting the error
> Gradle 'android' project refresh failed:
> Open quote is expected for attribute "{1}" associated with an element type "language".
All of my group members can open up the project without receiving this error except me.I am in dire need of help,i just want to finish my group project for the semester.Thank you for your help.
settings.gradle
include ':app'
build.gradle in the app folder
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:4.3.23'
compile 'com.android.support:support-v4:18.0.0'
files('libs/json-simple-1.1.1.jar')
compile files('libs/json-simple-1.1.1.jar')
}
build.gradle in the gradle folder
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Update:did another re-intstall of Android Studio and now its giving me this error.
Failed to refresh Gradle project 'android'
Out of memory: Java heap space. Configure Gradle memory settings using '-Xmx' JVM option (e.g. '-Xmx2048m'.)
Please fix the project's Gradle settings.
Gradle settings
You might have typed closed quote (“) instead of open quote("). Change the quotes at start and end of attribute.

Categories

Resources