Is it possible to encrypt .aab file (Android export)?

Godot Version

4.2

Question

Hi everyone, how are you?

My question is related to exporting for Android.

According to the official documentation, you need to enable APK Expansion to export your project without leaving it so exposed.

The steps described in the said documentation lead you to this error:

Since you can only submit .aab files to Play Store now, I wonder if it’s possible to export a project with some kind of encryption and send it to Play Store.

Actually, the thing I wanted the most is that Godot had some sort of encrypted environment variables by default, so that you could store your API keys in a safer way.

Of course, I’m aware that nothing can be 100% safe and that’s not the problem here. The point is that some data is more sensitive than other, and shouldn’t be so easy to get access to.

Thanks in advance, guys.

This isn’t currently implemented, but support for AAB encryption is being implemented in https://github.com/godotengine/godot/pull/76161.

Actually, the thing I wanted the most is that Godot had some sort of encrypted environment variables by default, so that you could store your API keys in a safer way.

Yes: Exporting for Android — Godot Engine (stable) documentation in English

Thank you very much for the answer.

I’m looking forward for this feature to be implemented.

Regarding the environment variables I mentioned earlier, I’m sorry for not being so clear.

I meant something like Vercel offers you, where you have the option to set your own environment variables and then use them in your code.

For example, you would set the environment variable “API_KEY” and then use it like this:

$HTTPRequest.request(url + “?api_key=” + str(GODOT_API_KEY))

With these values being encrypted by default, it would be a simple way to achieve the intented purpose, and you could even share your code without having to ommit the sensitive data.

To get an environment variable’s value in a script, use the OS.get_environment() method.

Thank you, this is really interesting, but do you need a specific setting to be able to read environment variables from the OS?

On Windows, I’ve set the following environment variables:

set GODOT_ANDROID_KEYSTORE_DEBUG_USER=test_user
set GODOT_ANDROID_KEYSTORE_DEBUG_PASSWORD=test_password

Then I checked if the values were applied:

echo %GODOT_ANDROID_KEYSTORE_DEBUG_USER%
echo %GODOT_ANDROID_KEYSTORE_DEBUG_PASSWORD%

In my game’s script, I added the following code:

print(OS.has_environment(“GODOT_ANDROID_KEYSTORE_DEBUG_USER”))
print(OS.has_environment(“GODOT_ANDROID_KEYSTORE_DEBUG_PASSWORD”))

Both returned false, so I wonder if there’s something I’m missing here.

Never mind, it was my mistake.

The solution I found is to make the environment variables permanent:

setx GODOT_ANDROID_KEYSTORE_DEBUG_USER test_user
setx GODOT_ANDROID_KEYSTORE_DEBUG_PASSWORD test_password

And then relaunching Godot Engine.

Thank you very much for your assistance.