Building Android With "Unable to find keystore alias" Error

While reading the manual, I created the keystore file and set it as a build target.

image

And when I run the build Android build I get an “Unable to find keystore alias” error. I would like to know where I should fix it.apk,aab builds both have the same result.

I saw the error on Windows 10 and the Defold Engine version is 1.2.174.

Which alias did you set when you created the keystore?

You can check the contents of your keystore using the commandline (requires Java and the keytool command on the path):

keytool -v -list -keystore my.keystore

This should show something like this:

$ > keytool -v -list -keystore defold.keystore

Enter keystore password:  
Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: defold
Creation date: 24 Aug 2020
Entry type: PrivateKeyEntry
Certificate chain length: 1
.
.
.

If you bundle with bob.jar it’s possible to specify the keystore alias to use like this:

java -jar bob.jar --keystore=my.keystore --keystore-alias=myalias --keystore-pass=password.txt ...

When bundling from the editor or if you don’t provide a keystore alias the bundler code will list the aliases and use the first encountered alias:

I executed the command you gave me.

C:\Users\stepi\Downloads\Mobile game>keytool -v -list -keystore mykeystore.keystore
Enter keystore password:  
Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: myalias
Creation date: 10/13/2020
Entry type: PrivateKeyEntry
Certificate chain length: 1

We have created a keystore with the same parameters as the example in the manual.

keytool -genkey -v -noprompt -dname "CN=John Smith, OU=Area 51, O=US Air Force, L=Unknown, ST=Nevada, C=US" -keystore mykeystore.keystore -storepass 5Up3r_53cR3t -alias myAlias -keyalg RSA -validity 9125

The error occurred when bundling from the editor.Maybe you need JDK11?
The keytool is used from the Engine.

image

No we bundle JDK 11 with the editor. What if you check the editor log? Help->Show Logs and open the most recent log file. You should see something like:

020-10-14 14:36:44.049 4042933 [clojure-agent-send-off-pool-18] INFO c.dynamo.bob.bundle.AndroidBundler - exec: /Applications/Defold.app/Contents/Resources/packages/jdk11.0.1-p1/bin/keytool -list -keystore /Users/bjornritzl/projects/certificates-defold/android/defold.keystore -storepass PASSWORD -rfc

Try running that exact command line from a prompt:

/Applications/Defold.app/Contents/Resources/packages/jdk11.0.1-p1/bin/keytool -list -keystore /Users/bjornritzl/projects/certificates-defold/android/defold.keystore -storepass PASSWORD -rfc

Does it successfully show the contents of the keystore?

The Editor’s build log stopped here.

