Signing a CocoonJS .apk file errors

Get help using Construct 2

Post » Tue Sep 11, 2012 6:16 pm

I used the CocoonJS cloud compiler and successfully booted up a game on a test device - runs great and the cloud service was super-easy. I'm having a bit of trouble signing the official release .apk though.

I've completed the first step of signing with keytool, using this command-line string:
[CODE]keytool -genkey -v -keystore C:\Android\salmonsez.keystore -alias salmonsez -keyalg RSA -keysize 2048 -validity 10000 [/CODE]    

It generates the file and everything. However when I run jarsigner for the next step with this string:
[CODE]jarsigner -verbose -keystore C:\Android\salmonsez.keystore -storepass **** -keypass **** C:\Android\ss\Salmon_Sez_release.apk Salmon_Sez_release.apk salmonsez[/CODE]

it gives me this error:
[CODE]jarsigner: Certificate chain not found for: Salmon_Sez_release.apk. Salmon_Sez_release.apk must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.[/CODE]

What am I missing here?stevo3011032012-09-11 18:17:26
B
11
S
3
G
2
Posts: 23
Reputation: 1,453

Post » Tue Sep 11, 2012 6:24 pm

[CODE]jarsigner -verbose -keystore C:\Android\salmonsez.keystore C:\Android\Salmon_Sez_release.apk salmonsez[/CODE]

Worked. Sorry to bother anyone, don't know what the issue was though.
B
11
S
3
G
2
Posts: 23
Reputation: 1,453

Post » Tue Sep 11, 2012 9:16 pm

I tried to like you but I do not really understand how. I installed Eclipse and the Android SDK but I'm a little lost, can you help me please? Sorry for the bad english, I'm french.
Webmaster of the French community from Construct Classic and Construct 2
B
80
S
13
G
8
Posts: 27
Reputation: 7,710

Post » Wed Sep 12, 2012 4:27 am

I'm going to write up a more detailed walk through of what I did because now it really is super easy. I'll let you know when I've gotten it finished.
B
11
S
3
G
2
Posts: 23
Reputation: 1,453

Post » Wed Sep 12, 2012 10:34 am

Oh @stevo301103, please wtire a tutorial about this process!
B
19
S
5
G
4
Posts: 109
Reputation: 4,195

Post » Wed Sep 12, 2012 11:21 am

[QUOTE=stevo301103] I'm going to write up a more detailed walk through of what I did because now it really is super easy. I'll let you know when I've gotten it finished.[/QUOTE] Thank you very much!
Webmaster of the French community from Construct Classic and Construct 2
B
80
S
13
G
8
Posts: 27
Reputation: 7,710

Post » Wed Sep 12, 2012 4:12 pm

[QUOTE=stevo301103] I'm going to write up a more detailed walk through of what I did because now it really is super easy. I'll let you know when I've gotten it finished.[/QUOTE]
This would be greatly appreciated.
B
17
S
2
G
3
Posts: 28
Reputation: 3,034

Post » Wed Sep 12, 2012 5:38 pm

So, here's a step-by-step for signing, using Construct 2, CocoonJS Cloud Compiler, the Java Development Kit & the Android SDK on Windows 7.

1. Install all prerequisites:
I used default values for everything, apparently this can cause an issue with the path variables (like directions to executable files given by the computer) - so you may want to locate everything in a simple directory like C:\Java. As it was I installed everything a long time ago and had yet to run into this situation, so I had to set a new PATH variable from the command line after I updated my Android SDK.

echo %JAVA_HOME%

will tell you where your Java Developer Kit is installed, a folder named /jdk.#.#.# (jdk followed by the current version number). Mine was installed in the /Program Files/Java/ directory, so before signing I had to set the java home, replace jdk.# with your folder name.

set JAVA_HOME = C:\Programs Files\Java\jdk.#.#.#

2. Create a folder at C:\Android, it'll make these next steps easier.

3. Next you have to generate a unique KEYSTORE using the Java tool Keytool - located in your jdk.#.#.# folder, my default location was:

Program Files\Java\jdk1.6.0_26\bin

Open a Command Prompt window on the \bin folder by holding SHIFT and right clicking in file explorer and choosing Open Command Prompt Here. At the command prompt type:

keytool -genkey -v -keystore C:\Android\YOURAPPNAME.keystore -alias YOURAPPNAME -keyalg RSA -keysize 2048 -validity 10000
Replacing the parts I put 'YOURAPPNAME' with your app. You'll be asked for name, company and location details and well as for two passwords. Set all these and remember them well. Once you've signed and uploaded a file you'll have to use the same key file each time you update it. I've saved the signing settings for each app as a text file to make this process a simple cut and paste operation.

4. Use Jarsigner to sign your app file from CocoonJS. Unzip the file they sent you and drag the "Release_Unsigned.apk" version to your C:\Android folder, rename it to something easy like "Your_App_Name_release.apk". In the Command Prompt window we opened in the last step, type:

jarsigner -verbose -keystore C:\Android\YOURAPPNAME.keystore C:\Android\YOURAPPNAME_release.apk YOURAPPNAME

If you don't get errors you can move onto the final step.

5. You can close the Command Prompt window now. We'll open another one from the location of our Android SDK installations Tools folder. My default location was at:

C:\Program Files (x86)\Android\android-sdk\tools
SHIFT+Click on the Tools folder and choose Open a Command Prompt Here. Then type:

zipalign -v 4 C:\Android\YOURAPPNAME_release.apk C:\Android\YOURAPPNAME_releaseYOURRELEASENUMBER.apk

To generate a final, uploadable file. It will generate a file with Your_App_Name_release001.apk to upload to the Google Play store. Remember, once it's done and uploaded you have to keep using this same keystore, so back it up and protect the access codes so you can continually update the same listing in the store. Changing this keystore value requires uploading your new app version as a whole new store listing.

Once you've uploaded a version and go back to update the listing later, you'll just do the last two steps, Jarsigner and Zipalign using the KEYSTORE file you created for the first step.stevo3011032012-09-12 17:47:29
B
11
S
3
G
2
Posts: 23
Reputation: 1,453

Post » Wed Sep 12, 2012 9:48 pm

Thank you for taking the time to write this tutorial.
But I followed your tutorial, I have no error, but when I upload the file to Google play he said: "The server could not process your apk. Please try again."
Have you any idea why?
Webmaster of the French community from Construct Classic and Construct 2
B
80
S
13
G
8
Posts: 27
Reputation: 7,710

Post » Wed Sep 12, 2012 11:41 pm

Can you post how you're setup and what steps you're doing? I've also had some issues with the google developers console that required me to use another browser to access it. Chrome had some lingering signins from other Google products and it was screwing up some of the saving and settings.
B
11
S
3
G
2
Posts: 23
Reputation: 1,453

Next

Return to How do I....?

Who is online

Users browsing this forum: Scofano and 22 guests