Error:Execution failed for task ':app:transformClassesWithDexForRelease'. - java

I'm trying to build my release apk and Android Stdio gives me error.
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list C:\Users\azats\Desktop\App\app\build\intermediates\multi-dex\release\maindexlist.txt --output C:\Users\azats\Desktop\App\app\build\intermediates\transforms\dex\release\folders\1000\1f\main C:\Users\azats\Desktop\App\app\build\intermediates\transforms\jarMerging\release\jars\1\1f\combined.jar}
I cleaned and built the project multiple times, but it didn't work. What's the problem?

Try adding:
defaultConfig {multiDexEnabled true.....}
and to avoid dex error in certain kitkat devices
compile 'com.android.support:multidex:1.0.2'
to your app/build.gradle
you might want to take a look at:
Configure Apps with Over 64K Methods

Related

Android studio generate APK get error Execution failed for task ':app:transformClassesWithDexBuilderForDebug'

I get this error:
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/mohammad/.gradle/caches/transforms-2/files-2.1/2a8ecf8990ef0fa0c976a742db5c3bdc/jars/classes.jar
What did I do?
1- remove caches folder.
2- upgrade gradle
3- restart android studio
4- add android.enableD8=true
5- add -dontwarn and -keep
6- remove com.google.android.gms:play-services
How can I fix this problem?!

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. (Android.banker.A2af7 trojen detected)

Android studio showing this error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.io.FileNotFoundException:
C:\Users\hp\Desktop\M\app\build\intermediates\pre-dexed\debug\classes_b11ac8137589884ed512c93c59b969dc5dc99df3.jar (The system cannot find the file specified)
Every time i run the app, quick heal shows Android.banker.A2af7(PUP) tojen is detected and it quarantines the file.
Here is the screenshot:
I have no idea what is happening.
Can anyone help?
I was also a QuickHeal User Some Files Created By Android Studio Are Considered As Virus By quickheal an easy fix can be to ignore the directory of your project in quikheal scans..
Hope This Helps..

Errors after updating to Android 3.0 and SDK 27

After Android Studio was released to 3.0 I was forced to update my SDK from 25 to 27 (couple libraries problems).
But now when try to build my app I get next error messages:
>Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
C:\Users\Alice\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.0.aar\63ec32742d97434c1d2e0dbe96345ab9\res\values\values.xml
Error:(252, 5) error: resource android:attr/foregroundInsidePadding is private.
C:\Users\Alice\AndroidStudioProjects\Ghiduldrumetului cu Loco\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:(941) resource android:attr/foregroundInsidePadding is private.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 16s
Information:7 errors
Information:0 warnings
Information:See complete output in console
Any suggestion how to fix it?
I fixed adding android.enableAapt2=false to gradle.properties file.
Try disabling the AAPT2 by adding android.enableAapt2=false to your gradle.properties file.
Builds may fail while AAPT2 is enabled. Additionally, AAPT2 is currently not compatible with Robelectric. If your build fails due to an AAPT2 resource processing issue or you want to use Roboelectric, you can disable AAPT2 by setting android.enableAapt2=false in your gradle.properties file and restarting the Gradle daemon by running ./gradlew --stop from the command line.
Reference :
https://developer.android.com/studio/build/gradle-plugin-3-0-0.html
Check if you're using "android:attr/foregroundInsidePadding" anywhere in your resources. It should be "attr/foregroundInsidePadding" instead.
More info: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#aapt2

MySQL connector with Android Studio

I've been trying to use MySQL connector with Android Studio but I can't get it to work.
Error:PARSE ERROR:
Error:unsupported class file version 52.0
Error:...while parsing com/mysql/jdbc/JDBC42CallableStatement.class
Error:1 error; aborting
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: 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_91\bin\java.exe'' finished with non-zero exit value 1
There are already few questions with the same problem but their solution isn't working for me.
Try using SQLite on Android instead of MySQL. Try this tutorial.
Otherwise use an ORM(Object Relational Mapping), it will greatly reduce you to write SQL queries and is much efficient and cleaner to use.

Gradle error: Error:Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes

To start off, this is the whole message:
Error:Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes
Error:1 error; aborting
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException:
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_51\bin\java.exe'' finished with
non-zero exit value 1
This is what I have tried:
Restarting AS.
Restaring my computer.
Tried invaldiate caches and restart.
Rebuilt the project serveral times.
Earlier today I installed that latest java update, but it did not affect anything. After a couple of hours of coding, I added a jar file to my libs folder and wrote a class that used some of the classes from that library.
Now I can't seem to build the application at all anymore, even if comment out the class that uses the dependency.
Using Android Studio 2.0, Java 1.8.0_91-b14 and the library mysql-connector-java-5.1.38-bin
Edit:
I just tried removing the jar file, and now it builds just fine. So that's the thing causing the problem. Now how to solve it...
I think you need to add the following line in your app's build.grade file
defaultConfig {
...
multiDexEnabled true
}

Categories