Skip to content

Commit 4217a10

Browse files
committed
fix android mono export causing conflicts
1 parent 842f982 commit 4217a10

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

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

+22-1
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;
@@ -323,8 +325,27 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
323325
{
324326
if (platform == OS.Platforms.Android)
325327
{
326-
if (IsSharedObject(Path.GetFileName(path)))
328+
var fileName = Path.GetFileName(path);
329+
if (IsSharedObject(fileName))
327330
{
331+
if (fileName.EndsWith(".jar"))
332+
{
333+
// Don't export the same dotnet jar twice. Otherwise we will have conflicts. This
334+
// can happen when exporting for multiple architectures. The jars exported from
335+
// godot for dotnet can be found in .godot/mono/temp/bin/Export[Debug|Release].
336+
// If you compare the bytecode with AndroidStudio or IntelliJ, you will find that
337+
// they are identical. Hence why we can only export one.
338+
//
339+
// Gradle does not distinguish jars between abi folders like it does with .so files. It will
340+
// try to compile both into the application if they are both exported.
341+
if (exportedJars.Contains(fileName))
342+
{
343+
return;
344+
}
345+
346+
exportedJars.Add(fileName);
347+
}
348+
328349
AddSharedObject(path, tags: new string[] { arch },
329350
Path.Join(projectDataDirName,
330351
Path.GetRelativePath(publishOutputDir,

0 commit comments

Comments
 (0)