godotengine / godot

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

Exporting to android now fails with error code 20 #35600

Open Myran opened 4 years ago

Myran commented 4 years ago

Godot version: 72c44bafac6e280b5e1e99b417588624bfb5ecc6

OS/device including version: MacOS 10.15.12

Issue description: When compiling from 72c44bafac6e280b5e1e99b417588624bfb5ecc6 my android export is now broken where it was successful before.

when using a custom build I get this:

arguments
0: ./editor/godot.osx.opt.tools.64
1: --path
2: project
3: --export
4: android
5: ../export/android/GameOne.apk
Current path: /Users/mattiasmyhrman/Repositories/gameone
Godot Engine v3.2.rc.custom_build.7617336d7 - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce GTX 775M OpenGL Engine

Registered camera FaceTime HD Camera (Built-in) with id 1 position 0 at index 0
export: begin: Exporting for Android steps: 105
export: end
ERROR: _fs_changed: Project export failed with error code 20 for preset 'android'.
   At: editor/editor_node.cpp:634.

When not using a custom build it exports successfully however when pushing to device I get

adb: failed to install export/android/GameOne.apk: Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
Starting: Intent { act=android.intent.action.MAIN cmp=org.godotengine.gameone/com.godot.game.GodotApp }
Error type 3
Error: Activity class {org.godotengine.gameone/com.godot.game.GodotApp} does not exist.

Both of these were working in rc1 IIRC so something seems to have happened with the manifest regeneration(?)

akien-mga commented 4 years ago

Did you reinstall the Android source template matching the commit that you built?

Myran commented 4 years ago

Indeed there must have been some mixup when I tried different versions. I am currently trying to sort out a CI / CD system for iOS and android which is a bit of a challenge.

Trying to install the source template failed silently in editor due to the android_source.zip file from the CI being corrupt. Maybe a popup warning on failure in editor and not only in terminal could be beneficial?

Side note: it would be great to be able to install the source template from command line, otherwise its not possible to do CD for android right now as I understand it.

Calinou commented 4 years ago

Side note: it would be great to be able to install the source template from command line, otherwise its not possible to do CD for android right now as I understand it.

I think it's a matter of installing it to $HOME/.local/share/godot/templates/<version>/android_source.zip, where <version> is the version identifier like 3.1.2.stable (create folders if needed).

Myran commented 4 years ago

Side note: it would be great to be able to install the source template from command line, otherwise its not possible to do CD for android right now as I understand it.

I think it's a matter of installing it to $HOME/.local/share/godot/templates/<version>/android_source.zip, where <version> is the version identifier like 3.1.2.stable (create folders if needed).

Thats correct however there is also the requirement to manually install the android build template through the projects menu. This seems to lack support from command line.

Doing some more research to circumvent this I setup the custom template paths and made a script that unzips the android_sourze.zip to android/build folder and this successfully circumvent the problem.

However the export error checking still requires android_source.zip in the template folder even when its already installed correctly. This should probably be corrected.

Calinou commented 4 years ago

@Myran Maybe we could add an --install-export-template <file> command-line argument that installs a TPZ file or Android source ZIP in the right location. This way, the user doesn't need to know in advance the version identifier to use. This means you'd have to run the Godot headless binary twice in CI environments, but it's probably not an issue.

Myran commented 4 years ago

@Myran Maybe we could add an --install-export-template <file> command-line argument that installs a TPZ file or Android source ZIP in the right location. This way, the user doesn't need to know in advance the version identifier to use. This means you'd have to run the Godot headless binary twice in CI environments, but it's probably not an issue.

That would would be perfect, thanks! :)

requizm commented 3 years ago

I get same error on Github CI with Ubuntu 20.04

Windows, linux, macos and web build perfectly fine. But i can't build android debug. I tried extracting the android_source.zip file to a folder called android_source but nothing changed.

Calinou commented 3 years ago

I tried extracting the android_source.zip file to a folder called android_source but nothing changed.

