segunda-feira, 6 de agosto de 2012

Unity3D fails to sign APK with JDK 1.7

What's wrong?

Unable to install APK!
    pkg: /data/local/tmp/Package.apk

With a short time to search I found many results about Unity and JDK 1.7 can't sign correctly. Like: and
But no solutions and to do a downgrade on JDK 1.7 not solve for me.

I think that bug is Unity3D don't specify the sign algorithm for jarsigner although Unity works correctly with JDK1.7 keytool. And a downgrade to JDK 1.6 results on fail with Unity and keytool.

How to do?

That's so simple! Like a cake:

Installs JDK 1.6 and use the executables from bin folder of JDK 1.6

Create your keystore and alias if necessary

Do a build by Unity3D and use default key (unsigned(debug)). For default Unity always sign yours APKs.

Use 7zFM from 7zip to remove META-INF folder into your generated APK.

Verify your APK after it with you want to see unsigned apk message

jarsigner -verify my_signed.apk

Now! Sign!

jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name

And verify one more time

jarsigner -verify my_signed.apk

Everything ok? Use zipalign to optimize the memory use by your apk

zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk
Now your APK is ready to install and submit. For more details: here

Nenhum comentário:

Postar um comentário