Certificate problems when installing APK file on Android phone from command line


A colleague made an example program using the QCAR plugin for Unity3D and it's running fine when installed from the editor. But when I try to install the package using the 'adb' tool from the Android SDK, I get the following error:

adb install teapot_slider.apk -> INSTALL_PARSE_FAILED_NO_CERTIFICATES

So I think: OK, the package isn't signed yet, so I'll go make a keystore using 'keytool' and then sign the package using 'jarsigner' (and then align it using 'zipalign', all tools from the Android SDK (see http://developer.android.com/guide/publishing/app-signing.html).

This all seems to go quite well, but then when I try to install the package again, I get this error: INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES

All the answers I find related to the latter error say that I need to uninstall the old application first. But I cannot do that since no previous version of the application has been installed, and no other Unity applications are installed either.

I have also found that the adb install/uninstall commands are a bit assymmetric: you specify the .apk file to install something, but you need to specify the name of the package to uninstall it. Since the contents of AndroidManifest.xml in an APK are garbled, I used the command 'aapt dump badging teapot_slider.apk' to find the name of the package: com.fj.test.

Running the command 'adb shell pm list packages' confirms what I new: this package is not in the list.

So the question is: how can I install an apk file on my phone without using the Unity3D Pro editor?

By the way, the phone is an LG Optimus 2X Speed (w. NVidia Tegra 2)


Why don't you use the built-in app signing capabilites of Unity? This is no pro-feature only. Go to File->Build Settings->Player Settings... and then in the Inspector under Publishing Settings you can configure your keystore or create a new one.

Afterwards you can just "Build and Run" your signed apk to your phone from Unity.

Important: You need to have a 32bit SDK (JRE won't do) installed in order to succeed.