2020-10-14 21:52:16.663 258055 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Compiling resources from C:\Users\stepi\Project\_output\armv7-android\test\res
2020-10-14 21:52:16.664 258056 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - exec: C:\Users\stepi\AppData\Local\Temp\2576689812470960856\x86_64-win32\aapt2.exe compile -o C:\Users\stepi\AppData\Local\Temp\compiled_resources16179957321117349054\com.defold.android --dir C:\Users\stepi\Project\_output\armv7-android\test\res\com.defold.android
2020-10-14 21:52:16.743 258135 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - exec: C:\Users\stepi\AppData\Local\Temp\2576689812470960856\x86_64-win32\aapt2.exe compile -o C:\Users\stepi\AppData\Local\Temp\compiled_resources16179957321117349054\com.example.todo --dir C:\Users\stepi\Project\_output\armv7-android\test\res\com.example.todo
2020-10-14 21:52:16.792 258184 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Linking resources from C:\Users\stepi\AppData\Local\Temp\compiled_resources16179957321117349054
2020-10-14 21:52:16.795 258187 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - exec: C:\Users\stepi\AppData\Local\Temp\2576689812470960856\x86_64-win32\aapt2.exe link --proto-format -o C:\Users\stepi\Project\_output\armv7-android\test\aab\aapt2\apk\output.apk -I C:\Users\stepi\AppData\Local\Temp\2576689812470960856\lib\android.jar --manifest C:\Users\stepi\Project\_output\armv7-android\test\AndroidManifest.xml --auto-add-overlay -R @C:\Users\stepi\Project\_output\armv7-android\test\aab\compiled_resources.txt
2020-10-14 21:52:17.085 258477 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Creating AAB base.zip
2020-10-14 21:52:17.103 258495 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Copying dex to C:\Users\stepi\AppData\Local\Temp\2576689812470960856\lib\classes.dex
2020-10-14 21:52:17.114 258506 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Copying asset to C:\Users\stepi\Project\_output\armv7-android\test\aab\base\assets\game.projectc
2020-10-14 21:52:17.124 258516 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Copying asset to C:\Users\stepi\Project\_output\armv7-android\test\aab\base\assets\game.arci
2020-10-14 21:52:17.127 258519 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Copying asset to C:\Users\stepi\Project\_output\armv7-android\test\aab\base\assets\game.arcd
2020-10-14 21:52:17.138 258530 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Copying asset to C:\Users\stepi\Project\_output\armv7-android\test\aab\base\assets\game.dmanifest
2020-10-14 21:52:17.141 258533 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Copying asset to C:\Users\stepi\Project\_output\armv7-android\test\aab\base\assets\game.public.der
2020-10-14 21:52:17.143 258535 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Copying resources to C:\Users\stepi\Project\_output\armv7-android\test\aab\base\res
2020-10-14 21:52:17.159 258551 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Copying engine to C:\Users\stepi\Project\_output\armv7-android\test\aab\base\lib\armeabi-v7a\libtest.so
2020-10-14 21:52:17.165 258557 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - exec: C:\Users\stepi\AppData\Local\Temp\2576689812470960856\x86_64-win32\strip_android.exe C:\Users\stepi\Project\_output\armv7-android\test\aab\base\lib\armeabi-v7a\libtest.so
2020-10-14 21:52:17.229 258621 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Copying engine to C:\Users\stepi\Project\_output\armv7-android\test\aab\base\lib\arm64-v8a\libtest.so
2020-10-14 21:52:17.236 258628 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - exec: C:\Users\stepi\AppData\Local\Temp\2576689812470960856\x86_64-win32\strip_android_aarch64.exe C:\Users\stepi\Project\_output\armv7-android\test\aab\base\lib\arm64-v8a\libtest.so
2020-10-14 21:52:17.297 258689 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Zipping C:\Users\stepi\Project\_output\armv7-android\test\aab\base to C:\Users\stepi\Project\_output\armv7-android\test\aab\base.zip
2020-10-14 21:52:17.841 259233 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Creating Android Application Bundle
2020-10-14 21:52:17.842 259234 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - exec: C:\Users\stepi\Project\Defold Projects\Defold-x86_64-win32\Defold\packages\jdk11.0.1-p1\bin\java -jar C:\Users\stepi\AppData\Local\Temp\2576689812470960856\bundletool-all.jar build-bundle --modules C:\Users\stepi\Project\_output\armv7-android\test\aab\base.zip --output C:\Users\stepi\Project\_output\armv7-android\test\test.aab
2020-10-14 21:52:19.520 260912 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - Sign C:\Users\stepi\Project\_output\armv7-android\test\test.aab
2020-10-14 21:52:19.520 260912 [clojure-agent-send-off-pool-24] INFO  c.dynamo.bob.bundle.AndroidBundler - exec: C:\Users\stepi\Project\Defold Projects\Defold-x86_64-win32\Defold\packages\jdk11.0.1-p1\bin\keytool -list -keystore C:\Users\stepi\Project\Defold Projects\test\test\mykeystore.keystore -storepass 5Up3r_53cR3t -rfc

When run on the command line, the contents of the keystore appear to be correct.