It should be extracted to a folder called android in the project root (its path would then be res://android). See also https://github.com/godotengine/godot-proposals/issues/3128.

requizm commented 3 years ago

I tried extracting the android_source.zip file to a folder called android_source but nothing changed.

It should be extracted to a folder called android in the project root (its path would then be res://android). See also godotengine/godot-proposals#3128.

I have android folder in res://

Btw local build working fine. I can build with my Windows 10, Godot 3.3.2-mono.stable

But i can't build on Github CI, Ubuntu 20.04, Godot 3.3.2-mono.stable

Maybe i should make something like this: gradlew zipCustomBuild But i don't know how

AdrKacz commented 1 year ago

@Calinou do you have any updates regarding:

@Myran Maybe we could add an --install-export-template command-line argument that installs a TPZ file or Android source ZIP in the right location. This way, the user doesn't need to know in advance the version identifier to use. This means you'd have to run the Godot headless binary twice in CI environments, but it's probably not an issue.

If not, do you have a script that can install the templates correctly that I can run in CI/CD? I did the following which didn't succeed:

curl -LO ${GODOT_TEMPLATES_URL} && unzip Godot_v${GODOT_VERSION}-stable_export_templates.tpz
mkdir -p "${GODOT_TEMPLATES_DIR}" && mv templates "${GODOT_TEMPLATES_DIR}/${GODOT_VERSION}.stable"
Calinou commented 1 year ago

@Calinou do you have any updates regarding:

@Myran Maybe we could add an --install-export-template command-line argument that installs a TPZ file or Android source ZIP in the right location. This way, the user doesn't need to know in advance the version identifier to use. This means you'd have to run the Godot headless binary twice in CI environments, but it's probably not an issue.

See https://github.com/godotengine/godot-proposals/issues/1277. Nobody is currently working on implementing this feature, but pull requests are welcome :slightly_smiling_face:

akien-mga commented 1 year ago

See also #50264.

Myran commented 1 year ago

@Calinou do you have any updates regarding:

@Myran Maybe we could add an --install-export-template command-line argument that installs a TPZ file or Android source ZIP in the right location. This way, the user doesn't need to know in advance the version identifier to use. This means you'd have to run the Godot headless binary twice in CI environments, but it's probably not an issue.

If not, do you have a script that can install the templates correctly that I can run in CI/CD? I did the following which didn't succeed:

curl -LO ${GODOT_TEMPLATES_URL} && unzip Godot_v${GODOT_VERSION}-stable_export_templates.tpz
mkdir -p "${GODOT_TEMPLATES_DIR}" && mv templates "${GODOT_TEMPLATES_DIR}/${GODOT_VERSION}.stable"

Havent looked at this repo in a while and went digging. Its rough around the edges but it worked AFAIK. At this point the details are very hazy unfortunately..

Building the android export based on custom godot version (3.2 somewhere IIRC) using this script:

cd godot-myran

scons platform=android target=release_debug android_arch=armv7 --jobs=$(sysctl -n hw.logicalcpu) # module_bmp_enabled=no module_bullet_enabled=no module_csg_enabled=no module_dds_enabled=no module_enet_enabled=no module_etc_enabled=no module_gdnative_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_mbedtls_enabled=yes module_mobile_vr_enabled=no module_opus_enabled=no module_pvr_enabled=no module_recast_enabled=no module_regex_enabled=no module_squish_enabled=no module_tga_enabled=no module_thekla_unwrap_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_vorbis_enabled=no module_webm_enabled=no module_websocket_enabled=no disable_advanced_gui=no disable_3d=yes optimize=size use_lto=yes
scons platform=android target=release_debug android_arch=arm64v8 --jobs=$(sysctl -n hw.logicalcpu) # module_bmp_enabled=no module_bullet_enabled=no module_csg_enabled=no module_dds_enabled=no module_enet_enabled=no module_etc_enabled=no module_gdnative_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_mbedtls_enabled=yes module_mobile_vr_enabled=no module_opus_enabled=no module_pvr_enabled=no module_recast_enabled=no module_regex_enabled=no module_squish_enabled=no module_tga_enabled=no module_thekla_unwrap_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_vorbis_enabled=no module_webm_enabled=no module_websocket_enabled=no disable_advanced_gui=no disable_3d=yes optimize=size use_lto=yes
scons platform=android target=release android_arch=armv7 --jobs=$(sysctl -n hw.logicalcpu) module_bmp_enabled=no module_bullet_enabled=no module_csg_enabled=no module_dds_enabled=no module_enet_enabled=no module_etc_enabled=no module_gdnative_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_mbedtls_enabled=yes module_mobile_vr_enabled=no module_opus_enabled=no module_pvr_enabled=no module_recast_enabled=no module_regex_enabled=no module_squish_enabled=no module_tga_enabled=no module_thekla_unwrap_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_vorbis_enabled=no module_webm_enabled=no module_websocket_enabled=no disable_advanced_gui=no disable_3d=yes optimize=size use_lto=yes
scons platform=android target=release android_arch=arm64v8 --jobs=$(sysctl -n hw.logicalcpu) module_bmp_enabled=no module_bullet_enabled=no module_csg_enabled=no module_dds_enabled=no module_enet_enabled=no module_etc_enabled=no module_gdnative_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_mbedtls_enabled=yes module_mobile_vr_enabled=no module_opus_enabled=no module_pvr_enabled=no module_recast_enabled=no module_regex_enabled=no module_squish_enabled=no module_tga_enabled=no module_thekla_unwrap_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_vorbis_enabled=no module_webm_enabled=no module_websocket_enabled=no disable_advanced_gui=no disable_3d=yes optimize=size use_lto=yes

cd platform/android/java
./gradlew generateGodotTemplates
cd ../../../../

echo "Moving templates...."
mv godot-myran/bin/android_debug.apk templates/android_debug.apk
mv godot-myran/bin/android_release.apk templates/android_release.apk
mv godot-myran/bin/android_source.zip templates/android_source.zip

this is the android part in the gitlab CI which uses it.

.play_store_internal: &common_play_store_internal
  stage: deploy_tests
  variables:
   GIT_SUBMODULE_STRATEGY: none
  script:
  # test move
    - ./install_android_source.sh
    - ./firebase_install.sh
    - ./editor/godot.osx.opt.tools.64 --path project -s update_android_export_config.gd --no-window --export_android_version=$CI_PIPELINE_IID --keystore_release_path=$CI_PROJECT_DIR/keys/gameone.keystore --keystore_debug_path=$CI_PROJECT_DIR/keys/debug.keystore --template_release_path=$CI_PROJECT_DIR/templates/android_release.apk --template_debug_path=$CI_PROJECT_DIR/templates/android_debug.apk
    - find ~/.gradle -type f -name "*.lock" -delete
    - ./editor/godot.osx.opt.tools.64 --path project --debug --verbose --no-window --export android $CI_PROJECT_DIR/export/android/GameOne.apk
  # ---
    - cd export/android/
    - fastlane internal
    -

the script "install_android_source.sh" :

echo "installing android gradle for custom builds"
cd templates/
mkdir build
unzip -o android_source.zip -d build
rm -rf ../project/android/build
mv build ../project/android/
chmod +x ../project/android/build
cd ..
echo "Done!"
AdrKacz commented 1 year ago

Thank you for your advice @Myran, I had a look at what was inside the buildfolder and the difference between the once created from Godot UI.

I ended up having a script that works on my Macbook:

mkdir -p ./mobile-game/android/build/
mkdir -p ./mobile-game/android/plugins/
echo "${GODOT_VERSION}.stable" > ./mobile-game/android/.build_version
touch ./mobile-game/android/build/.gdignore
unzip "$GODOT_TEMPLATE_ANDROID" -d ./mobile-game/android/build/

Unfortunately, the script doesn't work on the cloud instance(same OS and environment), I'll double check tomorrow, please don't close as the problem might need another set of commands that would be useful in the future for reference 👍

For information, here is how the build fails in the cloud instance (not a very informative message..):

ERROR: Export: Building of Android project failed, check output for the error. Alternatively visit docs.godotengine.org for Android build documentation.

Let me know if you have already seen a similar error and know how to fix it 👍

For full context:

2023-06-20 21:07:05.671 godot[2575:13865] *** +[NSString stringWithUTF8String:]: NULL cString
Godot Engine v4.0.3.stable.official.5222a99f5 - https://godotengine.org

WARNING: Custom cursor shape not supported by this display server.
     at: cursor_set_custom_image (servers/display_server.cpp:480)
export: begin: Exporting for Android steps: 105
0 param: --xr_mode_regular
1 param: --use_immersive
ERROR: Export: Building of Android project failed, check output for the error. Alternatively visit docs.godotengine.org for Android build documentation.
   at: add_message (editor/export/editor_export_platform.h:173)
export: end
ERROR: Project export for preset "Android" failed.
   at: _fs_changed (editor/editor_node.cpp:1047)
ERROR: 26 RID allocations of type 'P11GodotBody2D' were leaked at exit.
ERROR: 8 RID allocations of type 'P11GodotArea2D' were leaked at exit.
ERROR: 6 RID allocations of type 'P12GodotShape2D' were leaked at exit.
ERROR: Condition "_first != nullptr" is true.
   at: ~List (./core/templates/self_list.h:106)
ERROR: 1023 RID allocations of type 'N18RendererCanvasCull4ItemE' were leaked at exit.
ERROR: 17 RID allocations of type 'N18RendererCanvasCull6CanvasE' were leaked at exit.
ERROR: 2 RID allocations of type 'N16RendererViewport8ViewportE' were leaked at exit.
ERROR: 40 RID allocations of type 'PN13RendererDummy14TextureStorage12DummyTextureE' were leaked at exit.
ERROR: 11 RID allocations of type 'N13RendererDummy11MeshStorage9DummyMeshE' were leaked at exit.
ERROR: 74 RID allocations of type 'PN18TextServerAdvanced22ShapedTextDataAdvancedE' were leaked at exit.
ERROR: 12 RID allocations of type 'PN18TextServerAdvanced12FontAdvancedE' were leaked at exit.
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:1982)
ERROR: Resources still in use at exit (run with --verbose for details).
   at: clear (core/io/resource.cpp:489)
Myran commented 1 year ago

[NSString stringWithUTF8String:]: NULL cString seems like an obj-c string issue, maybe some mixup between ios and android export? Without knowing any details Its not likely an android export problem. Try with an empty project in the CI to isolate

AdrKacz commented 1 year ago

Hello @Myran, so I tried to build with an empty project (just added an empty Node2D for the main).

As usual, no problem on my laptop, however, the build still fails on the Cloud, the error is very similar: 2023-06-24 14:56:53.990 godot[2643:20972] *** +[NSString stringWithUTF8String:]: NULL cString.

Thank you for suggesting this quick experiment. It now looks that the issue isn't introduce by my project and thus may affect multiple users.

However, I have no idea where to look at to fix it. Indeed, I don't understand why the build works fine on my laptop (MacOS), but not on the Cloud Machine (running also under MacOS) 🤔

Let me know if you have any idea?

For complete context:

$ godot --export-release "Android" ../exports/android/test-cicd.aab --headless

2023-06-24 14:56:53.990 godot[2643:20972] *** +[NSString stringWithUTF8String:]: NULL cString
Godot Engine v4.0.3.stable.official.5222a99f5 - https://godotengine.org

WARNING: Custom cursor shape not supported by this display server.
     at: cursor_set_custom_image (servers/display_server.cpp:480)
WARNING: Blend file import is enabled in the project settings, but no Blender path is configured in the editor settings. Blend files will not be imported.
     at: _editor_init (modules/gltf/register_types.cpp:70)
export: begin: Exporting for Android steps: 105
0 param: --xr_mode_regular
1 param: --use_immersive
2023-06-24 14:56:53.990 godot[2643:20972] *** +[NSString stringWithUTF8String:]: NULL cString
Godot Engine v4.0.3.stable.official.5222a99f5 - https://godotengine.org

WARNING: Custom cursor shape not supported by this display server.
     at: cursor_set_custom_image (servers/display_server.cpp:480)
WARNING: Blend file import is enabled in the project settings, but no Blender path is configured in the editor settings. Blend files will not be imported.
     at: _editor_init (modules/gltf/register_types.cpp:70)
export: begin: Exporting for Android steps: 105
0 param: --xr_mode_regular
1 param: --use_immersive
ERROR: Export: Building of Android project failed, check output for the error. Alternatively visit docs.godotengine.org for Android build documentation.
   at: add_message (editor/export/editor_export_platform.h:173)
export: end
ERROR: Project export for preset "Android" failed.
   at: _fs_changed (editor/editor_node.cpp:1047)
ERROR: 1 RID allocations of type 'N18RendererCanvasCull4ItemE' were leaked at exit.
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:1982)
AdrKacz commented 1 year ago

As the error seems quite low level, here is an information that might be useful:

  1. My laptop run on Intel Core i5 chip
  2. My CI/CD runs on M1 chip (I cannot change for Intel chips)

I am not aware of any problem with Godot and M1 chips, but you surely have more context than I do ☺️

AdrKacz commented 1 year ago

FYI, the same errors occurs when trying to build for iOS

AdrKacz commented 1 year ago

@Calinou do you have context regarding this error message? I checked online but didn't find relevant mention.

Myran commented 1 year ago

I havent tried godot 4 yet however it is a likely guess is the issue is part of ios interfacing code and start to look there, try to build the editor in CI to verify.