Android : Error:Execution failed for task ':transformClassesWithJarMergingForDebug' - java

I don't know why it happen, but when I want to run a project, I get this message error :
Error:Execution failed for task ':transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry: android/support/v4/app/FragmentContainer.class
I tried to clean / rebuild project many times, but I got always same error when I run it.
build.gradle:
http://pastebin.com/nnE9bpN7
Do you have any solutions please? I'm really stuck at that.
Thanks

compileSdkVersion 'Google Inc.:Google APIs:23' is supposed to be compileSdkVersion 23. You're adding Google Play services via dependencies.
libs folder is not supposed to contain any support libraries such as support-v4. These are added again as a maven dependency:
compile "com.android.support:support-v4:23.1.1"
compile "com.android.support:appcompat-v7:23.1.1"
compile "com.android.support:design:23.1.1"

Related

program type already present: javax.inject.Named + transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

I'm using gradle version 4.4 and android plugin version 3.1.4 while building i am getting error as follows:
AGPBI: {"kind":"error","text":"Program type already present: javax.inject.Named","sources":[{}],"tool":"D8"}
:tractorapp:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':tractorapp:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
First of all, delete .gradle and .idea folders after closing this project in Android Studio and then re open the project and then follow this:
Enable multiDex in your app build.gradle file. This should help you solve this. Also share the build.gradle file here so that we can figure out what is causing the issue properly.
defaultConfig {
multiDexEnabled true
}

Upgrading firebase-crash caused error building apk

