@@ -216,6 +216,8 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
216
216
217
217
bool embedBuildResults = ( ( bool ) GetOption ( "dotnet/embed_build_outputs" ) || platform == OS . Platforms . Android ) && platform != OS . Platforms . MacOS ;
218
218
219
+ var exportedJars = new HashSet < string > ( ) ;
220
+
219
221
foreach ( PublishConfig config in targets )
220
222
{
221
223
string ridOS = config . RidOS ;
@@ -323,8 +325,27 @@ private void _ExportBeginImpl(string[] features, bool isDebug, string path, long
323
325
{
324
326
if ( platform == OS . Platforms . Android )
325
327
{
326
- if ( IsSharedObject ( Path . GetFileName ( path ) ) )
328
+ var fileName = Path . GetFileName ( path ) ;
329
+ if ( IsSharedObject ( fileName ) )
327
330
{
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
+
328
349
AddSharedObject ( path , tags : new string [ ] { arch } ,
329
350
Path . Join ( projectDataDirName ,
330
351
Path . GetRelativePath ( publishOutputDir ,
0 commit comments