Android Signing

Is it required to sign our apk file ? If yes how to do it?

For development : No. For publishing (i.e. Android Market) : Yes.

  1. Locate the Publishing Settings under PlayerSettings
  2. Create a new keystore by selecting a keystore name and password (confirm the password)
  3. Select “Create a new key” under Key Alias
  4. A new window opens; enter the necessary information.
  5. Select the newly created key.
  6. Build ( Run); your app is now signed.

n.b. Remember the passwords; they are not stored with the project (for security reasons).

19 Likes

How to save key?

Can’t find saved “user.keystore”

The keystore (including the key) will be created after step 4 below (ie after entering the details of the key)

3 Likes

…
Having trouble with this - I don’t get a new window, and Create New Key is a checkbox above, not a selection under Key Alias. I’m still on f5 build.

No, it’s “Create New Keystore” that is a checkbox.

Did you select “Create New Keystore” (assuming you don’t already have one)?
Did you select a name for the Keystore (Browse Keystore)?
Did you enter a keystore password?
Did you confirm it (and does it match)?
Only then will the “Create New Key” be visible under KeyAlias.

When pulling down the KeyAlias drop list do you get any errors in the Console log?

8 Likes

ah, thanks Erique - didn’t click Browse Keystore and save first.

3 Likes

FYI, In Windows, I had to download/install JDK and then manually add the JDK bin path to my PATH variable in Windows before I could get KeyTool and JarSigner to work from Unity. JDK installer did not do that automatically.

The 3.1 release will hopefully remedy this. If possible, please try the 3.1beta as it includes the fix for finding JAVA_HOME if not set by the JDK installer.

1 Like

And if you don’t have access to the beta, just email me: oleg@unity3d.com

1 Like

I have the same problem of Akasurreal: Unity does not find the command to create the keystore, so it saves nothing.
I’m trying to follow his procedure and see if it works.
I am on W7-64b.

You need to either install the JDK (on Windows usually), or have the jarsigner command in the PATH (which is the normal case for OSX).

1 Like

I added JAVA_HOME variable with value C:\Program Files\Java\jre6
Now I’m restarting the computer :smile:

That probably won’t do; you need the JDK, not the JRE.

I downloaded the JDK, what the hell?

OK it works with value = C:\Program Files\Java\jdk1.6.0_23 :smile:

Without the :smile: at the end!

I can’t get this to work. I have my JDK installed at C:/Program Files/Java/jdk1.6.0_24 and I have made a PATH environment variable with this path. No matter what I do Unity tells me Unable to run keytool; do you have the JDK installed?

Hi, my java sdk version is 1.6.0_23

1 ::.

546442--19297--$publish1.jpg

2 ::.

546442--19298--$publish2.jpg

3 ::.

4 ::. Publishing Setting

  • Check at Create New Keystore
  • Insert your keystore password first
  • Comfirm your keystore password again
  • Check Existing Keystore
  • Press Browse Keystore button
  • Select file privateKey.store
  • Now you can see foo at Alias name combo box already
  • You can create new Key by unity3d

546442--19300--$publish4.jpg

546442--19301--$publish5.jpg

5 :: Please try and Good luck.

Use JDK 6u14 (jdk1.6.0_14). Unity works fine with that version.
If you live outside USA, just rollback to 6u14 and it will work.

Anyone know how to sign an APK when building from the command-line (e.g. from a build script or CI server)? Looks like the keystore/key passwords aren’t saved, so can BuildPipeline.BuildPlayer() be used to build non-debug signed APKs?

They can be passed with PlayerSettings.keystorePass and PlayerSettings.keyaliasPass.