Keytool access denied for Android build

Hey, I’ve recently started getting an error when trying to build for Android. It may have started after updating Defold last night. When I build for Android, I am seeing the following message:

Picked up JAVA_TOOL_OPTIONS: 
Picked up _JAVA_OPTIONS: 
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 14,000 days
	for: CN=Android, OU=Debug, O=Android, L=Unknown, ST=Unknown, C=US
[Storing debug.keystore]
keytool error: java.io.FileNotFoundException: debug.keystore (Access is denied)
java.io.FileNotFoundException: debug.keystore (Access is denied)
	at java.base/java.io.FileOutputStream.open0(Native Method)
	at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
	at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
	at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:126)
	at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1310)
	at java.base/sun.security.tools.keytool.Main.run(Main.java:397)
	at java.base/sun.security.tools.keytool.Main.main(Main.java:390)

It was working yesterday prior to the update.

1 Like

Agh! Are you on Windows, macOS or Linux?

1 Like

I’m on Windows 10

And is this when bundling from the editor or using bob?

What if you generate a keystore?

From editor

Using a generated keystore or bundling from the terminal using bob.jar works

Created issue: https://github.com/defold/defold/issues/5206

Forum post with workaround: Problem bundling APK/AAB file from editor in 1.2.172

1 Like

@Epitaph64: If you want to jump onto the alpha testing branch for 1.2.174 there’s a version here which fixes the above mentioned bundling error: http://d.defold.com/alpha/

1 Like

Thanks for the tip. I setup a keystore and now however when I generate the APK I’m seeing “Unable to delete file: C:\Users\Epitaph64\Desktop\armv7-android\android5\armv7-android\Undiscovered Territories\aab\base\resources.pb” This happens even if I generate the APK to an empty directory.

Ah, sorry, you’ve come across this one: https://github.com/defold/defold/issues/5192

My recommendation is that you go for the latest alpha until we have released a new version, probably early next week. Or use 1.2.172 until then.

1 Like

No worries, glad it is already fixed in the alpha! I downloaded it and everything is working fine w/ the Android bundling. :slight_smile:

1 Like

Hmm, I’m having another bundling issue now w/ the alpha. I’m seeing “Cannot run program “C:\Users\Epitaph64\Desktop\Defold\packages\jdk11.0.1\bin\jarsigner”: CreateProcess error=2, The system cannot find the file specified” not sure where this went since it was working prior…

Incoming fix: https://github.com/defold/defold/pull/5214

1 Like

Cool. I managed to build it properly in the meantime by downloading OpenJDK 11 and replacing the directory there with it.

New alpha with jarsigner fix available from the download page: http://d.defold.com/alpha/

+1 for the innability to bundle for Android. I used the new .keystore and it previously errored out with a message in the form: “cannot delete … some files”, probably stuff used in between bundling.

Downloading the alpha seems to work.
Also in trying to fix errors I’ve added jdk1.8.0_221 and \bin to the path so it can use the “jarsigner”. Is the JDK version good enough, or will it interfere with future Android bundling needs?

Having installed the alpha, will I be able to update as soon as 1.2.174 becomes stable? Or should I keep the 1.2.173 as well and rename the folder back to Defold and update from there once 1.2.174 becomes stable?

Thanks!

The latest alpha (sha1: 1ad8b419bbccf27994e3290e6c6ede2594397800) has jarsigner bundled and everything should now be working on macOS, Windows and Linux. There should be no need to install Java and copy jarsigner or things like that.

Also note that we are bundling OpenJDK 11.0.1 with the editor.

The alpha and stable versions are on different update cycles. The alpha will keep updating for every commit we do to the development branch. The stable version will update the engine only when we do a stable release (every four weeks). Both versions will update as soon as there is new code for the editor though.

Best is to keep both versions around, and our recommendation is to use the stable release coming out every four weeks.

Makes perfect sense, thanks for the clarifications.