Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run java: com.adobe.air.ADTException: gradle tool failed #3629

Closed
Gis234 opened this issue Dec 31, 2024 · 23 comments
Closed

Unable to run java: com.adobe.air.ADTException: gradle tool failed #3629

Gis234 opened this issue Dec 31, 2024 · 23 comments
Labels

Comments

@Gis234
Copy link

Gis234 commented Dec 31, 2024

Problem:

AIR SDK: 51.1.3.1
Environment: Android

Hello,
For a few days I have been trying to compile my application but I have encountered an error message that I cannot resolve.
I uninstalled, reinstalled and updated Java and Android Studio with no results.

I have the impression that it is a problem with "Gradle" but Gradle JDK is pointed at "C:\Program Files\Android\Android Studio\jbr"

This is an error that happens when I compile an "aab" to a device and it started when I updated to the Adobe air Sdk 50 version.
I removed the only ANE I have (Admob), without success.
In Anroid studio I configure for Andoid 15.0(VanillalceCream) and gradle-8.9 version

The generated log:
*** ADT Logging at 2024/12/31 06:17:48 ***
Called by: C:\Program Files\Adobe\Adobe SDK\AIR 51.1.3.1\lib\adt.jar
ADT 51.1.3.1 called with: -package -target apk-captive-runtime -arch armv8 -storetype PKCS12 -keystore C:/certificats_Android/Igisorofree.p12 -storepass xxxxxx MyGame.apk C:/d dur1/sites/MyGame/Fini/MyGame2_debuging/Myame-app.xml -C C:/d dur1/sites/MyGame/Fini/MyGame2_debuging/ MyGame2free.swf icons/icon_192_3.png icons/icon_144_3.png icons/icon_96_3.png icons/icon_72_3.png icons/icon_36_3.png icons/icon_48_3.png -C C:/d dur1/sites/MyGame/Fini/igisoro2_debuging/ ANEAdMobmaster/com/AdMobIgisoro.as -C C:/d dur1/sites/Myame/Fini/MyGame2_debuging/ array/igisoro/array.as -C C:/d dur1/sites/MyGame/Fini/Myame2_debuging/ com/jeu/commun/billesDansTrou/src -C C:/d dur1/sites/MyGame/Fini/MyGame2_debuging/ com/jeu/commun/Jeu.as -C C:/d dur1/sites/MyGame/Fini/MyGame2_debuging/ com/jeu/niveaux -C C:/d dur1/sites/MyGame/Fini/MyGame_debuging/ com/jeu/MyGame.as -C C:/d dur1/sites/MyGame/Fini/igisoro2_debuging/ com/rs -C C:/d dur1/sites/MyGame/Fini/MyGame2_debuging/ images -C C:/d dur1/sites/MyGame/Fini/MyGame2_debuging/ inclusions -C C:/d dur1/sites/MyGame/Fini/MyGame2_debuging/ mp3 -extdir C:/Users/GODELI1/AppData/Local/Temp/MyGame2free_ANE_Cache/
Overriding request for apk-captive-runtime, instead generating Android App Bundle
Ignoring architecture request for AAB target
Creating device SDK handler - location passed in = C:\Users\Godelieve\AppData\Local\Android\Sdk
NOTE: Multiple Android build-tools folders exist, choosing the latest version (35.0.0) for packaging
Version in APK = 51.1.3.1, version of ADT = 51.1.3.1
Version in APK = 51.1.3.1, version of ADT = 51.1.3.1
Version in APK = 51.1.3.1, version of ADT = 51.1.3.1
Version in APK = 51.1.3.1, version of ADT = 51.1.3.1
NOTE: targets later than Android 33 need Gradle Plugin versions of 8 or more. Adjusting to 8.1.1
Gradle build where ADT is using JRE version 12.0.1
but where Gradle will be using the JDK from C:/Program Files/Android/Android Studio/jbr\bin\java.exe
Gradle build command: C:/Program Files/Android/Android Studio/jbr\bin\java.exe -Xmx1024m -Dorg.gradle.appname=gradlew -Dorg.gradle.jvmargs=-Xmx1024m -Duser.dir="C:\Users\GODELI1\AppData\Local\Temp\a66c0085-9b93-4847-bd47-bd54be495f5d" -cp "C:\Users\GODELI~1\AppData\Local\Temp\a66c0085-9b93-4847-bd47-bd54be495f5d\gradle\wrapper\gradle-wrapper.jar";"C:\Program Files\Adobe\Adobe SDK\AIR 51.1.3.1\lib\android\bin\gradle-cli.jar" org.gradle.wrapper.GradleWrapperMain :app:bundleRelease
..java.base/java.lang.Thread.getStackTrace(Thread.java:1602)
..com.adobe.air.DebugFile.printStack(DebugFile.java)
..com.adobe.air.ADTException.(ADTException.java)
..com.adobe.air.apk.AABOutputStream.buildGradle(AABOutputStream.java)
..com.adobe.air.apk.AABPackager.renameOutput(AABPackager.java)
..com.adobe.air.ApplicationPackager.createPackage(ApplicationPackager.java)
..com.adobe.air.apk.AABPackager.createPackage(AABPackager.java)
..com.adobe.air.ADT.parseArgsAndGo(ADT.java)
..com.adobe.air.ADT.run(ADT.java)
..com.adobe.air.ADT.main(ADT.java)
Stack trace:
Unexpected failure: Unable to run java: com.adobe.air.ADTException: gradle tool failed:
FAILURE: Build failed with an exception.

