Gradle build failing with TransformException - java

My gradle.build file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.alexandernohe.mapsappgoogle"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
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.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4.3'
compile 'com.firebase:firebase-client-android:2.5.1+'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:design:23.2.1'
}
I have enabled multidexing and have tried deleting the app/build folder but my application still will not build. If I remove the design library it will build but then I am unable to use a floating action button in my fragment, nor a coordinated layout. Most of the current solutions on here reference posts to enable multidexing, however, looking at the build file, you should see that it is enabled. I have a feeling that a library listed may overlap with the design library but as far as I can tell based upon googles documentation, they are different.
Here is the error code:
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 '/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java'' finished with non-zero exit value 3
EDIT:
I forgot to mention, I have also performed a clean on the project as well.

Try this inside the android block of your build.gradle:
dexOptions {
javaMaxHeapSize "4g"
}

Related

Android appcompat-v7 libraries not recognized

I moved my project to a new computer, with freshly installed Java and Android Studio, and it started acting weirdly. First, I was required to change "compile" with "implementation" in my gradle file. I did that, and then I was required to change my target sdk version, I did that too, and I also changed the version of the appcompat libraries, but in my classes the imports of appcompat are not recognized and also the methods, and the project does not build.
I cleaned, rebuilt, removed the .idea folder, did basically everything I could think of.
My gradle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.betako.pretprodazba"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:animated-vector-drawable:26.0.1'
implementation 'com.android.support:mediarouter-v7:26.0.1'
implementation 'com.android.support:design:26.0.1'
implementation 'com.google.android.gms:play-services:8.1.0'
implementation files('libs/commons-net-1.4.1.jar')
}

Error during Building an APK file in Android Studio

I was trying to build an apk for my project but i am facing this error and
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException: com.android.dex.DexException:
Multiple dex files define Lcom/google/android/gms/internal/zzajl;
i also added multiDexEnabled true but still getting 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/zzaix.class
Below is my Build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "in.package.name"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-ads:11.0.1'
testCompile 'junit:junit:4.12'
// Adding support library for this demo app
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-database:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
Please suggest me some solution
Thanks
Use SAME version
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
Then Clean-Rebuild and Restart IDE .
Try cleaning the project first - ./gradlew clean

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. try to sending emails

I'm trying to send an e-mail like in this post:
Sending Email in Android using JavaMail API without using the default/built-in app
And adding in my build.gradle and app file this lines: https://javaee.github.io/javamail/Android
Error:
Error:Execution failed for task
':app:transformClassesWithDexForDebug'. >
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException: com.android.dex.DexException:
Multiple dex files define
Lcom/sun/activation/registries/LineTokenizer;
But with the following app file I have a execution failed and don't know why.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.github.ocaparrostortosa.MyApplication"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
}
}
dependencies {
compile 'com.sun.mail:android-mail:1.5.5'
compile 'com.sun.mail:android-activation:1.5.5'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.android.gms:play-services-auth:10.2.1'
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:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And this one is my Project gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Can someone help me please? I'm close to finish the project :D
P.D: Sorry for my English and for the presentation, I'm new in stackoverflow.
this error is quite tricky. i also had a hard time on this. I solve my problem somehow by adding this multiDexEnabled true on my gradle build.config
android {
defaultConfig {
minSdkVersion 14 x
targetSdkVersion 23
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
Take note, this solution is case to case basis.
One scenario is - my app was very large that it exceeds 64MB limit. If this does not work, check your dependencies.
Other scenario was caused by Google Maps API dependencies that the version needs to be inline with the APP target SDK.

MongoDB Java Driver version 3.x.x error on Android

I have problem with compile 'org.mongodb:mongo-java-driver:3.x.x' on Android Studion. I am getting this error:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 2
The error do not appear with 'org.mongodb:mongo-java-driver:2.x.x' So i suppose that it is rather a jdk problem or a problem from mongo driver version 3.x.x.
Here is my gradle file too.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
repositories {
mavenCentral()
jcenter()
}
defaultConfig {
applicationId "com.example.irakl_000.maps"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
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.1.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:design:23.1.0'
//compile 'com.android.support:percent:23.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.isseiaoki:simplecropview:1.0.13'
compile 'org.mongodb:mongo-java-driver:2.9.2' //.....//
}
EDIT:
On a new project the version 3.x.x has no errors on gradle. So jdk should not be a problem. So could it be some kind of limit on size of compile file error like the 65K Limit error?

android: Execution failed for task ':app:dexDebug' zxing barcode scanner

i am trying to use dm77/barcodescanner zxing from github and i've been trying to use this library but i always get
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_60\bin\java.exe'' finished with non-zero exit value 2
i've searched to other app:dex:Debug questions and problems and they said that i may have multiple dependencies. i tried to check it but i can't detect what or where these "multiple dependencies" are.
here's my code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.quest.questsuser"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.akexorcist:RoundCornerProgressBar:2.0.3'
compile 'com.github.ksoichiro:Android-ObservableScrollView:v1.6.0'
compile 'com.melnykov:floatingactionbutton:1.0.7'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.12.0'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
}
repositories {
maven {
url "https://jitpack.io"
}
}
your help with be greatly appreciated.
I've already found the solution from https://www.youtube.com/watch?v=7uzWEjTVLQ4.
1. I added multiDexEnabled true in the default config build.gradle, added compile 'com.android.support:multidex:1.0.0' in the dependencies and in my Application Class i added a MultiDex.install(this); in the onCreate method

Categories

Resources