google / bundletool

Bundletool is a command-line tool to manipulate Android App Bundles
https://g.co/androidappbundle
Apache License 2.0
3.55k stars 386 forks source link

bundletool build-apks failed when minsdk<21 #338

Open fundyjob opened 1 year ago

fundyjob commented 1 year ago

Describe the bug agp:7.4.2 gradle:7.6.1 minsdk:19 When I upgraded from AGP 7.0.4 to 7.4.2 and Gradle from 7.0.2 to 7.6.1, I got an exception when parsing the release version of the AAB to generate APKS. I suspect it is related to desugaring, as the exception only occurs when the minSdk is less than 21.

However, I cannot upgrade to minSdk > 21 yet because there are still a large number of users on older devices. I hope you can help me solve this problem.

Bundletool version(s) affected Version: [e.g.1.8.0~1.15.1] i'm not sure before 1.8.0

Stacktrace [BT:1.15.1] Error: Flag --output should be the path where to generate the APK Set. Its extension must be '.apks'. com.android.tools.build.bundletool.model.exceptions.InvalidCommandException: Flag --output should be the path where to generate the APK Set. Its extension must be '.apks'. at com.android.tools.build.bundletool.model.exceptions.InternalExceptionBuilder.build(InternalExceptionBuilder.java:57) at com.android.tools.build.bundletool.commands.BuildApksCommand$Builder.build(BuildApksCommand.java:706) at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:884) at com.android.tools.build.bundletool.commands.BuildApksCommand.fromFlags(BuildApksCommand.java:752) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:83) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:55)

