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

Android mono export with 2 or more cpu architectures fails #98064

Open
TCROC opened this issue Oct 10, 2024 · 7 comments · May be fixed by #98066
Open

Android mono export with 2 or more cpu architectures fails #98064

TCROC opened this issue Oct 10, 2024 · 7 comments · May be fixed by #98066

Comments

@TCROC
Copy link
Contributor

TCROC commented Oct 10, 2024

Tested versions

4.4.dev [842f982]

System information

Linux Pop OS 22.04

Issue description

Note: I have a fix in my fork and will have a PR shortly.

Exporting an android mono build with 2 or more cpu architectures fails. This is due to libSystem.Security.Cryptography.Native.Android.jar being included twice in the export. 1 per cpu architecture. However, jars are cpu agnostic. Attempting to include 2 causes conflicts as Android attempts to load both. This was introduced in this PR here: #88803

Here is my error log:

ERROR: Export: Building of Android project failed, check output for the error:


> Configure project :
WARNING: The option setting 'android.overridePathCheck=true' is experimental.
The current default is 'false'.

> Task :validateJavaVersion UP-TO-DATE
> Task :clean UP-TO-DATE
> Task :assetPacks:installTime:clean UP-TO-DATE
> Task :preBuild UP-TO-DATE
> Task :preMonoDebugBuild UP-TO-DATE
> Task :mergeMonoDebugNativeDebugMetadata NO-SOURCE
> Task :checkKotlinGradlePluginConfigurationErrors
> Task :generateMonoDebugBuildConfig
> Task :generateMonoDebugResValues
> Task :checkMonoDebugAarMetadata
> Task :mapMonoDebugSourceSetPaths
> Task :generateMonoDebugResources
> Task :mergeMonoDebugResources
> Task :packageMonoDebugResources
> Task :createMonoDebugCompatibleScreenManifests
> Task :extractDeepLinksMonoDebug
> Task :parseMonoDebugLocalResources

> Task :processMonoDebugMainManifest
/home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/src/debug/AndroidManifest.xml:13:5-132 Warning:
	uses-feature#android.hardware.vulkan.level was tagged at AndroidManifest.xml:13 to replace another declaration but no other declaration present
/home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/src/debug/AndroidManifest.xml:14:5-140 Warning:
	uses-feature#android.hardware.vulkan.version was tagged at AndroidManifest.xml:14 to replace another declaration but no other declaration present

> Task :processMonoDebugManifest
> Task :javaPreCompileMonoDebug
> Task :mergeMonoDebugShaders
> Task :compileMonoDebugShaders NO-SOURCE
> Task :generateMonoDebugAssets UP-TO-DATE
> Task :mergeMonoDebugAssets
> Task :checkMonoDebugDuplicateClasses
> Task :compressMonoDebugAssets
> Task :mergeMonoDebugJniLibFolders
> Task :mergeLibDexMonoDebug
> Task :validateSigningMonoDebug
> Task :writeMonoDebugAppMetadata
> Task :writeMonoDebugSigningConfigVersions
> Task :processMonoDebugManifestForPackage
> Task :desugarMonoDebugFileDependencies
> Task :processMonoDebugResources
> Task :compileMonoDebugKotlin NO-SOURCE

> Task :mergeExtDexMonoDebug FAILED
ERROR: /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/0_jetified-libSystem.Security.Cryptography.Native.Android.jar: D8: Type net.dot.android.crypto.DotnetProxyTrustManager is defined multiple times: /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/0_jetified-libSystem.Security.Cryptography.Native.Android.jar:classes.dex, /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/2_jetified-libSystem.Security.Cryptography.Native.Android.jar: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 net.dot.android.crypto.DotnetProxyTrustManager is defined multiple times: /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/0_jetified-libSystem.Security.Cryptography.Native.Android.jar:classes.dex, /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/2_jetified-libSystem.Security.Cryptography.Native.Android.jar:classes.dex
	at com.android.builder.dexing.D8DexArchiveMerger.getMergingExceptionToRethrow(D8DexArchiveMerger.java:159)
	at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:147)
	at com.android.build.gradle.internal.tasks.DexMergingWorkAction.merge(DexMergingTask.kt:891)
	at com.android.build.gradle.internal.tasks.DexMergingWorkAction.run(DexMergingTask.kt:835)
	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:100)
	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$0(DefaultWorkerExecutor.java:170)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162)
	at org.gradle.internal.Factories$1.create(Factories.java:31)
	at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:249)
	at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:109)
	at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:114)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	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.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/0_jetified-libSystem.Security.Cryptography.Native.Android.jar:classes.dex
	at Version.fakeStackEntry(Version_8.2.33.java:0)
	at com.android.tools.r8.T.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:5)
	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:82)
	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:32)
	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:31)
	at com.android.tools.r8.utils.S0.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:2)
	at com.android.tools.r8.D8.run(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:11)
	at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:145)
	... 38 more
