How to correctly sign apps in CyanogenMod? - android

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.

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.

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)

Could not sign apk with platform certificate (ICS)

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.

Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES

At the risk of repeating what appears to be a very common complaint, I think I have a substantial variation on this bug.
The application won't install from Eclipse and this appears in the console: Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES.
LogCat provides some illumination: Package com.xxx has no certificates at entry assets/fonts/helvetica_neue.ttf; ignoring!
Meaning that the device (or emulator) believes that this particular file wasn't signed.
The usual solutions proposed for this are:
- Rename the offending file. We've tried that, it then complains about the next file, then the next, and so on.
- Add a dummy file. Tried that too. It complains about the new file, regardless of what it's called.
- Compile for greater than Android 1.6. We're compiling for 2.3.
It's worth noting this only happens when we launch a unit test. We can install the "real" application on its own with no difficulties. We're also using Maven and, of course, the Maven Android plugin.
Any insights or suggestions would be very welcome and of course if we figure it out on our own I'll post any findings.
I encountered this through normal debugging - while it's unlikely to help all the time, simply going to Project -> Clean and rebuilding everything may be enough to clear the error.
I found it was due to my JDK version. I was having this problem with 'ant' and it was due to this CAUTION mentioned in the documentation:
http://developer.android.com/guide/publishing/app-signing.html#signapp
Caution: As of JDK 7, the default signing algorithim has changed, requiring you to specify the signature and digest algorithims (-sigalg and -digestalg) when you sign an APK.
I have JDK 7. I can't speak for your Maven, but it is probably the same issue. In my Ant log, I used -v for verbose and it showed
$ ant -Dadb.device.arg=-d -v release install
[signjar] Executing 'C:\Program Files\Java\jdk1.7.0_03\bin\jarsigner.exe' with arguments:
[signjar] '-keystore'
[signjar] 'C:\cygwin\home\Chloe\pairfinder\release.keystore'
[signjar] '-signedjar'
[signjar] 'C:\cygwin\home\Chloe\pairfinder\bin\PairFinder-release-unaligned.apk'
[signjar] 'C:\cygwin\home\Chloe\pairfinder\bin\PairFinder-release-unsigned.apk'
[signjar] 'mykey'
[exec] pkg: /data/local/tmp/PairFinder-release.apk
[exec] Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
I signed the JAR manually and zipaligned it, but it gave a slightly different error:
$ "$JAVA_HOME"/bin/jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore release.keystore -signedjar bin/PairFinder-release-unaligned.apk bin/PairFinder-release-unsigned.apk mykey
$ zipalign -v -f 4 bin/PairFinder-release-unaligned.apk bin/PairFinder-release.apk
$ adb -d install -r bin/PairFinder-release.apk
pkg: /data/local/tmp/PairFinder-release.apk
Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]
641 KB/s (52620 bytes in 0.080s)
I found that answered here.
How to deal with INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES without uninstallation
I only needed to uninstall it and then it worked!
$ adb -d uninstall com.kizbit.pairfinder
Success
$ adb -d install -r bin/PairFinder-release.apk
pkg: /data/local/tmp/PairFinder-release.apk
Success
641 KB/s (52620 bytes in 0.080s)
Now I only need modify the build.xml to use those options when signing!
For those with this problem...
Select V1 (jar signature) instead of V2 (full apk signature)
Selecting V2 could also cause this problem.
This is fixed now. Should someone find themselves with the same unique project setup and bug the solution may be of some value.
The problem stemmed from the configuration of our resource directories in the POM of our test project (the project containing our unit tests). They were pointing to the resource directories of the project being tested. This set up should work so I'm going to guess that it's a bug in the Maven Android plugin that causes the resources to remain unsigned.
So the solution was to remove the references to external resource directories (I can't say why it was done that way initially but removing them appears to have no ill effects) and configure the resource directories in the standard way (taking as an example the POM provided by the maven plugin project archetype with tests).
I had this problem with MotoDev 3.0.0
The solution was to delete emulator and create a new one.
In fact, you do not need to delete the old emulator, just create a new one and installation goes smoothly.
Had the same problem, it was that I was configured to use the App Store instead of debug under the Android target configuration, and I hadn't set up the app store yet. Switched back to debug and it was fine.
choose Java SE 6 in the Java preference app

Categories

Resources