Android export: `'apksigner' returned with error #1` and `error #2` ("debug.keystore" does not contain a key)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gdough


I need help with being able to export to Android using Godot 3.5. The error I’m receiving is:'apksigner' returned with error #1 (and also error #2). I’m currently testing with an empty project to rule out my project being what’s bugged.

I’ve followed the Exporting for Android instructions on Godot Docs v3.5:

  • Installed OpenJDK 11 (the JAVA_HOME System environment variable is correctly set, and Open JDK 11’s /bin directory is also in the System’s Path variable). java --version gives “openjdk 11.0.2 2019-01-15, OpenJDK Runtime Environment 18.9 (build 11.0.2+9), OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)”.
  • Downloaded Android’s command line tools and run the sdkmanager setup command
  • Created a debug.keystore file using keytool (the OpenJDK 11 version) as shown
  • Pointed Godot to both the debug.keystore file and Android’s SDK directory.
  • I’ve not tried is installing Android Studio because it shouldn’t be needed using the command line tools method.

The first issue is that I get apksigner’s error #1 with Godot’s default keystore user/pass. The username must to be changed from “androiddebugkey” to “debug.keystore” to solve error #1. Why Godot can’t see debug.keystore’s alias of “androiddebugkey” and work as shown in the Godot Docs, I don’t know. It should work using the alias, so maybe this is indicative of some underlying problem?

With error #1 seemingly solved, I then get stuck on 'apksigner' returned with error #2. It doesn’t matter if I populate the Export dialogue’s Debug, Debug User, and Debug Password fields with the correct values (or rather the only values which work for me (user/pass:debug.keystore/android), it just won’t work.

Running Godot from the command line with --verbose shows this output when error #2 is displayed in Godot’s UI:

ADDING: resources.arsc
Starting signing of the APK binary using D:/Android/SDK/build-tools/30.0.3/apksigner.bat
Signing debug binary using:
D:/Android/SDK/build-tools/30.0.3/apksigner.bat sign --verbose --ks C:/Users/user/.android/debug.keystore --ks-pass pass:android --ks-key-alias debug.keystore E:/godot/godot-docs/Test Project/Test Project.apk
The system cannot find the path specified.
Failed to load signer "signer #1": C:/Users/user/.android/debug.keystore entry "debug.keystore" does not contain a key

WARNING: Code Signing: 'apksigner' returned with error #2

     at: add_message (editor/editor_export.h:251)

In particular, Failed to load signer "signer #1": C:/Users/user/.android/debug.keystore entry "debug.keystore" does not contain a key is interesting. Why would debug.keystore not contain a key? I’m using the command to generate one as shown in the documentation.

This debug.keystore is only temporary in an attempt to get things working, but here’s the full output of what keytool -v -list -keystore debug.keystore shows:

Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: androiddebugkey
Creation date: 23 Aug 2022
Entry type: PrivateKeyEntry
Certificate chain length: 1
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 4b3b8fec
Valid from: Tue Aug 23 19:42:05 EEST 2022 until: Fri Jan 07 18:42:05 EET 2050
Certificate fingerprints:
         SHA1: 9E:CC:A5:77:81:BA:EC:4A:49:6D:3B:7B:F7:96:1F:D8:52:FB:60:53
         SHA256: 0A:66:E3:2D:F9:E6:C2:CD:18:CC:62:52:F1:4B:9E:F3:80:8B:5A:8C:B8:33:CB:7D:08:11:5C:67:51:0C:9C:F9
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 3


#1: ObjectId: Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: C3 3E 78 04 9B F8 5E 53   B0 67 6B 5D E1 F7 4F 68  .>x...^S.gk]..Oh
0010: D7 A7 BF EA                                        ....


I’m not sure what I’m doing wrong. I managed to get Godot to export an Android project a year or two ago when attempting to learn Godot, but now I’m finding it impossible. What am I missing? Any help is appreciated!

  • My Godot 3.5 is installed via Scoop.

  • Android’s command line tools is an extracted zip.

  • OpenJDK 11 is installed using the MSI installer.

  • Windows 11

:bust_in_silhouette: Reply From: gdough

It turns out that the mysterious line The system cannot find the path specified was also appearing when simply running cmd.exe and is completely unrelated to apksigner.bat, apksigner.jar, the APK file, and Godot.

The problem was that a program had been assigned to autorun on cmd.exe’s launch, but command prompt’s autorun setting was somehow misconfigured. In my case, this program was Clink. I reinstalled Clink, and re-ran clink autorun install which resolved the no longer mysterious line. After all my debugging, it appears that this was the only problem that needed fixing as all other issues were resolved by it and therefore were only side-effects of this command prompt autorun misconfiguration. The solution to this Stack Overflow question helped me figure this out.

I also recreated my debug.keystore file (some hours before solving the autorun issue), this time with certainty that OpenJDK11’s keytool was being used (before, I may have been mistakenly creating it with the latest OpenJDK installation due to a misconfiguration in the user/system PATHs – I now only have the user environment variables JAVA_HOME and %JAVA_HOME%\bin for PATH set). I’m not sure if recreating this file was part of what fixed things, but immediately after fixing the Clink issue, I was now able to use the default Godot Debug User value “androiddebugkey” (the keystore’s alias) instead of “debug.keystore”, which wasn’t possible before, and also export and sign the APK without problems.