Adobe-Runtime-Support
Adobe-Runtime-Support copied to clipboard
Cannot build Android AAB package with native extension with the same id
Problem Description
Cannot build Android AAB application with native extension that has the same id. If application id equal with native extension id that it uses - you will get packaging error.
It has been tested with multiple AIR versions, even with latest AIR 50.0.0.1 with different applications ids with different native extensions. Same problem in all cases if native extension has the same id as application. There is no such issue with APK packaging.
Related issue (not the same): https://github.com/airsdk/Adobe-Runtime-Support/issues/1188
Steps to Reproduce
Try to package AIR application as Android AAB with application id that equal native extension id that is uses. Application example with sources, native extension sample and packaging commands attached. android_aab_native_extension_id_bug.zip
Packaging command: adt -package -target aab -storetype pkcs12 -keystore cert.p12 -storepass pass -keypass pass android_aab_native_extension_id_bug.apk android_aab_native_extension_id_bug-app.xml -extdir libs android_aab_native_extension_id_bug.swf
Application ID and native extension ID: com.test.ane
Actual Result: Packaging error:
unexpected failure: Unable to run java: com.adobe.air.ADTException: gradle tool failed: Warning: This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
ERROR:C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex: D8: Type com.test.ane.BuildConfig is defined multiple times: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex, C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Type com.test.ane.BuildConfig is defined multiple times: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex, C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex
at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:151)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:138)
at com.android.build.gradle.internal.tasks.DexMergingWorkAction.merge(DexMergingTask.kt:863)
at com.android.build.gradle.internal.tasks.DexMergingWorkAction.run(DexMergingTask.kt:809)
at com.android.build.gradle.internal.profile.ProfileAwareWorkAction.execute(ProfileAwareWorkAction.kt:74)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:206)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:214)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex
at Version.fakeStackEntry(Version_3.0.64.java:0)
at com.android.tools.r8.utils.w.a(SourceFile:68)
at com.android.tools.r8.utils.w.a(SourceFile:28)
at com.android.tools.r8.utils.w.a(SourceFile:27)
at com.android.tools.r8.utils.w.b(SourceFile:3)
at com.android.tools.r8.D8.run(D8.java:11)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:136)
... 33 more
Caused by: com.android.tools.r8.internal.b: Type com.test.ane.BuildConfig is defined multiple times: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex, C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex
at com.android.tools.r8.internal.RA.a(SourceFile:14)
at com.android.tools.r8.internal.RA.a(SourceFile:22)
at com.android.tools.r8.internal.Cw.b(SourceFile:6)
at com.android.tools.r8.internal.Cw.a(SourceFile:23)
at com.android.tools.r8.internal.Cw.a(SourceFile:10)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
at com.android.tools.r8.internal.Cw.a(SourceFile:6)
at com.android.tools.r8.graph.I0$c.f(SourceFile:3)
at com.android.tools.r8.dex.a.a(SourceFile:94)
at com.android.tools.r8.dex.a.a(SourceFile:23)
at com.android.tools.r8.D8.a(D8.java:21)
at com.android.tools.r8.D8.d(D8.java:11)
at com.android.tools.r8.D8.b(D8.java:1)
at com.android.tools.r8.utils.w.a(SourceFile:24)
... 36 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Type com.test.ane.BuildConfig is defined multiple times: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex, C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex
* 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 15s
java.io.IOException: Unable to run java: com.adobe.air.ADTException: gradle tool failed: Warning: This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
ERROR:C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex: D8: Type com.test.ane.BuildConfig is defined multiple times: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex, C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Type com.test.ane.BuildConfig is defined multiple times: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex, C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex
at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:151)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:138)
at com.android.build.gradle.internal.tasks.DexMergingWorkAction.merge(DexMergingTask.kt:863)
at com.android.build.gradle.internal.tasks.DexMergingWorkAction.run(DexMergingTask.kt:809)
at com.android.build.gradle.internal.profile.ProfileAwareWorkAction.execute(ProfileAwareWorkAction.kt:74)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:206)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:214)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex
at Version.fakeStackEntry(Version_3.0.64.java:0)
at com.android.tools.r8.utils.w.a(SourceFile:68)
at com.android.tools.r8.utils.w.a(SourceFile:28)
at com.android.tools.r8.utils.w.a(SourceFile:27)
at com.android.tools.r8.utils.w.b(SourceFile:3)
at com.android.tools.r8.D8.run(D8.java:11)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:136)
... 33 more
Caused by: com.android.tools.r8.internal.b: Type com.test.ane.BuildConfig is defined multiple times: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex, C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex
at com.android.tools.r8.internal.RA.a(SourceFile:14)
at com.android.tools.r8.internal.RA.a(SourceFile:22)
at com.android.tools.r8.internal.Cw.b(SourceFile:6)
at com.android.tools.r8.internal.Cw.a(SourceFile:23)
at com.android.tools.r8.internal.Cw.a(SourceFile:10)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
at com.android.tools.r8.internal.Cw.a(SourceFile:6)
at com.android.tools.r8.graph.I0$c.f(SourceFile:3)
at com.android.tools.r8.dex.a.a(SourceFile:94)
at com.android.tools.r8.dex.a.a(SourceFile:23)
at com.android.tools.r8.D8.a(D8.java:21)
at com.android.tools.r8.D8.d(D8.java:11)
at com.android.tools.r8.D8.b(D8.java:1)
at com.android.tools.r8.utils.w.a(SourceFile:24)
... 36 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Type com.test.ane.BuildConfig is defined multiple times: C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\project_dex_archive\release\out\com\test\ane\BuildConfig.dex, C:\Users\username\AppData\Local\Temp\34746714-fe1d-446a-b323-0d3ec1f1322f\app\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex
* 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 15s
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)
Expected Result: AIR application will be packaged without errors.
Known Workarounds
Change application ID or native extension ID.
I'd suggest making sure your application id and extension package name don't overlap. They are supposed to be unique.
@marchbold, I already use different IDs as described in workaround.
I have opened this issue cause error log not obvious about real issue and may be other developers stuck with that. And it works fine with APK. So I think there should be some comment from @ajwfrost. May be some better adt
error description should be in such cases..
Okay sure, I'd expect the error would be fairly obvious to an extension developer though and one of the reasons to ensure you are using unique package names for your extensions.