build-apks fails in conjunction with coreLibraryDesugaringEnabled
See original GitHub issueDescribe the bug The build-apks command fails on an app with coreLibraryDesugaringEnabled and minSdk = 16
Bundletool version(s) affected 1.2.0
Stacktrace
bundletool build-apks --bundle app/build/outputs/bundle/reflectRelease/app-reflect-release.aab --output ~/tmp/my_app.apks
INFO: The APKs will be signed with the debug keystore found at '/Volumes/Transcend/Android/.android/debug.keystore'.
Error: Merging dex file containing classes with prefix 'j$.' with classes with any other prefixes is not allowed.
[BT:1.2.0] Error: Dex merging failed.
com.android.tools.build.bundletool.model.exceptions.CommandExecutionException: Dex merging failed.
at com.android.tools.build.bundletool.model.exceptions.InternalExceptionBuilder.build(InternalExceptionBuilder.java:57)
at com.android.tools.build.bundletool.mergers.D8DexMerger.translateD8Exception(D8DexMerger.java:107)
at com.android.tools.build.bundletool.mergers.D8DexMerger.merge(D8DexMerger.java:81)
at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeDexFiles(ModuleSplitsToShardMerger.java:343)
at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.lambda$mergeDexFilesAndCache$1(ModuleSplitsToShardMerger.java:282)
at java.util.HashMap.computeIfAbsent(HashMap.java:1126)
at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeDexFilesAndCache(ModuleSplitsToShardMerger.java:280)
at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeSingleShard(ModuleSplitsToShardMerger.java:163)
at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeSingleShard(ModuleSplitsToShardMerger.java:99)
at com.android.tools.build.bundletool.shards.StandaloneApksGenerator.lambda$generateStandaloneApks$1(StandaloneApksGenerator.java:93)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at com.android.tools.build.bundletool.shards.StandaloneApksGenerator.generateStandaloneApks(StandaloneApksGenerator.java:96)
at com.android.tools.build.bundletool.shards.ShardedApksFacade.generateSplits(ShardedApksFacade.java:63)
at com.android.tools.build.bundletool.commands.BuildApksManager.generateStandaloneApks(BuildApksManager.java:211)
at com.android.tools.build.bundletool.commands.BuildApksManager.execute(BuildApksManager.java:147)
at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:624)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:75)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:47)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at com.android.tools.r8.utils.W.a(:87)
at com.android.tools.r8.D8.run(:6)
at com.android.tools.build.bundletool.mergers.D8DexMerger.merge(D8DexMerger.java:74)
... 21 more
Caused by: com.android.tools.r8.utils.b: Error: Merging dex file containing classes with prefix 'j$.' with classes with any other prefixes is not allowed.
at com.android.tools.r8.utils.M0.a(:21)
at com.android.tools.r8.utils.W.a(:73)
... 23 more
To Reproduce I have patched android/app-bundle-samples in order to showcase the problem with the DynamicCodeLoadingKotlin sample: https://github.com/mtotschnig/app-bundle-samples/commit/af6cec93409a36d0118867de5192f38c44eb79d8
Expected behavior build-apks should generate APKs to allow local testing.
Known workaround None.
Environment: JVM: 1.8.0_144 (Oracle Corporation 25.144-b01) OS: Mac OS X 10.15.6 x86_64
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
Could not find method: coreLibraryDesugaringEnabled in the ...
I expected it would work fine, but it makes the below error: Could not find method coreLibraryDesugaringEnabled() for arguments [true] on object ...
Read more >coreLibraryDesugaringEnabled = true leads to ... - Issue Tracker
I've enabled coreLibraryDesugaringEnabled and included the desugar_jdk_libs artifact ... They all fail with a "ClassNotFoundException: Didn't find class '.
Read more >Use Java 8 language features and APIs - Android Developers
Otherwise, you get the following error: Dex: Error converting bytecode to dex: Cause: ... coreLibraryDesugaringEnabled true
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Implemented in bundletool 1.7.0.
desugar_jdk_libs is not currently fully supported in bundletool for applications with minSdk less than 21. This decision is made because even if we implement such support it will be very limited as on devices with sdk below 21 legacy multidex support is required for such apps: https://developer.android.com/studio/build/multidex#mdex-gradle.
And legacy multidex support + desugar_jdk_libs has a limitation: desugar_jdk_libs requires to have its own dex file that on devices with sdk <= 21 will be loaded after the main dex file with all activities and fragments. This means that a developer won’t be able to use any Java 8 classes/interfaces as field types, method parameters, or method return types in subclasses of Activity, Fragment. Java 8 classes will work correctly only as local variables and in helper classes.