When trying to export to Android, I'm getting this fatal error on a project that was upgraded from Godot 4.0.4 to Godot 4.2-dev-5:

editor/export/editor_export_platform.h:179 - Code Signing: 'apksigner' returned with error #2
editor/export/editor_export_platform.h:179 - Code Signing: output:
Failed to load signer "signer #1"
java.io.IOException: toDerInputStream rejects tag type 127
at java.base/sun.security.util.DerValue.toDerInputStream(DerValue.java:886)
at java.base/sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1974)
at java.base/sun.security.util.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:222)
at java.base/java.security.KeyStore.load(KeyStore.java:1479)
at com.android.apksigner.ApkSignerTool$SignerParams.loadKeyStoreFromFile(ApkSignerTool.java:833)
at com.android.apksigner.ApkSignerTool$SignerParams.loadPrivateKeyAndCertsFromKeyStore(ApkSignerTool.java:723)
at com.android.apksigner.ApkSignerTool$SignerParams.loadPrivateKeyAndCerts(ApkSignerTool.java:663)
at com.android.apksigner.ApkSignerTool$SignerParams.access$500(ApkSignerTool.java:615)
at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:269)
at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:89)

The error occurs both when attempting a one-click install and when exporting by saving as an .apk.

In Godot 4.0.4, I was able to export the project to Android without any issue.

I can export two other 4.2-dev5 projects to Android. As far as I can tell, the Android export settings for this project are the same as in those two projects. But maybe I missed something.

I tried deleting the .godot folder and letting it get rebuilt, but that didn't help.

Solved.

The setting Editor Settings >> General >> Export >. Android >> Debug Keystore was set to the path to the adb executable, instead of the debug keystore file.

What I don't understand is that the other two projects had that same setting, and they exported to Android.

DaveTheCoder changed the title to [Solved] Android export - Code Signing: 'apksigner' returned with error #2 .

Maybe the daemonized gradle had already picked up the debug key?