Could not sign apk with platform certificate (ICS) - android

I try to sign Trebuchet launcher with platform certificate, but it fails to install after that:
$ java -jar out/host/darwin-x86/framework/signapk.jar build/target/product/security/platform.x509.pem build/target/product/security/platform.pk8 out/target/product/crespo/system/app/Trebuchet.apk CapsuleLauncher.apk
$ adb -e install -r CapsuleLauncher.apk
1916 KB/s (7946887 bytes in 4.049s)
pkg: /data/local/tmp/CapsuleLauncher.apk
Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]
If I do not sign it - it installs successfully. How to sign it?

INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES means that you used the wrong certificate to sign your app.
Signing with the platform certificate only works if you build an app for your custom firmware rom where you know the certificate. It does not work if you use the standard firmware of a device since the manufacturers keep their certificates a secret.
If you don't sign it the app won't get any system priviledges but will still run.

Related

Certificate for Android application

Trying to install application with ADB on physical device connected via USB:
adb -s ce06160684b99a0902 install E:\D\android\MQTT\app\debug\app-debug.apk
Got error:
E:\D\android\MQTT\app\debug\app-debug.apk: 1 file pushed. 4.0 MB/s (3747450 bytes in 0.903s)
pkg: /data/local/tmp/app-debug.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
I was generated application via Build->Generate Signed Bundle/APK -> APK and entered key data:
I suppose this procedure generates certificate? How to fix this problem?
It is trying to install app-debug.apk whereas the signed apk name is app-release.apk . What code are you using to install the apk to your device? Also try adding this certificate through
Project Structure -> Default Config -> Signing Config
For both debug and release if required.
According to documentation (Sign your debug build), you don't have to explicitly sign your app-debug.apk, it's done automatically. It uses a specific keystore, generated for you, under $HOME/.android/debug.keystore.
So you only need to click the play button, with your device selected in the drop-down list, as described here.
You could also click on Rebuild Project instead of Generate Signed Bundle / APK, and manually upload it to device with your adb command.

How to verify apk signature from a shell command prompt?

I would like to know how to verify an apk signature (and installer) from a shell command prompt.
Thanks
Based on the Android documentation, to verify your apk from the shell apksigner verify my-app.apk
Sign Your App Manually

Google Glass // System signature // Install APK in background

I want to download and install / remove APKs in background programmatically on a google glass device.
Steps i already tried:
Move APK to /system/priv-apps
Try to sign the APK with the system signature (I don't know if I signed it with the correct one)
Set the android sharedUserId to "android.uid.system" -> this gave me a permission error while installing
Can anybody help me getting my App signed by a system signature? I really do not want to code a shell script running on each boot..
I am also getting the following error while trying to exec the
pm install -r APK_PATH
command programmatically:
Error running exec(). Command: [su] Working Directory: null Environment: null
Please help me! :-)
According to this documentation, be noted that the APK needs to meet the following criteria:
It must be zip-aligned.
You must not make any changes to the package name or private signing key after this (the Android package manager does not allow upgrades if either of these changes).
It must be smaller than 50 megabytes.
It must be compiled using the latest version of the GDK.
To sign the APK based from this thread,
On top of signing Android 1.6 for Dream with certificates generated by
myself, I've also managed to sign my app with the platform certificate
and run it with the system sharedUserId. These are the steps I took:
Build and flash to your Dream your own Android using http://source.android.com/documentation/building-for-dream. Use the
mkkey.sh script on
http://pdk.android.com/online-pdk/guide/release_keys.html to create
new certificates, including x509 certificates before you do 'make'.
In the AndroidManifest.xml of your application: under the <manifest> element, add the attribute android:sharedUserId="android.uid.system".
Export an unsigned version of your Android application using Eclipse: right-click on the project >> Android Tools >> Export
Unsigned Application Package.
Use <root-of-android-source-tree>/out/host/<your-host>/framework/signapk.jar to sign your app using platform.x509.pem and platform.pk8 in <root-of-android-source-tree>/build/target/product/security
generated earlier:
java -jar signapk.jar platform.x509.pem platform.pk8 YourApp-unsigned.apk YourApp-signed.apk.
Install the app to your device:
adb install YourApp-signed.apk
Run your app
Use adb shell ps to confirm that your app is running as system.
Check these related forums:
How to sign Android app with system signature?
How can I sign my application with the system signature key?
Hope this helps!

ADB Install a signed APK over an unsigned APK that failed to install in the first place

I am attempting to sideload an APK with ADB. When I downloaded it, it was unsigned, but I attempted to install it, unknowingly, and it failed since it was unsigned. I signed it manually and verified that it was signed correctly, but when I go to install it with adb install -r <path to signed apk>, I get the following error:
Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]
So I found this question that said to uninstall the old application that was unsigned, but I can't find the application on my device or anywhere in adb, so how am I supposed to uninstall the unsigned APK that failed to install in the first place? Or is there something I'm missing?
To uninstall you must know the package name of the application, Not the file name.
Usage Example: adb uninstall com.google.android.youtube (uninstalls youtube)

How to correctly sign apps in CyanogenMod?

I compiled CyanogenMod 7 from source code, then tried to install ADWLauncher on my device:
$ adb install -r ./out/target/product/crespo/system/app/ADWLauncher.apk
4147 KB/s (1060312 bytes in 0.249s)
pkg: /data/local/tmp/ADWLauncher.apk
Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]
Related question's answer says, that this means that package was not properly signed. But when I try to sign it - it fails, because the package is already signed.
How can I sign it correctly?
There is line
LOCAL_CERTIFICATE := shared
in Android.mk. How can I override it with my own certificate?
This may be because you're trying to install a version of an app on top of another version that has a different signature. Try completely uninstalling the already installed apk first, either via Android's UI or from adb:
adb uninstall org.adw.launcher
Then try installing fresh again. The same error can occur even if you've built both versions yourself- say first having installed a version signed with a release key, and then installing the same app again using test/debug keys.

Categories

Resources