What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\Godelieve\AppData\Local\Temp\a66c0085-9b93-4847-bd47-bd54be495f5d\settings.gradle' (C:\Users\Godelieve.gradle\caches\8.0\scripts\5y6bqie0ral8doqg354vmfpkh).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 65

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 13s

My adt.cfg file:

See release notes: uncomment these lines in order to force your APK to be generated with 64-bit ARM binaries

(needed when using an IDE such as Adobe Animate that currently only provides armv7 and x86 as the options via the UI)

DefaultArch=armv8
OverrideArch=armv8

See release notes and #58

#UncompressedExtensions=emd,tfl,tflite,pb

Default is to prefiix the package with 'air.' - to turn this off, uncomment the below line

#AddAirToAppID=false

If you need to increase the heap available to Java when packaging an Android app, you can use the below setting

when ADT is run from another tool. (If run from the command line, just add -Xmx=2048m or similar to the command

line within the ADT launch script..)

#JavaXmx=2048m

For debugging, set this to 'true' and a file "adt.log" should be generated in your user's home folder

DebugOut=true

To override the creation of an Android APK file, and to instead create an Android App Bundle, the below

flag can be uncommented. Note that the bundle may end up with an "apk" file extension

CreateAndroidAppBundle=true

When creating an Android App Bundle, this flag can be used to output the Android Studio project

files in a subfolder of your build directory (rathe than using a temporary location that gets

cleaned up on exit).

#KeepAndroidStudioOutput=true

For convenience, rather than using "-platformsdk" on the command line, these can be set up here:

AndroidPlatformSDK=C:\Users\Godelieve\AppData\Local\Android\Sdk
#iOSPlatformSDK=path_to_sdk

JAVA_HOME is usually picked up from an environment variable but this can override it:

JAVA_HOME=C:\Program Files\Android\Android Studio\jbr

on macos platorms, use the native codesign task rather than trying to use ADT's internal code:

#UseNativeCodesign=true

NOTE TO WINDOWS USERS: paths should be either in the form "C:\Users\etc", with two backslash characters, or using

forwardslash characters instead such as "C:/Users/etc". If a single backslash is used, the config file is ignored.

Please help

@Gis234 Gis234 added the Bug label Dec 31, 2024
@apofis1969
Copy link

apofis1969 commented Jan 1, 2025

