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

Fix Android mono export with 2 or more cpu architectures fails #98066

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long

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)
{
string ridOS = config.RidOS;
Expand Down Expand Up @@ -325,14 +327,6 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
{
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))
{
AddSharedObject(path, tags: new string[] { arch },
Expand All @@ -343,10 +337,19 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
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;
}
Expand Down
5 changes: 4 additions & 1 deletion platform/android/java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ 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 {
Expand Down