godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
87.99k stars 19.9k forks source link

Android build is (sometimes) missing referenced .NET assemblies #40204

Open timothyparez opened 4 years ago

timothyparez commented 4 years ago

Godot version: 3.2.1 (3.2.2 has some breaking changes so I have not updated yet)

OS/device including version: Ubuntu 20.04 LTS Linux devtop-home 5.4.0-40-generic #44-Ubuntu SMP Tue Jun 23 00:01:04 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Multiple version of Android

Issue description: In my project reference some nuget packages, for example:

protobuf-net netmq Newtonsoft.Json

Steps to reproduce: Create an empty project with C# support. Add said nuget packages, export the APK

Minimal reproduction project:

The project I attached actually works... (but so does my other project sometimes) If you open the APK you can see protobuf-net is there, whereas in my other apk it is not.

AssemblyIssueSample.zip

image

If you look at the screenshot, you will see the content of 2 APK files. One does not include the protobuf-net assembly. I do not know what triggers the issue.

Logcat:

8 15:42:13.246  5553  5588 E mono    : Unhandled Exception:
07-08 15:42:13.246  5553  5588 E mono    : System.IO.FileNotFoundException: Could not load file or assembly 'protobuf-net, Version=2.4.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67' or one of its dependencies.
07-08 15:42:13.246  5553  5588 E mono    : File name: 'protobuf-net, Version=2.4.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67'
07-08 15:42:13.246  5553  5588 E mono    :   at (wrapper managed-to-native) System.MonoCustomAttrs.IsDefinedInternal(System.Reflection.ICustomAttributeProvider,System.Type)
07-08 15:42:13.246  5553  5588 E mono    :   at System.MonoCustomAttrs.IsDefined (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00027] in <d27d4d20107845ca9569511318b19517>:0 
07-08 15:42:13.246  5553  5588 E mono    :   at System.RuntimeType.IsDefined (System.Type attributeType, System.Boolean inherit) [0x00038] in <d27d4d20107845ca9569511318b19517>:0 
07-08 15:42:13.246  5553  5588 E mono    :   at System.Enum.InternalFormat (System.RuntimeType eT, System.Object value) [0x00000] in <d27d4d20107845ca9569511318b19517>:0 
07-08 15:42:13.246  5553  5588 E mono    :   at System.Enum.ToString () [0x00011] in <d27d4d20107845ca9569511318b19517>:0 
07-08 15:42:13.246  5553  5588 E mono    :   at DebugLabel._Process (System.Single delta) [0x0000d] in <dac6cfdc1ab24ae5b528571459958f73>:0 
07-08 15:49:17.312  6303  6343 I godot   : Godot Engine v3.2.1.stable.mono.official - https://godotengine.org
07-08 15:49:17.474  6303  6343 I godot   : Mono: Logfile is: /data/data/com.sample.mygame/files/mono/mono_logs/2020_07_08 15.49.17 (6303).txt
07-08 15:49:17.630  6303  6343 E godot   :    At: modules/mono/csharp_script.cpp:3187:reload() - Condition "!obj_type" is true. Returned: ERR_BUG
07-08 15:49:17.666  6303  6343 E godot   :    At: modules/mono/csharp_script.cpp:2915:can_instance() - Method failed. Returning: __null
07-08 15:49:18.130  6303  6343 E mono    : 
07-08 15:49:18.130  6303  6343 E mono    : Unhandled Exception:
07-08 15:49:18.130  6303  6343 E mono    : System.IO.FileNotFoundException: Could not load file or assembly 'protobuf-net, Version=2.4.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67' or one of its dependencies.
07-08 15:49:18.130  6303  6343 E mono    : File name: 'protobuf-net, Version=2.4.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67'
07-08 15:49:18.130  6303  6343 E mono    :   at (wrapper managed-to-native) System.MonoCustomAttrs.IsDefinedInternal(System.Reflection.ICustomAttributeProvider,System.Type)
07-08 15:49:18.130  6303  6343 E mono    :   at System.MonoCustomAttrs.IsDefined (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inherit) [0x00027] in <d27d4d20107845ca9569511318b19517>:0 
07-08 15:49:18.130  6303  6343 E mono    :   at System.RuntimeType.IsDefined (System.Type attributeType, System.Boolean inherit) [0x00038] in <d27d4d20107845ca9569511318b19517>:0 
07-08 15:49:18.130  6303  6343 E mono    :   at System.Enum.InternalFormat (System.RuntimeType eT, System.Object value) [0x00000] in <d27d4d20107845ca9569511318b19517>:0 
07-08 15:49:18.130  6303  6343 E mono    :   at System.Enum.ToString () [0x00011] in <d27d4d20107845ca9569511318b19517>:0 
07-08 15:49:18.130  6303  6343 E mono    :   at DebugLabel._Process (System.Single delta) [0x0000d] in <1c508adea2bd49df979fb8fbfb68771a>:0 

