The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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: export SCRIPT_AES256_ENCRYPTION_KEY="generatedencryptionkey"
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
4. Run ./sdkmanager --sdk_root=<android_sdk_path> "platform-tools" "build-tools;30.0.3" "platforms;android-30" "cmdline-tools;latest" "cmake;3.10.2.4988404" "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 java --version
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: export ANDROID_SDK_ROOT="/home/user/Android/cmdline-tools"
10. Run the release/debug SCons commands:

scons platform=android target=release android_arch=armv7
scons platform=android target=release android_arch=arm64v8
cd platform/android/java
./gradlew generateGodotTemplates

scons platform=android target=release_debug android_arch=armv7
scons platform=android target=release_debug android_arch=arm64v8
cd platform/android/java
./gradlew generateGodotTemplates

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?

Godot version 3.4.2
in Engine by (97 points)
edited by

I think I have finally found a solution here: https://github.com/godotengine/godot/issues/43817#issuecomment-849141454

I am not sure if this will break compatibility with any plugins, but so far all of the ones I am using work.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.