I have the same problem. Can not create any AAB Build. The JAVSA_HOME is set and the ANDROID SDK too at the config file.
adt -package -target aab -storetype pkcs12 -keystore certificat_android.p12 -storepass xxxxxxxx MyApp.aab MyApp-app.xml -extdir lib MyApp.swf google-services.json values.xml res AppIcons

NOTE: Multiple Android build-tools folders exist, choosing the latest version (34.0.0) for packaging NOTE: targets later than Android 33 need Gradle Plugin versions of 8 or more. Adjusting to 8.1.1 unexpected failure: Unable to run java: com.adobe.air.ADTException: gradle tool failed: org.gradle.api.internal.classpath.UnknownModuleException: Cannot locate JAR for module 'ant' in distribution directory '/Users/myUser/.gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0'. at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadExternalModule(DefaultModuleRegistry.java:145) at org.gradle.api.internal.classpath.DefaultModuleRegistry.getExternalModule(DefaultModuleRegistry.java:133) at org.gradle.api.internal.DefaultClassPathProvider.findClassPath(DefaultClassPathProvider.java:70) at org.gradle.api.internal.DefaultClassPathRegistry.getClassPath(DefaultClassPathRegistry.java:35) at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:48) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.gradle.launcher.GradleMain.main(GradleMain.java:34) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:35) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:108) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63) java.io.IOException: Unable to run java: com.adobe.air.ADTException: gradle tool failed: org.gradle.api.internal.classpath.UnknownModuleException: Cannot locate JAR for module 'ant' in distribution directory '/Users/johanneskarl/.gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0'. at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadExternalModule(DefaultModuleRegistry.java:145) at org.gradle.api.internal.classpath.DefaultModuleRegistry.getExternalModule(DefaultModuleRegistry.java:133) at org.gradle.api.internal.DefaultClassPathProvider.findClassPath(DefaultClassPathProvider.java:70) at org.gradle.api.internal.DefaultClassPathRegistry.getClassPath(DefaultClassPathRegistry.java:35) at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:48) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.gradle.launcher.GradleMain.main(GradleMain.java:34) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:35) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:108) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63) at com.adobe.air.apk.AABOutputStream.buildGradle(AABOutputStream.java) at com.adobe.air.apk.AABPackager.renameOutput(AABPackager.java) at com.adobe.air.ApplicationPackager.createPackage(ApplicationPackager.java) at com.adobe.air.apk.AABPackager.createPackage(AABPackager.java) at com.adobe.air.ADT.parseArgsAndGo(ADT.java) at com.adobe.air.ADT.run(ADT.java) at com.adobe.air.ADT.main(ADT.java)

@Policy56
Copy link

Policy56 commented Jan 2, 2025

Can you try to use JDK 17 instead of newer version ?

@apofis1969 , do you use ANE ?
And, you've problem with your ant version

Cannot locate JAR for module 'ant' in distribution directory '/Users/myUser/.gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0

@apofis1969
Copy link

apofis1969 commented Jan 2, 2025

@Policy56 I am using JDK 17, I have ANEs. All the latest versions.

@Policy56
Copy link

Policy56 commented Jan 2, 2025

@apofis1969 , can you try to downgrade your ANE version or distriqt to not use v3.0.0 . (issue distriqt/ANE-AndroidSupport#36)

@apofis1969
Copy link

@Policy56 I did the downgrade. Still the same bug. Frustrating.

@Policy56
Copy link

Policy56 commented Jan 3, 2025

Can you try to clean your gradle folder ?

On Windows:

gradlew cleanBuildCache

On Mac or UNIX:

./gradlew cleanBuildCache

@apofis1969
Copy link

@Policy56 the ./gradlew did not work. I deleted the cache of the hidden .gradle folder. Opened Android Studio again and then I had to install gradle again. Tomorrow I will test the build on my Android phone.

@ajwfrost
Copy link
Collaborator

ajwfrost commented Jan 6, 2025

Hi

There seem to be a couple of different issues within this thread...

  1. Original post: exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 65
  2. UnknownModuleException: Cannot locate JAR for module 'ant' in distribution directory '/Users/myUser/.gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0'.

@Gis234 for the first one - this has been seen before and in one case appeared to be caused by a JAR file that had some class file information from Java 21, even though the class files within the JAR were themselves all using a Java 11 or 17 version. If you are still seeing this, would you be able to confirm what ANEs you're using (and even better if it's possible to remove any of them in order to isolate one that may be at fault?). For example do you use anything from BouncyCastle?

