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

Error building Android generated project with Kotlin #130

Closed
basettoni89 opened this issue Aug 3, 2023 · 6 comments
Closed

Error building Android generated project with Kotlin #130

basettoni89 opened this issue Aug 3, 2023 · 6 comments

Comments

@basettoni89
Copy link

Hi,
I'm trying to generate a libGDX project with Kotlin and KTX.
I've tried both with template "Kotlin", and with "Kotlin + KTX", and both of this, build fine for desktop, but gave me the same error while trying on Android.

The log error is:

> Task :android:mergeExtDexDebug
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
com.android.tools.r8.kotlin.H

AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}

> Task :android:mergeExtDexDebug FAILED
AGPBI: {"kind":"error","text":"com.android.tools.r8.kotlin.H","sources":[{}],"tool":"D8"}

Execution failed for task ':android:mergeExtDexDebug'.
> Could not resolve all files for configuration ':android:debugRuntimeClasspath'.
   > Failed to transform ktx-assets-async-1.12.0-rc1.jar (io.github.libktx:ktx-assets-async:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-assets-async\1.12.0-rc1\1c739b8642739b46e154c141fd6acdfbd17a4751\ktx-assets-async-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-async-1.12.0-rc1.jar (io.github.libktx:ktx-async:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-async\1.12.0-rc1\ddd296e8bc7120485d4852357dc3d14d8cd6eb14\ktx-async-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-actors-1.12.0-rc1.jar (io.github.libktx:ktx-actors:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-actors\1.12.0-rc1\3a3d5bccb1f328853eebf72027de59c5a991cb94\ktx-actors-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-app-1.12.0-rc1.jar (io.github.libktx:ktx-app:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-app\1.12.0-rc1\cf32c53453e9830944715b52897d87e83583c691\ktx-app-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-assets-1.12.0-rc1.jar (io.github.libktx:ktx-assets:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-assets\1.12.0-rc1\c9bcfcf9f168bd27fd25abd8e651e89a384b795d\ktx-assets-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-collections-1.12.0-rc1.jar (io.github.libktx:ktx-collections:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-collections\1.12.0-rc1\bdcd683c872b2b814fa65dfd437b9913e98ae296\ktx-collections-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-graphics-1.12.0-rc1.jar (io.github.libktx:ktx-graphics:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-graphics\1.12.0-rc1\fd0cc0352c2bdbbd6ac1857501c3cc0a1a1b1c29\ktx-graphics-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-json-1.12.0-rc1.jar (io.github.libktx:ktx-json:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-json\1.12.0-rc1\48bcde12beeb22aa77d9a5e1a479edb169593fc4\ktx-json-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-log-1.12.0-rc1.jar (io.github.libktx:ktx-log:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-log\1.12.0-rc1\6a95310c2240b8148cb30e22109d64bd6aad71cb\ktx-log-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-math-1.12.0-rc1.jar (io.github.libktx:ktx-math:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-math\1.12.0-rc1\10973bfaaee08188466677829951c8306639bc1b\ktx-math-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-vis-style-1.12.0-rc1.jar (io.github.libktx:ktx-vis-style:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-vis-style\1.12.0-rc1\686a2d6a212ff3d26e5f73655ac2fe3ed3b591e5\ktx-vis-style-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-style-1.12.0-rc1.jar (io.github.libktx:ktx-style:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-style\1.12.0-rc1\581a5ed11aba724f611f27edf6bc9b7da2e52f31\ktx-style-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-tiled-1.12.0-rc1.jar (io.github.libktx:ktx-tiled:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-tiled\1.12.0-rc1\69e36152818d66f144a0e138c2795500b201aaa9\ktx-tiled-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-vis-1.12.0-rc1.jar (io.github.libktx:ktx-vis:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-vis\1.12.0-rc1\5eeff1a27025e2d7f732a203dbea5eb53bad0b\ktx-vis-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform ktx-scene2d-1.12.0-rc1.jar (io.github.libktx:ktx-scene2d:1.12.0-rc1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\io.github.libktx\ktx-scene2d\1.12.0-rc1\b41c69e65c27e7eef0fcba580e8b7a6bc711f07f\ktx-scene2d-1.12.0-rc1.jar.
         > Error while dexing.
   > Failed to transform kotlin-stdlib-1.9.0.jar (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingNoClasspathTransform: C:\Users\dmortara\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.9.0\8ee15ef0c67dc83d874f412d84378d7f0eb50b63\kotlin-stdlib-1.9.0.jar.
         > Error while dexing.

Here there is also the project as generated by the gdx-liftoff tool:
BoatTemplateKotlinKtx.zip

Here some information about my setup:

  • IDE: IntelliJ IDEA - Build #IC-232.8660.185, built on July 26, 2023
  • Android Plugin - bundled 2022.3.1 Beta 2.232.8660.185
  • Host OS: Windows 10
  • libGDX-liftoff version 1.12.0.0

Can someone help me figuring out if it is a bug of the tool or an error on my configuration?

Thank you,
Davide

@czyzby
Copy link
Contributor

czyzby commented Aug 3, 2023

Possibly related: https://issuetracker.google.com/issues/266599585

@tommyettinger
Copy link
Member

There's a few strange things here, and I'm not cut out to address any of them. First off, downloading your project triggers Windows Defender to think there's a virus, which is something I only encounter rarely, and I'm also on Windows 10.

5qLlugrFDP

Needless to say, actually downloading the file will be a challenge, so I'll use the sample projects instead, since I think you said those also had the same issue.

The only real clue I have is that the log you pasted in the ktx issue seemed to have all of the errors start with a circular reference to H, which is "one of those Android classes" that I do not claim to understand. I'll try to figure this out, but... eesh, I am not really an Android dev.

@basettoni89
Copy link
Author

basettoni89 commented Aug 4, 2023

I don't know why the project is suspected as virus, it's a project create by gdx-liftoff and then built with IDEA.

Can someone try to create a project (or the sample from gdx-ktx) and build it with AGP 7.4.x? Is the version mentioned in the issue posted above

@basettoni89
Copy link
Author

I finally make the kts-sample build correctly.

In the order I've changed:

  • AGP to 8.1.0
  • Gradle to 8.0
  • Java version to 17
  • Kotlin jvm to 17

I'm attaching the modified kts sample that is building now with Android Studio Giraffe (2022.3.1).
ktx-sample-project-main.zip

I hope this time Windows Defender will not trigger!

@tommyettinger
Copy link
Member

I've wanted to update Gradle to 8.x for a while now, but Android has always held the version back. Maybe now it works reliably, after about half a year of not working... I tried the modified sample, and IDEA (the current version, 2023.2 ) still doesn't seem to be compatible with AGP 8.1.

It does seem to be compatible with AGP 8.0.0, though! 🎉

I have it using Gradle 8.2.1 (8.3 should be out soon, but should also be compatible), and that seems to work fine with AGP 8.0.0 . I only had to change the JDK in project structure to 17, and it worked as soon as the versions were right. The downside to moving to AGP 8.0 is it means users who want to develop for Android need to update IDEA to 2023.2 or use a very recent Android Studio version. It looks like at least for Kotlin usage, it's necessary to use an up-to-date IDE.

I'll leave this open until I can confirm the most recent Liftoff release's samples build in the most recent IDEA (and AS).

@tommyettinger
Copy link
Member

I can confirm the Java and Kotlin samples build with the most recent sample versions and most recent IDEA (2023.2.2). I haven't tested with AS, nor have I been able to test the iOS builds, but all other platforms work out of the box. So I guess I can close this! Hooray...

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

No branches or pull requests

3 participants