Caused by: com.android.tools.r8.utils.b: Type net.dot.android.crypto.DotnetProxyTrustManager is defined multiple times: /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/0_jetified-libSystem.Security.Cryptography.Native.Android.jar:classes.dex, /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/2_jetified-libSystem.Security.Cryptography.Native.Android.jar:classes.dex
	at com.android.tools.r8.utils.Q2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:21)
	at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:54)
	at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:10)
	at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
	at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6)
	at com.android.tools.r8.graph.m4$a.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6)
	at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:61)
	at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:12)
	at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:9)
	at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:45)
	at com.android.tools.r8.D8.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:17)
	at com.android.tools.r8.D8.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:1)
	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:28)
	... 41 more


> Task :compileMonoDebugJavaWithJavac
> Task :mergeMonoDebugNativeLibs

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mergeExtDexMonoDebug'.
> 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 net.dot.android.crypto.DotnetProxyTrustManager is defined multiple times: /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/0_jetified-libSystem.Security.Cryptography.Native.Android.jar:classes.dex, /home/tcroc/dev/BlockyBallOT/blockyball-godot/android/app/build/build/intermediates/external_file_lib_dex_archives/monoDebug/2_jetified-libSystem.Security.Cryptography.Native.Android.jar: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 13s
30 actionable tasks: 28 executed, 2 up-to-date

   at: add_message (./editor/export/editor_export_platform.h:235)
export: end
ERROR: Project export for preset "Android APK" failed.
   at: _fs_changed (editor/editor_node.cpp:1049)
loading_editor_layout: begin: Loading editor steps: 5
	loading_editor_layout: step 0: Loading editor layout...
loading_editor_layout: end

Steps to reproduce

  1. Use a mono build of godot
  2. Set up and android export preset (I did apk)
  3. Configure to use a gradle build (nice find @raulsntos)
  4. Configure it for 2 or more architectures (I did x86_64 and arm64)
  5. Export and see that it errors

Minimal reproduction project (MRP)

N/A

@TCROC TCROC changed the title Android mono export error with 2 or more architectures Android mono export with 2 or more cpu architectures causes error Oct 10, 2024
@TCROC TCROC changed the title Android mono export with 2 or more cpu architectures causes error Android mono export with 2 or more cpu architectures fails Oct 10, 2024
@raulsntos
Copy link
Member

The PR you mentioned (#88803) has not been backported to 4.3. Did you mean 4.4?

It looks like you are exporting using Gradle builds. I'm unable to reproduce using the pre-built export template APK.

@TCROC
Copy link
Contributor Author

TCROC commented Oct 10, 2024

Yes. I did mean 4.4. My bad.

@TCROC
Copy link
Contributor Author

TCROC commented Oct 10, 2024

@raulsntos which would explain why you couldn't reproduce it. I had a typo. I meant to say 4.4. I do have a PR here that fixes it: #98064

@raulsntos
Copy link
Member

No, I assumed you meant 4.4 and tested with a new build from commit 4c4e673. The issue is likely exclusive to Gradle builds, since non-Gradle builds don't care about these .jar files and can include them multiple times just fine.

@TCROC
Copy link
Contributor Author

TCROC commented Oct 10, 2024

Ah I see what you mean. Yes I can confirm that I am currently using a gradle build:

image

@TCROC
Copy link
Contributor Author

TCROC commented Oct 10, 2024

@raulsntos I updated my repro steps and mentioned you. Thanks for the clarification! :)

@TCROC
Copy link
Contributor Author

TCROC commented Dec 12, 2024

Hey @akien-mga . Can we add this as a 4.4 release blocker? Otherwise it will break android + mono / c# devs. Which I presume is a lot of devs. I have a PR with a fix in here: #98066

But there is still discussion around whether they want to take the approach in that PR. I am personally fine. The fix is in our fork. But it will hurt a lot of other devs if 4.4 releases with this issue.

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

Successfully merging a pull request may close this issue.

3 participants