I think if something goes wrong during the export process it stops adding assemblies but still produces the APK.

neikeq commented 4 years ago

Right now there's no way for export plugins to abort if there's an error. However you should see an error dialog after exporting finishes. If that's not the case, can you run Godot in verbose mode, export the project and copy the full terminal output here? To run in verbose mode: godot --path path/to/project --editor --verbose

timothyparez commented 4 years ago

This is the monolog (not sure whether you need it or not), hang on for the other info monolog.txt

timothyparez commented 4 years ago

Verbose output:


Godot Engine v3.2.1.stable.mono.official - https://godotengine.org
EditorSettings: Save OK!
Mono: Unloading scripts domain...
Mono: Runtime cleanup...
Mono: Finalized
timothy@devtop-home:~/godot$ OpenGL ES 2.0 Renderer: GeForce GTX 1060 3GB/PCIe/SSE2

Mono: Logfile is: /home/timothy/.local/share/godot/mono/mono_logs/2020_07_08 22.21.43 (870135).txt
ERROR: reload: Condition "!obj_type" is true. Returned: ERR_BUG
   At: modules/mono/csharp_script.cpp:3187.
Running: "/usr/bin/msbuild" "/home/timothy/Documents/Projects/MyGame/MyGame.sln" /v:normal /t:Build "/p:Configuration=Debug" "/l:GodotTools.BuildLogger.GodotBuildLogger,/home/timothy/godot/GodotSharp/Tools/GodotTools.BuildLogger.dll;/home/timothy/.local/share/godot/mono/build_logs/c22e199bb31a371d6dbd06bf97ae64ae_Debug" /p:GodotDefineConstants=\"GODOT_MOBILE;GODOT_ANDROID;GODOT_ETC;GODOT_ARMEABI_V7A;GODOT_ARM64_V8A;\"
Microsoft (R) Build Engine version 16.5.0-ci for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Running: "/usr/bin/msbuild" "/home/timothy/Documents/Projects/MyGame/MyGame.sln" /v:normal /t:Build "/p:Configuration=Debug" "/l:GodotTools.BuildLogger.GodotBuildLogger,/home/timothy/godot/GodotSharp/Tools/GodotTools.BuildLogger.dll;/home/timothy/.local/share/godot/mono/build_logs/c22e199bb31a371d6dbd06bf97ae64ae_Debug" /p:GodotDefineConstants=\"GODOT_MOBILE;GODOT_ANDROID;GODOT_ETC;GODOT_ARMEABI_V7A;GODOT_ARM64_V8A;\"
Microsoft (R) Build Engine version 16.5.0-ci for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 7/8/2020 10:21:51 PM.
Project "/home/timothy/Documents/Projects/MyGame/MyGame.sln" on node 1 (Build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Project "/home/timothy/Documents/Projects/MyGame/MyGame.sln" (1) is building "/home/timothy/Documents/Projects/MyGame/MyGame.csproj" (2) on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
_CopyFilesMarkedCopyLocal:
  Touching "/home/timothy/Documents/Projects/MyGame/.mono/temp/obj/Debug/MyGame.csproj.CopyComplete".
_CopyAppConfigFile:
Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
  MyGame -> /home/timothy/Documents/Projects/MyGame/.mono/temp/bin/Debug/MyGame.dll
Done Building Project "/home/timothy/Documents/Projects/MyGame/MyGame.csproj" (default targets).
Done Building Project "/home/timothy/Documents/Projects/MyGame/MyGame.sln" (Build target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.72

Time Elapsed 00:00:00.72
ERROR: get_assembly_dependencies: Cannot load assembly (refonly): 'System.Threading.Tasks.Dataflow'.
   At: modules/mono/editor/godotsharp_export.cpp:93.
ADDING: AndroidManifest.xml
ADDING: classes.dex
ADDING: lib/arm64-v8a/libMonoPosixHelper.so
ADDING: lib/arm64-v8a/libMonoSupportW.so
ADDING: lib/arm64-v8a/libc++_shared.so
ADDING: lib/arm64-v8a/libgodot_android.so
ADDING: lib/arm64-v8a/libmono-btls-shared.so
ADDING: lib/arm64-v8a/libmono-ee-interp.so
ADDING: lib/arm64-v8a/libmono-native.so
ADDING: lib/arm64-v8a/libmono-profiler-aot.so
ADDING: lib/arm64-v8a/libmono-profiler-coverage.so
ADDING: lib/arm64-v8a/libmono-profiler-log.so
ADDING: lib/arm64-v8a/libmonosgen-2.0.so
ADDING: lib/armeabi-v7a/libMonoPosixHelper.so
ADDING: lib/armeabi-v7a/libMonoSupportW.so
ADDING: lib/armeabi-v7a/libc++_shared.so
ADDING: lib/armeabi-v7a/libgodot_android.so
ADDING: lib/armeabi-v7a/libmono-btls-shared.so
ADDING: lib/armeabi-v7a/libmono-ee-interp.so
ADDING: lib/armeabi-v7a/libmono-native.so
ADDING: lib/armeabi-v7a/libmono-profiler-aot.so
ADDING: lib/armeabi-v7a/libmono-profiler-coverage.so
ADDING: lib/armeabi-v7a/libmono-profiler-log.so
ADDING: lib/armeabi-v7a/libmonosgen-2.0.so
ADDING: res/drawable-hdpi-v4/notification_bg_low_normal.9.png
ADDING: res/drawable-hdpi-v4/notification_bg_low_pressed.9.png
ADDING: res/drawable-hdpi-v4/notification_bg_normal.9.png
ADDING: res/drawable-hdpi-v4/notification_bg_normal_pressed.9.png
ADDING: res/drawable-hdpi-v4/notify_panel_notification_icon_bg.png
ADDING: res/drawable-mdpi-v4/notification_bg_low_normal.9.png
ADDING: res/drawable-mdpi-v4/notification_bg_low_pressed.9.png
ADDING: res/drawable-mdpi-v4/notification_bg_normal.9.png
ADDING: res/drawable-mdpi-v4/notification_bg_normal_pressed.9.png
ADDING: res/drawable-mdpi-v4/notify_panel_notification_icon_bg.png
ADDING: res/drawable-v21/notification_action_background.xml
ADDING: res/drawable-xhdpi-v4/notification_bg_low_normal.9.png
ADDING: res/drawable-xhdpi-v4/notification_bg_low_pressed.9.png
ADDING: res/drawable-xhdpi-v4/notification_bg_normal.9.png
ADDING: res/drawable-xhdpi-v4/notification_bg_normal_pressed.9.png
ADDING: res/drawable-xhdpi-v4/notify_panel_notification_icon_bg.png
ADDING: res/drawable-xxhdpi-v4/notify_panel_notification_icon_bg.png
ADDING: res/drawable/notification_bg.xml
ADDING: res/drawable/notification_bg_low.xml
ADDING: res/drawable/notification_icon_background.xml
ADDING: res/drawable/notification_tile_bg.xml
ADDING: res/layout-v16/notification_template_custom_big.xml
ADDING: res/layout-v21/notification_action.xml
ADDING: res/layout-v21/notification_action_tombstone.xml
ADDING: res/layout-v21/notification_template_custom_big.xml
ADDING: res/layout-v21/notification_template_icon_group.xml
ADDING: res/layout/downloading_expansion.xml
ADDING: res/layout/notification_action.xml
ADDING: res/layout/notification_action_tombstone.xml
ADDING: res/layout/notification_template_icon_group.xml
ADDING: res/layout/notification_template_part_chronometer.xml
ADDING: res/layout/notification_template_part_time.xml
ADDING: res/layout/status_bar_ongoing_event_progress_bar.xml
ADDING: res/mipmap-anydpi-v26/icon.xml
ADDING: res/mipmap-hdpi-v4/icon.png
ADDING: res/mipmap-hdpi-v4/icon_background.png
ADDING: res/mipmap-hdpi-v4/icon_foreground.png
ADDING: res/mipmap-mdpi-v4/icon.png
ADDING: res/mipmap-mdpi-v4/icon_background.png
ADDING: res/mipmap-mdpi-v4/icon_foreground.png
ADDING: res/mipmap-xhdpi-v4/icon.png
ADDING: res/mipmap-xhdpi-v4/icon_background.png
ADDING: res/mipmap-xhdpi-v4/icon_foreground.png
ADDING: res/mipmap-xxhdpi-v4/icon.png
ADDING: res/mipmap-xxhdpi-v4/icon_background.png
ADDING: res/mipmap-xxhdpi-v4/icon_foreground.png
ADDING: res/mipmap-xxxhdpi-v4/icon.png
ADDING: res/mipmap-xxxhdpi-v4/icon_background.png
ADDING: res/mipmap-xxxhdpi-v4/icon_foreground.png
ADDING: res/mipmap/icon.png
ADDING: res/mipmap/icon_background.png
ADDING: res/mipmap/icon_foreground.png
Unicode error: invalid skip
Unicode error: invalid skip
Unicode error: invalid skip
Unicode error: invalid skip
Unicode error: invalid skip
Unicode error: no space left
ADDING: resources.arsc
0 param: --xr_mode_regular
1 param: --use_depth_32
2 param: --use_immersive
   adding: META-INF/MANIFEST.MF
   adding: META-INF/ANDROIDD.SF
   adding: META-INF/ANDROIDD.RSA
  signing: AndroidManifest.xml
  signing: classes.dex
  signing: lib/arm64-v8a/libMonoPosixHelper.so
  signing: lib/arm64-v8a/libMonoSupportW.so
  signing: lib/arm64-v8a/libc++_shared.so
  signing: lib/arm64-v8a/libgodot_android.so
  signing: lib/arm64-v8a/libmono-btls-shared.so
  signing: lib/arm64-v8a/libmono-ee-interp.so
  signing: lib/arm64-v8a/libmono-native.so
  signing: lib/arm64-v8a/libmono-profiler-aot.so
  signing: lib/arm64-v8a/libmono-profiler-coverage.so
  signing: lib/arm64-v8a/libmono-profiler-log.so
  signing: lib/arm64-v8a/libmonosgen-2.0.so
  signing: lib/armeabi-v7a/libMonoPosixHelper.so
  signing: lib/armeabi-v7a/libMonoSupportW.so
  signing: lib/armeabi-v7a/libc++_shared.so
  signing: lib/armeabi-v7a/libgodot_android.so
  signing: lib/armeabi-v7a/libmono-btls-shared.so
  signing: lib/armeabi-v7a/libmono-ee-interp.so
  signing: lib/armeabi-v7a/libmono-native.so
  signing: lib/armeabi-v7a/libmono-profiler-aot.so
  signing: lib/armeabi-v7a/libmono-profiler-coverage.so
  signing: lib/armeabi-v7a/libmono-profiler-log.so
  signing: lib/armeabi-v7a/libmonosgen-2.0.so
  signing: res/drawable-hdpi-v4/notification_bg_low_normal.9.png
  signing: res/drawable-hdpi-v4/notification_bg_low_pressed.9.png
  signing: res/drawable-hdpi-v4/notification_bg_normal.9.png
  signing: res/drawable-hdpi-v4/notification_bg_normal_pressed.9.png
  signing: res/drawable-hdpi-v4/notify_panel_notification_icon_bg.png
  signing: res/drawable-mdpi-v4/notification_bg_low_normal.9.png
  signing: res/drawable-mdpi-v4/notification_bg_low_pressed.9.png
  signing: res/drawable-mdpi-v4/notification_bg_normal.9.png
  signing: res/drawable-mdpi-v4/notification_bg_normal_pressed.9.png
  signing: res/drawable-mdpi-v4/notify_panel_notification_icon_bg.png
  signing: res/drawable-v21/notification_action_background.xml
  signing: res/drawable-xhdpi-v4/notification_bg_low_normal.9.png
  signing: res/drawable-xhdpi-v4/notification_bg_low_pressed.9.png
  signing: res/drawable-xhdpi-v4/notification_bg_normal.9.png
  signing: res/drawable-xhdpi-v4/notification_bg_normal_pressed.9.png
  signing: res/drawable-xhdpi-v4/notify_panel_notification_icon_bg.png
  signing: res/drawable-xxhdpi-v4/notify_panel_notification_icon_bg.png
  signing: res/drawable/notification_bg.xml
  signing: res/drawable/notification_bg_low.xml
  signing: res/drawable/notification_icon_background.xml
  signing: res/drawable/notification_tile_bg.xml
  signing: res/layout-v16/notification_template_custom_big.xml
  signing: res/layout-v21/notification_action.xml
  signing: res/layout-v21/notification_action_tombstone.xml
  signing: res/layout-v21/notification_template_custom_big.xml
  signing: res/layout-v21/notification_template_icon_group.xml
  signing: res/layout/downloading_expansion.xml
  signing: res/layout/notification_action.xml
  signing: res/layout/notification_action_tombstone.xml
  signing: res/layout/notification_template_icon_group.xml
  signing: res/layout/notification_template_part_chronometer.xml
  signing: res/layout/notification_template_part_time.xml
  signing: res/layout/status_bar_ongoing_event_progress_bar.xml
  signing: res/mipmap-anydpi-v26/icon.xml
  signing: res/mipmap-hdpi-v4/icon.png
  signing: res/mipmap-hdpi-v4/icon_background.png
  signing: res/mipmap-hdpi-v4/icon_foreground.png
  signing: res/mipmap-mdpi-v4/icon.png
  signing: res/mipmap-mdpi-v4/icon_background.png
  signing: res/mipmap-mdpi-v4/icon_foreground.png
  signing: res/mipmap-xhdpi-v4/icon.png
  signing: res/mipmap-xhdpi-v4/icon_background.png
  signing: res/mipmap-xhdpi-v4/icon_foreground.png
  signing: res/mipmap-xxhdpi-v4/icon.png
  signing: res/mipmap-xxhdpi-v4/icon_background.png
  signing: res/mipmap-xxhdpi-v4/icon_foreground.png
  signing: res/mipmap-xxxhdpi-v4/icon.png
  signing: res/mipmap-xxxhdpi-v4/icon_background.png
  signing: res/mipmap-xxxhdpi-v4/icon_foreground.png
  signing: res/mipmap/icon.png
  signing: res/mipmap/icon_background.png
  signing: res/mipmap/icon_foreground.png
  signing: resources.arsc
  signing: assets/.mono/metadata/scripts_metadata.debug
  signing: assets/.mono/assemblies/Debug/MyGame.dll
  signing: assets/.mono/assemblies/Debug/Mono.Android.dll
  signing: assets/.mono/assemblies/Debug/mscorlib.dll
  signing: assets/.mono/assemblies/Debug/TinyIoC.dll
  signing: assets/.mono/assemblies/Debug/System.Core.dll
  signing: assets/.mono/assemblies/Debug/System.dll
  signing: assets/.mono/assemblies/Debug/Mono.Security.dll
  signing: assets/.mono/assemblies/Debug/System.Xml.dll
  signing: assets/.mono/assemblies/Debug/System.Numerics.dll
  signing: assets/.mono/assemblies/Debug/GodotSharp.dll
  signing: assets/.mono/assemblies/Debug/I18N.dll
  signing: assets/.mono/assemblies/Debug/I18N.CJK.dll
  signing: assets/.mono/assemblies/Debug/I18N.MidEast.dll
  signing: assets/.mono/assemblies/Debug/I18N.Other.dll
  signing: assets/.mono/assemblies/Debug/I18N.Rare.dll
  signing: assets/.mono/assemblies/Debug/I18N.West.dll

>> Goes on to sign all my .cs etc files here

So the first thing of interest is probably:

ERROR: reload: Condition "!obj_type" is true. Returned: ERR_BUG
   At: modules/mono/csharp_script.cpp:3187.

That's before the msbuild (which succeeds in the end)

And then:

ERROR: get_assembly_dependencies: Cannot load assembly (refonly): 'System.Threading.Tasks.Dataflow'.
   At: modules/mono/editor/godotsharp_export.cpp:93.

Which happens as the APK export starts. Now that library is there (from nuget) and available for net461, netstandard1.0, netstandard1.1, netstandard2.0 and portable-net45+win8+wpa81

After that error nothing else is added.

I am going to try and remove that library but my guess is that it will then just bump into the next issue

timothyparez commented 4 years ago

When I posted this earlier on, it was also throwing an exception because I included TinyIoC.cs directly into the project. While exporting the APK it would complain about the namespace and then stop processing further dependencies.

So after compiling TinyIoC into a separate assembly and removing System.Threading.Tasks.Dataflow the APK is built without errors and includes all the other libraries:

image

I guess this splits into 2 issues then.

  1. If there is a problem with the referenced assemblies the produced APK is broken
  2. For some reason I cannot reference System.Threading.Tasks.Dataflow even though it targets multiple frameworks and works just fine with Mono on Linux (on both x64 and arm architectures)
p1gd0g commented 5 months ago

Same here, godot 3.5.3 mono, win11. Resolved by mv .dll file manually.