I am using Godot 3.4.2 on Manjaro KDE. I have also tested Godot 3.3.4 and the same issue persists.
These are the steps I followed starting with: https://docs.godotengine.org/en/stable/development/compiling/compiling_with_script_encryption_key.html#step-by-step
1. Generate a 256bit AES key using the aes-256-cbc variant from https://asecuritysite.com/encryption/keygen
- The documentation specifies "a 256bit AES key in HEX", but only the Base-64 section of the keygen service has any output.
2. Set this key as environment variable with:
The documentation then says I need to "Compile Godot export templates and set them as custom export templates in the export preset options."
Next documentation link: https://docs.godotengine.org/en/stable/development/compiling/compiling_for_android.html
This page says "Also, you still need to follow the steps mentioned in the Exporting for Android tutorial before attempting to build a custom export template."
Next documentation link: https://docs.godotengine.org/en/stable/getting_started/workflow/export/exporting_for_android.html
3. Download Linux command-line tools from https://developer.android.com/studio/#command-tools
./sdkmanager --sdk_root=<android_sdk_path> "platform-tools" "build-tools;30.0.3" "platforms;android-30" "cmdline-tools;latest" "cmake;18.104.22.16888404" "ndk;21.4.7075529"
- The documentation says to install "platforms;android-29", but that needs to be changed to "platforms;android-30" to match the default compileSdk and targetSdk in a project's android/build/config.gradle file.
- This command is also very similar to the one present in: https://docs.godotengine.org/en/stable/development/compiling/compiling_for_android.html#setting-up-the-buildsystem. The only part that is omitted is the "ndk;21.4.7075529"
- This page also does not have the command
sdkmanager --sdk_root=<android_sdk_path> --licenses that is present on the compiling page. I am not sure if it is necessary to run the license command first, as the exporting page does not specify it. I figured it probably wouldn't hurt, so I ran the license command first.
5. Verify that openJDK 11 is installed with
6. Create a debug keystore with
keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 -deststoretype pkcs12
7. Set the Android SDK path and debug keystore information in the Editor Settings.
Going back to: https://docs.godotengine.org/en/stable/development/compiling/compiling_for_android.html#building-the-export-templates
8. Download Godot source code from https://github.com/godotengine/godot/releases to match my release, 3.4.2-stable.
9. Set the environment variable ANDROIDSDKROOT to point to the Android SDK:
10. Run the release/debug SCons commands:
scons platform=android target=release android_arch=armv7
scons platform=android target=release android_arch=arm64v8
scons platform=android target=release_debug android_arch=armv7
scons platform=android target=release_debug android_arch=arm64v8
1 1. Copy the templates to $HOME/.local/share/godot/templates//
- The documentation says "However, if you are writing your custom modules or custom C++ code, you might instead want to configure your APKs as custom export templates here: (in the editor)"
I am not sure why this would be specific to custom modules or custom C++ code and not other reasons to use a custom template (such as for encrypting scripts.)
But seeing as I am not using custom modules or custom C++ code in this test project, I will do the more difficult task of copying the export templates to a hidden folder rather than linking to them in the editor.
12. Set the encryption key in the Script tab of the export preset.
13. Export with any arbitrary script.
- If custom build is enabled, the game crashes.
- If custom build is disabled, the game runs as normal.
Does anyone know what could be causing this? Has anyone successfully exported to Android with custom build and encrypted scripts enabled?