+1 vote

I followed the documentation: https://docs.godotengine.org/en/stable/development/compiling/compiling_with_script_encryption_key.html

Problem: I want to export for android with script encryption. I get same errors as on this page. ERROR: open_and_parse: Condition [...bla bla...] on Android.

Godot version: 3.2.4.beta1

Windows 10


Exact steps I did:

  • Created a key with openssl.
  • Set set SCRIPT_AES256_ENCRYPTION_KEY=your_generated_key
  • Executed following commands:

scons -j 6 platform=android target=release android_arch=armv7
scons -j 6 platform=android target=release android_arch=arm64v8
cd platform/android/java
.\gradlew generateGodotTemplates

Copied the bin/android_release.apk to %appdata%\Roaming\Godot\templates\3.2.4.beta1\

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

Copied the bin/android_debug.apk to %appdata%\Roaming\Godot\templates\3.2.4.beta1\

In Godot:

  • Under android export > script, I set the key in the input field and
    set export mode to encrypted.
  • Under android export > options > Custom Template, I set the debug and
    release accordingly to C:/godot/bin/android_debug.apk and C:/godot/bin/android_release.apk

Then exported to android (and it crashes right after starting the game, it flickers a bit and then crashes). Adb logcat shows same errors as here. Note: it does not crash when exporting normally. Any help?

On the same link (top of the page), it says: Godot is encrypting the scripts during export, but can't read them at runtime. Well, what should I do?

in Engine by (84 points)

I'm quite unfamiliar with this process, but looking over your steps....

I see that you built the Godot export templates (presumably with your encryption key) and copied them to, for example, %appdata%\Roaming\Godot\templates\3.2.4.beta1\.

However, later, in Godot, you specified your custom template to be within C:/godot/bin/.

That doesn't seem right. Shouldn't that point to the custom templates you built?

Hi. Since the compiled templates are the same as the one that I copied to %appdata%\Roaming\Godot\templates\3.2.4.beta1\ it does not make a difference (both files are the same). This is mentioned here too.

You don't even need to copy them, you can just reference the resulting file in the bin\ directory of your Godot source folder, so that the next time you build you will automatically have the custom templates referenced.

Again, I'm not familiar with this, but... I feel like the ones you compiled are different in that they include your encryption key. Just as a test, what happens if you point to the ones you compiled instead?

But, yeah, I see what you mean with your docs reference. It does sound like it's not necessary to point to the custom files, but since it doesn't attempt to explain the magic that makes that auto-referencing mechanism work, I'm skeptical - especially since your problem is caused by not having your key properly included...

Do you mean like this? https://imgur.com/PQH3BLZ
If you meant like this, it unfortunately did not change anything. Leaving these empty also does not solve the problem.

I was suggesting that you set those two values to the templates you complied. So, set them to the 2 files you copied into %appdata%\Roaming\Godot\templates\3.2.4.beta1\

I see. It unfortunately did not work. I set them like this:

C:/Users/###/AppData/Roaming/Godot/templates/3.2.4.beta1/android_debug.apk

C:/Users/###AppData/Roaming/Godot/templates/3.2.4.beta1/android_release.apk

I feel like I tried almost everything. I know you're not very familiar with this, but if you do know about this, could the problem be eventually this line... set SCRIPT_AES256_ENCRYPTION_KEY=your_generated_key
I set this in the terminal before running the scons commands.

To be precise, when you set that environment variable, I assume you replaced the your_generated_key string with the actual key you generated, right?

Correct. I was just wondering if this should be done in the terminal or somewhere else. But i guess its in the terminal inside the godot source folder.

Again, just guessing... But, I assume setting it the terminal you ran all of the build commands from is exactly right. I assume the build uses that specific variable to access your custom key during the build process...

After setting the variable in a command terminal, it should be available to any process that's started from that same terminal. However, if you ran any of the commands from a different command terminal (or ran any commands before setting the variable), the encryption key would not have been available to those processes...

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.