I originally added firebase crash reporting using Android firebase assistant in android studio. Which added firebase-crash:10.0.1. Now i am want access some methods added in later version so i upgraded it to to firebase-crash:11.2.0.
This is where the problem starts
I used this guide to make changes in my gradle.build (Module:app)
Changed compile 'com.google.firebase:firebase-crash:10.0.1' to compile 'com.google.firebase:firebase-crash:11.2.0'
At this point gradle sync failed. To resolve this i modified build.gradle (Project) with
allprojects {
repositories {
jcenter()
//Added this code
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
Gradle build sync completed succesfully. Now i tried building debug apk and i received this 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/google/android/gms/internal/zzbvb;
To fix this issue i modified buil.gradle(Modeule:app)
defaultConfig{
///...
multiDexEnabled true
///...
}
And now i am able to generate debug-build apk. But generating signed apk gives following error with 1588 warnings & 1 error.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
Job failed, see logs for details
This is where i am stuck. I am not able to resolve this issue. I tried several methods including clean/rebuild and invalidate cache & restart. Also tried adding -ignorewarning -dontwarn -keep class { public private} none of them seems to work.
Error in console on generating signed apk
build.gradle(Project)
build.gradle(Module:app)
Update
Adding this line compile 'com.google.android.gms:play-services:11.2.0 in build.gradle (Module:app) does build signed apk successfully. But shows following warnings.
I am confused
Using the Firebase version 11.2.0 (that has a dependency with Google play services v.11.2.0), you should use also the support libraries v26.
In your case:
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v13:26.0.1'
Also you have to use:
compileSdkVersion 26
More info here.

Can't build app when I import Xerces library (exit value 1)

I cannot seem to get my app to build when I import in the Xerces library. I am already using the multidex due to previous issues and therefore I know this is all setup properly.
I have spend a couple of days now looking online and trying all sorts of versions of Xerces and tweaks to my build.gradle but cannot work out the issue. I have tried cleaning re-building, re-setting Android Studio/my PC, using a jar directly compiling and now officially out of ideas.
Below is my build.gradle setup:
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "#packageid#"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "0.8"
multiDexEnabled true
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'me.dm7.barcodescanner:zbar:1.8.4'
compile project(':rangebar-1.3')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile 'com.batch.android:batch-sdk:1.5'
compile 'xerces:xercesImpl:2.11.0'
// compile files('libs/xercesImpl-2.9.1.jar')
}
I have also extended my Application already and therefore have used the following within the class:
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
However, every time I try to build I keep getting the following error:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> 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_79\bin\java.exe'' finished with non-zero exit value 1
Below is the end part of my gradle build error log:
Reading program jar [C:\Documents\MobileProjects\IA\Android\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]
Reading library jar [C:\AppData\Local\Android\sdk\build-tools\23.0.2\lib\shrinkedAndroid.jar]
Preparing output jar [C:\Documents\MobileProjects\IA\Android\app\build\intermediates\multi-dex\debug\componentClasses.jar]
Copying resources from program jar [C:\Documents\MobileProjects\IA\Android\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]
:app:transformClassesWithMultidexlistForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> 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_79\bin\java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
As you have tried cleaning re-building, re-setting Android Studio/my PC, using a jar directly for compiling, now I want to give you some suggestions. Hope it can help you.
Before giving suggestion, I want to tell you to go through this article first: Configuring Your App for Multidex with Gradle. Then you can follow the suggestions.
Suggestion-1:
For gradle bulid, it must be followed
dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
to pre-dex each module and produce an APK that can be tested on
Android Lollipop without time consuming dex merging processes.
You have used minSdkVersion as "minSdkVersion 18". So plase update it.
Suggestion-2:
Note: With Android Plugin for Gradle versions lower than 1.1, you need to add the following dependency for multidex-instrumentation:
dependencies {
androidTestCompile('com.android.support:multidex-instrumentation:1.0.1') {
exclude group: 'com.android.support', module: 'multidex'
}
}
Note: Use of multidex for creating a test APK is not currently supported.
Suggestion-3:
Your input jars contain multiple resource files with the same name. ProGuard continues copying the resource files as usual, skipping any files with previously used names. Once more, the warning may be an indication of some problem though, so it's advisable to remove the duplicates. A convenient way to do so is by specifying filters on the input jars. There is no option to switch off these warnings.
The standard Android build process automatically specifies the input
jars for you. There may not be an easy way to filter them to remove
these warnings. You could remove the duplicate resource files manually
from the input and the libraries.
ProGuard may terminate when it encounters parsing errors or I/O errors, or some more serious warnings:
Suggestion-4:
Problem RAM. I had similar message in my Messages Gradle Build
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_45\bin\java.exe'' finished with non-zero exit value 1
I didn't have free RAM on my laptop with the OS windows 8.1. I closed a few programs that I don't need. After that, I had more free RAM and my project was built in android studio.
Suggestion-5:
Some people suggested to close Android Studio and kill the java processs, which was very big (1.2 GB). Then you can run with gradle. It helps.
Suggestion-6:
Install the latest version of the build tools. Adjust your build.gradle to use
`buildToolsVersion "22.0.1"`
It helps some cases.
I see from your build.gradle that your project seems containing different modules (compile project(':rangebar-1.3')).
I had your same issue in a multi-module project of mine. The root cause was that the same library was explicitly included in more than one module.
Let's say that your project has the following strucuture:
Project
+-Module1 (includes Module2, Module3)
+-Module2 (includes Lib.jar)
+-Module3 (includes Lib.jar)
In this configuration I was getting your same error trying to compile Module1. The solution was to reconfigure modules to include Lib.jar in only one single place, like for example:
Project
+-Module1 (includes Module2, Module3)
+-Module2 (includes Module3)
+-Module3 (includes Lib.jar)

Importing JDBC into Android Studio errors

I am currently working on an Android app and I am attempting to retrieve information from a MySQL database. I am trying to use JDBC as instructed by my professors, but I keep running into problems.
I have installed the MySQL Connector/ODBC 5.3, set a CLASSPATH environment variable for the driver I am attempting to use, which is "mysql-connector-java-5.1.38-bin.jar", and I attempted to import that JAR into my project.
I have attempted to import the JAR in two ways, which are the following:
File > New Module > Import .JAR/.AAR Package > import the mysql connector JAR
Then I proceeded to go to File > Project Structure > app > Dependencies > add module dependency
The other way I have attempted to do this was by adding the JAR into the "libs" folder of my project and follow the Project structure path to add a dependency from file.
I am running the latest version of Android Studio 2.0
The build completes successfully when following either of the importing steps however when doing so I get the following error when attempting to run the app:
Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
> JSR/RET are not supported with computeFrames option
The only solution I found relevant to this was going to Android Studio Settings and turning the Instant Run option off.
After doing so I received the following error instead:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_77\bin\java.exe'' finished with non-zero exit value 1
The following is my build.gradle(Module:app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "com.example.JohnDoe.myapp" //This is not actually the name or the name of the app on there but I changed this for privacy.
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = 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.2.1'
compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.android.support:multidex:1.0.1'
compile project(':mysql-connector-java-5.1.38-bin')
}
The following is a link to the whole gradle console output after turning "Instant Run" off: pastebin.com/5kj6Cgeb
Please advise me where to go from here to get the JDBC driver working so I can finish this project. Thank you for your time.
UPDATE 1: Apparently the latest JDBC driver is not fully compatible with Android and causes issues. I installed and imported the previous version (5.0.8) and so far the app at least runs. Will be attempting to implement the driver now and actually develop with it, at which time I will post another update on the outcome.
You should not use JDBC in Android Apps as it is targetted to high bandwith, reliable connections to a database server, something you will not achieve on a mobile device. Try to wrap your database in a REST web service instead.
I've read several times that people struggled with using JDBC in Android, it's just not built for beeing used in the Android ecosystem. Not every library is fully compatible with Android, your gradle output suggests that the "dexer" could not convert the jar file to a .dex.
Your provided gradle output show the following error:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
See this question for a possible solution. Ensure you are building with the right Java SDK.

Error when trying to integrate parse into Android app error: Error:Execution failed for task ':app:transformClassesWithDexForDebug'

I am attempting to recreate a running app I made in iOS for Android to release together I am attempting to integrate parse into the Android app and receive the following error:
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_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
could someone assist as to what this could mean and how can I go about fixing it?
I downloaded the latest parse SDK and placed in the dependencies in the build.gradle.
First of all clean and rebuild your project and if the problem still persist, Try adding multiDexEnabled true to your app build.gradle file.
defaultConfig {
multiDexEnabled true
}

Categories

Resources