Building Android With "Unable to find keystore alias" Error

#1

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.

0 Likes

#2

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:

0 Likes

#3

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

0 Likes

#4

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?

0 Likes

#5

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.

0 Likes

#6

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

#7

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

0 Likes

#8

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

2 Likes