Skip to content

Commit c90fd7f

Browse files
committed
Merge pull request godotengine#98066 from TCROC/fix-android-mono-export
Fix Android mono export with 2 or more cpu architectures fails
2 parents 6a3bf28 + 5e2fd7b commit c90fd7f

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
216216

217217
bool embedBuildResults = ((bool)GetOption("dotnet/embed_build_outputs") || platform == OS.Platforms.Android) && platform != OS.Platforms.MacOS;
218218

219+
var exportedJars = new HashSet<string>();
220+
219221
foreach (PublishConfig config in targets)
220222
{
221223
string ridOS = config.RidOS;
@@ -325,14 +327,6 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
325327
{
326328
string fileName = Path.GetFileName(path);
327329

328-
if (fileName.EndsWith(".jar"))
329-
{
330-
// We exclude jar files from the export since they should
331-
// already be included in the Godot templates, adding them
332-
// again would cause conflicts.
333-
return;
334-
}
335-
336330
if (IsSharedObject(fileName))
337331
{
338332
AddSharedObject(path, tags: new string[] { arch },
@@ -343,10 +337,19 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
343337
return;
344338
}
345339

346-
static bool IsSharedObject(string fileName)
340+
bool IsSharedObject(string fileName)
347341
{
348-
if (fileName.EndsWith(".so") || fileName.EndsWith(".a")
349-
|| fileName.EndsWith(".dex"))
342+
if (fileName.EndsWith(".jar"))
343+
{
344+
// Don't export the same jar twice. Otherwise we will have conflicts.
345+
// This can happen when exporting for multiple architectures. Dotnet
346+
// stores the jars in .godot/mono/temp/bin/Export[Debug|Release] per
347+
// target architecture. Jars are cpu agnostic so only 1 is needed.
348+
var jarName = Path.GetFileName(fileName);
349+
return exportedJars.Add(jarName);
350+
}
351+
352+
if (fileName.EndsWith(".so") || fileName.EndsWith(".a") || fileName.EndsWith(".dex"))
350353
{
351354
return true;
352355
}

platform/android/java/app/monoLibs/libSystem.Security.Cryptography.Native.Android.jar renamed to modules/mono/thirdparty/libSystem.Security.Cryptography.Native.Android.jar

File renamed without changes.

platform/android/java/app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ dependencies {
7070
}
7171

7272
// .NET dependencies
73-
monoImplementation fileTree(dir: 'monoLibs', include: ['*.jar'])
73+
String jar = '../../../../modules/mono/thirdparty/libSystem.Security.Cryptography.Native.Android.jar'
74+
if (file(jar).exists()) {
75+
monoImplementation files(jar)
76+
}
7477
}
7578

7679
android {

0 commit comments

Comments
 (0)