@apofis1969 that issue is a new one to me but cleaning up .gradle is a good idea (it should just re-create it next time it's used). From the above comment I wonder whether the build is actually working now (i.e. you have a package to test so the building part presumably succeeded)?

FYI we have been trying to reproduce these, but then encountered a new/different issue! Regarding duplicate Kotlin classes.. which we eventually solved by editing the app's build.gradle file using the suggestion here: https://stackoverflow.com/a/75315276 i.e. adding to the end:

configurations.implementation {
    exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
}

(building via the ADT android-studio target and then within Android Studio).

The Gradle-based building does seem a little sensitive to the various combinations of Java, Gradle, Android Gradle Plugin, and the Android compile SDK and build-tools versions....

@apofis1969
Copy link

apofis1969 commented Jan 6, 2025

Hi @ajwfrost - it does not work with the new ANEs. I made a build with the ANEs which I used in June 2024. So the mistake is with the ANEs or with some of them.
Could you please tell me where I have to add this code configurations.implementation { exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' }
I am building via Terminal on my Mac

@apofis1969
Copy link

@ajwfrost - It is working now with the newest ANEs. I do not understand why suddenly. I will try it tomorrow again. This is very strange.

@ajwfrost
Copy link
Collaborator

ajwfrost commented Jan 6, 2025

@apofis1969 thanks - just to check: "it does not work" meaning, it doesn't build an APK/AAB file, but instead fails with the Cannot locate JAR for module 'ant' error?

Ah, just seen your update. "This is very strange" = fast becoming our team's catchphrase...

If you find the issue again, I would suggest building using the android-studio target in place of apk or aab for the command-line -target option. The output filename should instead be a folder name, and this is where the Android Studio project will be created. You can then open that folder using Android Studio and start to play around with the settings... that particular configurations.implementation thing we added under the "app" module's build.gradle file, right at the end of the file after the other blocks.

thanks

@Gis234
Copy link
Author

Gis234 commented Jan 6, 2025

Hi,
Thanks for the response.
No I don't use "BouncyCastle"
I use "admob ANE".
To debug I created an application without Admob ANE but the problem remained the same.
I deleted .Gradle and cache with no results.

@ajwfrost
Copy link
Collaborator

ajwfrost commented Jan 6, 2025

Hi @Gis234
Do you know what version of Java you have in Android Studio? i.e. can you run from a command-line:

"C:\Program Files\Android\Android Studio\jbr\bin\java.exe" -version

The log shows that it's updating to use 8.1.1 as the Android Gradle Plug-in version, and is probably using Gradle 8.0. This means that you must use Java versions 17 through 20: Gradle 8 is not supported on Java versions 16 or less, or on version 21 and later.

The compatibility is still somewhat unclear, unless anyone can find a better reference! The official compatibility matrix doesn't clarify which of these is a 'minimum' and whether there's a 'maximum', so the Java compatibility doesn't really help unless it's meant to mean that you choose which Gradle version to use based on the Java version that you have (which seems the wrong way round to do things ...!)
https://docs.gradle.org/current/userguide/compatibility.html
And this also seems to contradict another table that someone created, which seems to be a lot more useful:
https://www.devopsschool.com/blog/gradle-versions-their-supported-java-versions-and-unsupported-java-versions/

You can actually change the version of Gradle (and the Android Gradle Plug-in) that AIR/ADT will use, via the application descriptor within the <android> section, for example:

    <gradleVersion>8.4</gradleVersion>
    <androidGradlePluginVersion>8.5.0</androidGradlePluginVersion>

Hope that helps!
thanks

@Gis234
Copy link
Author

Gis234 commented Jan 6, 2025

Here is the java version in Android studio:

C:\Program Files\Android\Android Studio\jbr\bin>java.exe -version
openjdk version "21.0.3" 2024-04-16
OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
OpenJDK 64-Bit Server VM (build 21.0.3+-12282718-b509.11, mixed mode)

@Gis234
Copy link
Author

Gis234 commented Jan 6, 2025

Okay I'm going to try to change the Gradle version, but I wonder, wouldn't it be better to use java 17 or 20 than to change the Gradle version?

@apofis1969
Copy link

@ajwfrost - I wanted to say, that I could compile an aab build. I also created a new project in Android Studio. Deleted the cache in the .gradle folder on my Mac. Opened the new Android Project again and the missing gradle configurations had been downloaded. I am using Java 17.
The strange thing is, that I had to build the app with the older ANEs which I used in June 2024. After this the build with the recent ANEs worked too. Really strange…
Let’s see what will happen tomorrow… 🤪

@ajwfrost
Copy link
Collaborator

ajwfrost commented Jan 6, 2025

@Gis234

wouldn't it be better to use java 17 or 20 than to change the Gradle version?

Possibly .. although if your Java installation within Android Studio is set to 21, it implies Android Studio is expecting you to use a later Gradle version... which may mean we should be trying to detect this and update the Gradle versions appropriately. If you were to do this in Android Studio, I would expect a little pop-up to appear asking you to upgrade the Gradle/AGP versions...

@apofis1969 definitely strange ..! and possibly something hidden to do with caches and compatibilities perhaps. Fingers crossed for it working tomorrow still :-)

@Gis234
Copy link
Author

Gis234 commented Jan 6, 2025

Thank you Andrew for this information. I will keep you informed of developments

@Gis234
Copy link
Author

Gis234 commented Jan 6, 2025

Well, I pasted the 2 lines that you gave me to place in the application description file in the tag.

The new error message is this:

Stack trace:
Unexpected failure: Unable to run java: com.adobe.air.ADTException: gradle tool failed: 
FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\.......\AppData\Local\Temp\3f818136-33ce-4ec8-89aa-e49887b40a87\app\build.gradle' line: 1

* What went wrong:
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.version-check'.
   > Minimum supported Gradle version is 8.7. Current version is 8.4. If using the gradle wrapper, try editing the distributionUrl in C:\Users\......\AppData\Local\Temp\3f818136-33ce-4ec8-89aa-e49887b40a87\gradle\wrapper\gradle-wrapper.properties to gradle-8.7-all.zip

* 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 2m 49s

I'm going to change 8.4 to 8.7 in the lines.
I'll see what that gives.

  <gradleVersion>8.7</gradleVersion>
    <androidGradlePluginVersion>8.5.0</androidGradlePluginVersion>

@Gis234
Copy link
Author

Gis234 commented Jan 6, 2025

It's better for me. The apk file is generated.

I upgraded Gradle to 8.9 and removed the line:

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

in the game descriptor xml file, because I had an error telling me about it.

Now I'm going to see if I needed this line.

THANKS

@Gis234
Copy link
Author

Gis234 commented Jan 9, 2025

Finally, even by decommenting the line
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
it works.

I close

@Gis234 Gis234 closed this as completed Jan 9, 2025
@Gis234
Copy link
Author

Gis234 commented Jan 9, 2025

Thanks 😉

@marchbold
Copy link
Collaborator

@Gis234 If you have updated your extensions lately you need to reconstruct your app descriptor. There have been major changes to the manifest additions required for all our extensions and lines like the one you have referenced are no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants