Facing this error while building the Android application
* What went wrong:
Execution failed for task ':app:mergeExtDexCiDebug'.
> Could not resolve all files for configuration ':app:ciDebugRuntimeClasspath'.
> Failed to transform mypkg:mylib-1.0.0.aar (mypkg:mylib:1.0.0) to match attributes {
artifactType=android-dex,
asm-transformed-variant=NONE,
dexing-enable-desugaring=true,
dexing-is-debuggable=true,
dexing-min-sdk=21,
org.gradle.category=library,
org.gradle.dependency.bundling=external,
org.gradle.libraryelements=aar,
org.gradle.status=integration,
org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /Users/xxx/.gradle/caches/transforms-3/49baf52f7ba8b21fe69d66f95b8d5255/transformed/jetified-mylib-1.0.0-runtime.jar.
> Error while dexing.
Using Gradle 7.5.1 and AGP version is 7.3.0-beta05 (tried earlier ones too). Android Studio version Android Studio Chipmunk | 2021.2.1 Patch 2.
As far as possible, I have verified I am using
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
Still, it is complaining about Java 8 incompatibility. Any idea how I can find if any of the dependencies is using Java 8 and if that's even a problem?
Looking into the logs (before this error is shown), I found another error message like
Compilation of classes ... requires its nest mates ... (unavailable) to be on program or class path.
Then it occurred that one of the SDKs I used cannot be upgraded to Java 11 and has to be Java 8. (I was trying to upgrade my current SDK as well as the dependent SDK to Java 11 and Gradle7). So downgrading just the Java version (11 back to 8) helped. Gradle/AGP version had no impact.
On a related note, this specific error message may be fixed in the upcoming Gradle release according to https://developer.android.com/studio/releases/fixed-bugs/studio/2021.3.1#android-studio-dolphin-canary-1-2021.3.1.1.
Related
When building my project in Android Studio, I get the following error.
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16.
I have tried changing the Kotlin version in my project-level gradle file to almost every single stable release available without much success. The one or two stable releases of Kotlin that do make this error go away generate their own errors.
The current Gradle version 5.6.4 is not compatible with the Kotlin Gradle plugin. Please use Gradle 6.1.1 or newer, or the previous version of the Kotlin plugin.
jav.lang.noClassDefFoundError
Build file 'C:\Users\pictu\Downloads\ble-starter-android-master\ble-starter-android-master\app\build.gradle' line: 18
A problem occurred evaluating project ':app'.
> org/gradle/api/services/BuildService
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:227)
at
...
org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 130 more
Caused by: java.lang.ClassNotFoundException: org.gradle.api.services.BuildService
... 160 more
I've tried using multiDex, I've tried changing the Kotlin version, I've tried changing the compileSdkVersion + minSdkVersion + targetSdkVersion, but none of them worked. I've also looked at several SO posts, but I haven't found any that help my specific issue.
UPDATE 1: The error message points out this line specifically.
apply plugin: 'kotlin-android'
UPDATE 2: The answer to this SO post helped me get a little further. Now I am getting this cryptic stack trace that mentions something about a circular reference. I haven't been able to find out what a circular reference is in this context.
Invoke-customs are only supported starting with Android O (--min-api 26)
Stack trace:
com.android.tools.r8.a: Invoke-customs are only supported starting with Android O (--min-api 26)
at com.android.tools.r8.dex.r.a(:289)
at com.android.tools.r8.dex.r.a(:98)
at com.android.tools.r8.dex.r.b(:188)
at com.android.tools.r8.dex.b.a(:63)
at
...
Caused by: [CIRCULAR REFERENCE: com.android.tools.r8.a: Invoke-customs are only supported starting with Android O (--min-api 26)]
These are the two Stack Overflow posts that led me to my answer (1, 2).
You need to update your Gradle settings. I updated mine to Gradle version 6.1.1 using the chart in the answer to the first SO post I referenced.
The second thing you need to do is specify sourceCompatibility and targetCompatibility as JavaVersion.VERSION_1_8 in the compileOptions section of the app level Gradle file.
I am able to build and run my application through Android Studio. However running any gradle commands in the command-line (even with a ./gradlew clean) fails with the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> java.lang.NullPointerException (no error message)
Removing the following line from build.gradle allows me to build in command-line but not in Android Studio.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Even I had faced the same problem once before and "Invalidate cache and Restart" worked for me... You will find this option under File->Invalidate cache and Restart... Hope this fix works for you too :-)
Edit: Also, in your project's build.gradle file, check if
classpath 'com.android.tools.build:gradle:*.*.*
is greater than 2.4.1
I wanted to use intellij-markdown in one android kotlin project - but it does not survive the java roundtrip. Now I am searching for the least painful way to deal with this problem and hence ask here - perhaps someone faced the same problem. All solutions I have in mind currently are not really nice as they all diverge from upstream.
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
Error:1 error; aborting
Error:Execution failed for task ':android:transformClassesWithDexForProdWithFirebaseDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/home/ligi/.gradle/caches/modules-2/files-2.1/org.jetbrains/markdown/0.1.23/f02dce4ef95be9f24a6ea59de2c187f597befb70/markdown-0.1.23.jar' to '/home/ligi/git/SurvivalManual/android/build/intermediates/transforms/dex/prodWithFirebase/debug/folders/1000/10/markdown-0.1.23_4afcc7019db1f3375984c600cc493df386228117'
I was just trying to compile my app with the new preview SDK 24 Android N in Android Studio 2.1 Preview 1.
I have in app billing in my app.
When trying to build the app I get the following exception
aidl.exe E 6416 3312 io_delegate.cpp:102] Error while creating directories: Invalid argument
Error:Execution failed for task ':app:compileDebugAidl'.
> java.lang.RuntimeException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Gebruiker\AppData\Local\Android\Sdk\build-tools\24.0.0-preview\aidl.exe'' finished with non-zero exit value 1
I already tried to use the latest IInAppBillingService.aidl but I still get the same error. When I remove the IInAppBillingService.aidl file the project compiles fine.
Here's a part of my build gradle
compileSdkVersion 'android-N'
buildToolsVersion "24.0.0 rc1"
defaultConfig {
applicationId "xxx.myapp"
minSdkVersion 14
targetSdkVersion 'N'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
The IInAppBillingService.aidl file is in the following folder
src/main/aidl/com/android/vending/billing
How to fix this?
I think you have to change below points
minSdkVersion 'N' and compileSdkVersion 'android-N'
update your JAVA JDK to 1.8
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
I had updated to the latest Android Studio 2.0 Beta 6 and had also updated the Settings to support Instant Run due to warning about gradle version not correct. This changed all my buildToolsVersion settings to 24 RC 1. That started causing the aidl error described in this bug report. I had to go back to buildToolsVersion 23.0.2 to be able to compile and run.
Got exactly the same problem with our InApp stuff and IInAppBillingService.aidl and after spending some time on it, and looking through the unsolved google issue tracker thread, found (at least temporarily) solution that allows me to compile the project with the latest stuff under Android N.
It surely is not quite legit, and after Google fixes whatever they need to, it shall be reverted, but in short - it is to replace the aidl.exe from the current beta Build Tools 24.0.0 rc2 with the aidl.exe from the currently stable one 23.1 - voila the "Invalid argument" error is gone :)
Firstly,the most important step is that you need to get more detail information about the error.
You can use one of the the following Gradle commands to get more details.
gradlew assembleDebug
gradlew assembleDebug --info
gradlew assembleDebug --debug
gradlew assembleDebug --scan
gradlew assembleDebug --stacktrace
I have met the similar situation with the environment:
macOS 10.14.2
Android Studio 3.3
The more detail information is:
ifeegoo:AIDLClient ifeegoo$ ./gradlew assembleDebug
Welcome to Gradle 4.10.1!
Here are the highlights of this release:
- Incremental Java compilation by default
- Periodic Gradle caches cleanup
- Gradle Kotlin DSL 1.0-RC6
- Nested included builds
- SNAPSHOT plugin versions in the `plugins {}` block
For more details see https://docs.gradle.org/4.10.1/release-notes.html
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
> Configure project :app
WARNING: The specified Android SDK Build Tools version (28.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.0.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '28.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
> Task :app:compileDebugAidl FAILED
/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/main/aidl/com/xb/test/IRomteAidlInterface.aidl:6: couldn't find import for class com.xb.test.IClientAidlInterface
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugAidl'.
> java.io.IOException: com.android.ide.common.process.ProcessException: Error while executing process /Users/ifeegoo/Library/Android/sdk/build-tools/28.0.3/aidl with arguments {-p/Users/ifeegoo/Library/Android/sdk/platforms/android-27/framework.aidl -o/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out -I/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/main/aidl -I/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/debug/aidl -I/Users/ifeegoo/.gradle/caches/transforms-1/files-1.1/support-compat-27.1.1.aar/5625261fa2f53d5e15ed7248754bde52/aidl -d/var/folders/vl/nvypcrfj25n20fhnmtl0t5p40000gn/T/aidl37267774351421868.d /Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/main/aidl/com/xb/test/IRomteAidlInterface.aidl}
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
2 actionable tasks: 1 executed, 1 up-to-date
So the most important detail information is after FAILED
/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/main/aidl/com/xb/test/IRomteAidlInterface.aidl:6: couldn't find import for class com.xb.test.IClientAidlInterface
Finally,I found that there is somethings wrong with my AIDL file location.
I already know that question has been already asked very often and answers, but no one of the answers i found fixed my problem.
It's the error:
Error:Gradle: Execution failed for task ':ffcommunity:preDexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\Android SDK\sdk\build-tools\20.0.0\dx.bat --dex --output D:\Users\ReVo\Documents\IntelliJ IDEA\FFCommunity\ffcommunity\build\intermediates\pre-dexed\debug\bananaquery-2ee85432877a057e7414910b8127805535139d5d.jar D:\Users\ReVo\Documents\IntelliJ IDEA\FFCommunity\ffcommunity\libs\bananaquery.jar
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:665)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
...while parsing com/comuf/revonline/bananaquery/BananaInsert.class
1 error; aborting
The error is bad class file magic (cafebabe) or version (0034.0000).
I builded and execute the application without problems many times in the same day but now this fails everytime with this message.
Project SDK is Android API 19 Platform and project level is 1.7.
CompileSDK is 19 and buildToolsVersion is '20.0.0'.
Compile options:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
and in dependencies i have:
compile files('libs/bananaquery.jar')
The library is build with SDK Android API 19 Platform with project level 1.7.
My .jar file is inside libs/ folder.
I use IntelliJ IDEA 14 Preview, it could be the reason? With IntellIJ IDEA 13 it remains stuck at "Gradle sync"
compile files could be useless since i have compile fileTree(dir: 'libs', include: ['*.jar']) too
my JAVA_HOME variable changed to Java 1.8 and I got this error message when compiling a pure java module as a dependency of my android project.
build.gradle of the java module
apply plugin: 'java'
Solution #1: Quick an dirty
I fixed it by setting my JAVA_HOME back to 1.7:
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
Solution #2: change compiler version:
change back to 1.7 for this specific module in its build.gradle
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7
Ok, my bad.
In the Project SDK section, when you add an Android SDK you should provide the Java SDK and all my Android SDKs uses Java 8 as SDK so it create the class files with the wrong version even if the Project level is 1.7 (i don't know why, i supposed that everything was choosed by Project level).
Now i changed the SDK (the java version "1.x.0" part.)
and it seems to compile fine.
The reason that worked before today was because my SDK was 1.8 and not Android API x
In case people find #Marco Acierno's answer to be a bit unclear, the solution is to ensure you're building with Java 7 and not a higher version.
For Android Studio, change File -> Project Structure -> SDK Location -> JDK Location to jdk1.7.x. For the command line, ensure java -version outputs java version "1.7.x".
Setting JAVA_HOME back to 1.7 worked for me.
change all your module java version to java 1.7 in every build.grade file.
in plugin which is library and application
compileOptions{
sourceCompatibility=JavaVersion.VERSION_1_7
targetCompatibility=JavaVersion.VERSION_1_7
}
and in java
sourceCompatibility= 1.7
targetCompatibility= 1.7
This problem occurs when you use a .jar file that is not using any feature of Java 6 or higher but was built using Java 6 or higher.
If you built that .jar file then you don't need to change anything in Gradle or ProGuardor Compiler Version. The solution is very simple, just build that .jar file again but using Java 5 or less.
More details.
I had a similar issue, i solved it by upgrading my proguard.
get your proguard version by this command
java -jar ~/android-sdks/tools/proguard/lib/proguard.jar
get the latest progaurd.jar file from here (http://proguard.sourceforge.net)
replace the existing android-sdks/tools/proguard/lib/proguard.jar with new .jar file.
Hopefully this should help you.
If u using java 8 then you should upgrade to proguard 5.x coz proguard 4.x does not support java 8.
had a similar issue when i tried to add a self made library from netbeans to android studio. setting the source- and target compatibility in android studio and source/binary format in netbeans (both!) to java 1.7 solved the problem.
in android studio:
Project Structure -> Modules/App -> Propreties -> Source- and Target to 1.7
in netbeans:
File -> Project Properties -> Sources -> Source/Binary Format to 1.7
then clean and build your netbeans projekt and copy the .jar from "NBProj/dist" to "app/libs"
share the solution of the case if only Java8 installed, just set Java compiler level to 1.7 and then rebuild the project should be OK.
I got the error when using a third party library. In accordance with the above-mentioned question, it was necessary to replace the library according to the above stack trace message:
...
...while parsing com/comuf/revonline/bananaquery/BananaInsert.class
...
with the appropriate version.
Corresponding to the question, bananaquery.jar is to be replaced by the Java-compatible version.