Ah, the returned information has labels in Japanese. And that will not work since the code is looking for the string “Alias name”. I’ve created a ticket (https://github.com/defold/defold/issues/5273) to track this issue and will try to include a fix in the next release.

You can work around the problem by bundling using bob.jar (download from d.defold.com) and specifying the alias:

java -jar bob.jar -v --archive --platform=armv7-android --bundle-format=apk --keystore=my.keystore --keystore-pass=keystore-password.txt --keystore-alias=myalias build bundle
1 Like

Thank you! I’m happy to see that this will be resolved in the next release.

I have a PR ready for review: https://github.com/defold/defold/pull/5277

2 Likes

still the same error. Any solution ?

  • Windows 8.1
  • Java version 1.8.0_261

All known issues with keystore builds have been resolved as far as I know. The only problem we have is if you use different passwords for the keystore and the key. This will be solved in 1.2.182.

Can you please share the steps you have done and the error you are getting? Include as much info as possible (https://defold.com/manuals/getting-help/#required-information).

Problem is, when i saved my password.txt file UTF-8 format. (Project->Bundle->Android Application : Bundle format : APK “Unable to find keystore alias”)
But, if password.txt file ANSI format. "Failed creating universal APK"
Also Bundle format : AAB working well.

Used : Defold\packages\jdk11.0.1-p1\bin\keytool.exe

keytool -genkey -v -noprompt -dname “CN=John Smith, OU=Area 51, O=US Air Force, L=Unknown, ST=Nevada, C=US” -keystore mykeystore.keystore -storepass defold -alias myAlias -keyalg RSA -validity 9125

password.txt file
defold

Engine Version : 1.2.180

universal_apk_error.txt (5.4 KB)

Sorry for the very slow response here. We will change how the keystore password is used. We will pass the file with the password directly to the Android bundletool instead of loading it and then sending it. This will remove a source of potential encoding problems. This change is handled by this pull request which should end up in the next version of Defold:

1 Like

Hello guys, just run to this error (Unable to find keystore alias) in 188. I have created keystore with command from Defold development for the Android platform.
Log contains this:

2021-10-30 20:05:44.984 48003 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Creating AAB base.zip
2021-10-30 20:05:44.988 48007 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Using extender binary for architecture: armv7-android
2021-10-30 20:05:44.988 48007 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Using extender binary for architecture: arm64-android
2021-10-30 20:05:44.989 48008 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Copying dex to /Users/gudkov-m/project/sola-spaco-2/game/build/armv7-android/classes.dex
2021-10-30 20:05:45.021 48040 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Copying asset /Users/gudkov-m/project/sola-spaco-2/game/build/default/game.projectc to /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/assets/game.projectc
2021-10-30 20:05:45.022 48041 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Copying asset /Users/gudkov-m/project/sola-spaco-2/game/build/default/game.arci to /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/assets/game.arci
2021-10-30 20:05:45.023 48042 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Copying asset /Users/gudkov-m/project/sola-spaco-2/game/build/default/game.arcd to /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/assets/game.arcd
2021-10-30 20:05:45.025 48044 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Copying asset /Users/gudkov-m/project/sola-spaco-2/game/build/default/game.dmanifest to /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/assets/game.dmanifest
2021-10-30 20:05:45.025 48044 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Copying asset /Users/gudkov-m/project/sola-spaco-2/game/build/default/game.public.der to /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/assets/game.public.der
2021-10-30 20:05:45.026 48045 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Copying resources to /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/res
2021-10-30 20:05:45.029 48048 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Copying engine to /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/lib/armeabi-v7a/libUnboundBall.so
2021-10-30 20:05:45.052 48071 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - exec: /var/folders/d6/y7bbslgx5bb9_ctrmv_3hgqh0000gn/T/8575137655474031270/x86_64-darwin/strip_android /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/lib/armeabi-v7a/libUnboundBall.so
2021-10-30 20:05:45.251 48270 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Copying engine to /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/lib/arm64-v8a/libUnboundBall.so
2021-10-30 20:05:45.269 48288 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - exec: /var/folders/d6/y7bbslgx5bb9_ctrmv_3hgqh0000gn/T/8575137655474031270/x86_64-darwin/strip_android_aarch64 /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base/lib/arm64-v8a/libUnboundBall.so
2021-10-30 20:05:45.429 48448 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Zipping /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base to /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base.zip
2021-10-30 20:05:45.790 48809 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Creating Android Application Bundle
2021-10-30 20:05:45.967 48986 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - exec: /Applications/Defold.app/Contents/Resources/packages/jdk11.0.1-p1/bin/java -jar /var/folders/d6/y7bbslgx5bb9_ctrmv_3hgqh0000gn/T/8575137655474031270/bundletool-all.jar build-bundle --modules /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/aab/base.zip --output /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/UnboundBall.aab
2021-10-30 20:05:46.989 50008 [clojure-agent-send-off-pool-11] INFO c.dynamo.bob.bundle.AndroidBundler - Sign /Users/gudkov-m/project/sola-spaco-2/bundle/armv7-android/UnboundBall/UnboundBall.aab

keystore.zip (3.0 KB)

Screenshot 2021-10-30 at 20.12.35

Ok, I check the keystore aliases using this command:

keytool -v -list -keystore mykeystore.keystore

I get the following error:

keytool error: java.io.IOException: Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available
java.io.IOException: Integrity check failed: java.security.NoSuchAlgorithmException: Algorithm HmacPBESHA256 not available

So it seems like the keystore isn’t using an algorithm known to the Java version in the editor or the one I have (JDK11). Which version of Java are you using?

I just run keytool from terminal, java version probably this

openjdk 16.0.1 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)

I have tried keytool from defold install directory and now all works fine. Thanks for help!

Yeah, this is probably the problem. I have OpenJDK 11 installed (because it’s what we use in Defold).

With new defold updates is fixed the problem, thank you defold team.