Execution failed for task ':app:transformClassesWithDexForDebug' - android

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!!

Related

Failed to apply plugin [class 'org.gradle.language.base.plugins.LifecycleBasePlugin']

I just open an old project on android studio, when I trying to run the app on emulator I see this error
Build file 'D:\Courses\Java\Android Projects\CustomListViewExample\app\build.gradle' line: 1
A problem occurred evaluating project ':app'.
> Failed to apply plugin [class 'org.gradle.language.base.plugins.LifecycleBasePlugin']
> Cannot add task 'clean' as a task with that name already exists.
I tried to delete the first line, but it's appear the new error
A problem occurred evaluating project ':app'.
> Could not find method android() for arguments [build_epi4gcthpuruce7js1p17xxvs$_run_closure1#5c2243f6] on project ':app' of type org.gradle.api.Project.
here's the full build.gradle(app) file
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.nh.customlistviewexample"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
}
The build.gradle moudles file
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
}

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

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.

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.

Android Studio 0.8.6 Gradle project sync failed

I just installed the last Android Studio 0.8.6(beta) on my MacOSx Snow leopard. After creating a basic project, I have an error message
Gradle project sync failed ....
I added the mavenCentral() to repositories, in my build.gradle file. But it does not fix it:
this is my build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
The build.gradle in my android project looks like:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
applicationId "app.helloworld"
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Using the command line :
./gradlew assembleDebug --stacktrace
I otain this error message:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'HelloWorld'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:0.12.2.
Required by:
:HelloWorld:unspecified
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
Thanks for your answer.

Categories

Resources