Browse Source

Merge pull request #98066 from TCROC/fix-android-mono-export

Fix Android mono export with 2 or more cpu architectures fails
Thaddeus Crews 6 months ago
parent
commit
c90fd7f3da

+ 14 - 11
modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs

@@ -216,6 +216,8 @@ namespace GodotTools.Export
 
 
             bool embedBuildResults = ((bool)GetOption("dotnet/embed_build_outputs") || platform == OS.Platforms.Android) && platform != OS.Platforms.MacOS;
             bool embedBuildResults = ((bool)GetOption("dotnet/embed_build_outputs") || platform == OS.Platforms.Android) && platform != OS.Platforms.MacOS;
 
 
+            var exportedJars = new HashSet<string>();
+
             foreach (PublishConfig config in targets)
             foreach (PublishConfig config in targets)
             {
             {
                 string ridOS = config.RidOS;
                 string ridOS = config.RidOS;
@@ -325,14 +327,6 @@ namespace GodotTools.Export
                                     {
                                     {
                                         string fileName = Path.GetFileName(path);
                                         string fileName = Path.GetFileName(path);
 
 
-                                        if (fileName.EndsWith(".jar"))
-                                        {
-                                            // We exclude jar files from the export since they should
-                                            // already be included in the Godot templates, adding them
-                                            // again would cause conflicts.
-                                            return;
-                                        }
-
                                         if (IsSharedObject(fileName))
                                         if (IsSharedObject(fileName))
                                         {
                                         {
                                             AddSharedObject(path, tags: new string[] { arch },
                                             AddSharedObject(path, tags: new string[] { arch },
@@ -343,10 +337,19 @@ namespace GodotTools.Export
                                             return;
                                             return;
                                         }
                                         }
 
 
-                                        static bool IsSharedObject(string fileName)
+                                        bool IsSharedObject(string fileName)
                                         {
                                         {
-                                            if (fileName.EndsWith(".so") || fileName.EndsWith(".a")
-                                             || fileName.EndsWith(".dex"))
+                                            if (fileName.EndsWith(".jar"))
+                                            {
+                                                // Don't export the same jar twice. Otherwise we will have conflicts.
+                                                // This can happen when exporting for multiple architectures. Dotnet
+                                                // stores the jars in .godot/mono/temp/bin/Export[Debug|Release] per
+                                                // target architecture. Jars are cpu agnostic so only 1 is needed.
+                                                var jarName = Path.GetFileName(fileName);
+                                                return exportedJars.Add(jarName);
+                                            }
+
+                                            if (fileName.EndsWith(".so") || fileName.EndsWith(".a") || fileName.EndsWith(".dex"))
                                             {
                                             {
                                                 return true;
                                                 return true;
                                             }
                                             }

+ 0 - 0
platform/android/java/app/monoLibs/libSystem.Security.Cryptography.Native.Android.jar → modules/mono/thirdparty/libSystem.Security.Cryptography.Native.Android.jar


+ 4 - 1
platform/android/java/app/build.gradle

@@ -70,7 +70,10 @@ dependencies {
     }
     }
 
 
     // .NET dependencies
     // .NET dependencies
-    monoImplementation fileTree(dir: 'monoLibs', include: ['*.jar'])
+    String jar = '../../../../modules/mono/thirdparty/libSystem.Security.Cryptography.Native.Android.jar'
+    if (file(jar).exists()) {
+        monoImplementation files(jar)
+    }
 }
 }
 
 
 android {
 android {