java -jar scripts/bundletool.jar build-apks --bundle=/Users/duanfengyuan/compress/likee-5.6.0-30127-gp-eng.aab --output=apks/release.apks --ks=~/bigo.keystore --ks-key-alias=xjp-bigo-android --key-pass=pass:49MTiNzChAbxmxkH Enter keystore password: 6月 26, 2023 6:11:53 下午 com.android.tools.build.bundletool.commands.BuildApksCommand execute 信息: Output directory 'apks' does not exist, creating it. Error: java.lang.NullPointerException Error: java.lang.NullPointerException [BT:1.15.1] Error: Dex merging failed. null com.android.tools.build.bundletool.model.exceptions.CommandExecutionException: Dex merging failed. null at com.android.tools.build.bundletool.model.exceptions.InternalExceptionBuilder.build(InternalExceptionBuilder.java:57) at com.android.tools.build.bundletool.mergers.D8DexMerger.translateD8Exception(D8DexMerger.java:169) at com.android.tools.build.bundletool.mergers.D8DexMerger.merge(D8DexMerger.java:141) at com.android.tools.build.bundletool.mergers.D8DexMerger.merge(D8DexMerger.java:138) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeDexFiles(ModuleSplitsToShardMerger.java:375) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.lambda$mergeDexFilesAndCache$1(ModuleSplitsToShardMerger.java:295) at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeDexFilesAndCache(ModuleSplitsToShardMerger.java:294) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeSingleShard(ModuleSplitsToShardMerger.java:167) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeSingleShard(ModuleSplitsToShardMerger.java:105) at com.android.tools.build.bundletool.shards.StandaloneApksGenerator.lambda$generateStandaloneApkWithFusedModule$1(StandaloneApksGenerator.java:132) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) at com.android.tools.build.bundletool.shards.StandaloneApksGenerator.generateStandaloneApkWithFusedModule(StandaloneApksGenerator.java:135) at com.android.tools.build.bundletool.shards.StandaloneApksGenerator.generateStandaloneApks(StandaloneApksGenerator.java:124) at com.android.tools.build.bundletool.shards.ShardedApksFacade.generateSplits(ShardedApksFacade.java:63) at com.android.tools.build.bundletool.commands.BuildApksManager.generateStandaloneApks(BuildApksManager.java:236) at com.android.tools.build.bundletool.commands.BuildApksManager.execute(BuildApksManager.java:152) at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:923) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:83) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:55) Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete at Version.fakeStackEntry(Version_3.3.28.java:0) at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:75) at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28) at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:27) at com.android.tools.r8.internal.Bj.b(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:2) at com.android.tools.r8.D8.run(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:6) at com.android.tools.build.bundletool.mergers.D8DexMerger.merge(D8DexMerger.java:121) ... 23 more Caused by: java.lang.NullPointerException at com.android.tools.r8.internal.Bw.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:400) at com.android.tools.r8.graph.N.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:24) at com.android.tools.r8.internal.F2.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:1518) at com.android.tools.r8.graph.W0.c(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:3) at com.android.tools.r8.graph.L2.b(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:5) at com.android.tools.r8.graph.M2.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:3) at com.android.tools.r8.graph.K2.g(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:3) at com.android.tools.r8.graph.M2.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:1) at com.android.tools.r8.graph.L2.b(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:3) at com.android.tools.r8.graph.W0.g(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:2) at com.android.tools.r8.internal.F2.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:1515) at com.android.tools.r8.internal.F2.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:327) at com.android.tools.r8.utils.C.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4) at com.android.tools.r8.utils.C.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:38) at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1448) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) Suppressed: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NullPointerException at com.android.tools.r8.D8.d(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:766) at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:1) at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:24) at com.android.tools.r8.internal.Bj.b(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:2) at com.android.tools.r8.D8.run(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:6) at com.android.tools.build.bundletool.mergers.D8DexMerger.merge(D8DexMerger.java:121) at com.android.tools.build.bundletool.mergers.D8DexMerger.merge(D8DexMerger.java:138) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeDexFiles(ModuleSplitsToShardMerger.java:375) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.lambda$mergeDexFilesAndCache$1(ModuleSplitsToShardMerger.java:295) at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeDexFilesAndCache(ModuleSplitsToShardMerger.java:294) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeSingleShard(ModuleSplitsToShardMerger.java:167) at com.android.tools.build.bundletool.mergers.ModuleSplitsToShardMerger.mergeSingleShard(ModuleSplitsToShardMerger.java:105) at com.android.tools.build.bundletool.shards.StandaloneApksGenerator.lambda$generateStandaloneApkWithFusedModule$1(StandaloneApksGenerator.java:132) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) at com.android.tools.build.bundletool.shards.StandaloneApksGenerator.generateStandaloneApkWithFusedModule(StandaloneApksGenerator.java:135) at com.android.tools.build.bundletool.shards.StandaloneApksGenerator.generateStandaloneApks(StandaloneApksGenerator.java:124) at com.android.tools.build.bundletool.shards.ShardedApksFacade.generateSplits(ShardedApksFacade.java:63) at com.android.tools.build.bundletool.commands.BuildApksManager.generateStandaloneApks(BuildApksManager.java:236) at com.android.tools.build.bundletool.commands.BuildApksManager.execute(BuildApksManager.java:152) at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:923) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:83) at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:55) Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1006) at com.android.tools.r8.utils.C.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:14) at com.android.tools.r8.utils.C.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:6) at com.android.tools.r8.utils.C.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:5) at com.android.tools.r8.internal.F2.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:486) at com.android.tools.r8.D8.d(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:756) ... 28 more Caused by: java.lang.NullPointerException at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:603) ... 34 more Caused by: [CIRCULAR REFERENCE: java.lang.NullPointerException]

To Reproduce Steps to reproduce the behavior. Include the full command being run as well as, if possible, artifacts the bug can be reproduced with.

Expected behavior A clear and concise description of what you expected to happen.

Known workaround If you have found a workaround, please specify what it is.

Environment: OS: [e.g. iOS 10.3.3]

Additional context Add any other context about the problem here.

JohanBeumer commented 1 year ago

@fundyjob just an alert for you, your --ks-key-alias and --key-pass are shown in the logging