Android INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES - android

I am getting the following error when I'm trying to install an APK with a higher version and same packageName over an existing one. The existing APK is a system app. It fails with the following error:
INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES
However when I manually inspect the 2 apks their certificates seem to match. I used the following command:
unzip -p $package META-INF/CERT.RSA | keytool -printcert
Is there a different parameter which might be affecting this?

Related

Installed apk doesn't start

I have to write couple tests on Xamarin UI Test framework to check apk on emulator. I tried to install my apk in two ways:
1 adb.exe install path\com.company.mobiledemo.apk
2 through Xamarin UI Test
if (platform == Platform.Android)
{
AndroidApp app = ConfigureApp.Android
.ApkFile("path\\com.company.mobiledemo.apk")
.Debug()
.EnableLocalScreenshots()
.DeviceSerial("emulator-5554")
.StartApp();
return app;
}
In first approach apk installed and working correctly. But when apk installed via code above apk will be install but wont launch, just stopped after splash screen.
I have no idea why because both use the same apk file.
NUnit: 3.13.3
NUnit3TestAdapter: 4.2.1
Xamarin.UITest: 2.2.6
Emulator OS: Android 6.0 Api 23
Ok I found the solution. It's a bit confused and maybe there is a more easy fix. Problem as I understood is your apk and Instrumentation backend apk must be signed the same cert.
My steps:
I installed apk via adb command : >adb.exe install ~\..\com.company.mobiledemo.apk
Then changed AppInitializer.cs like this :
if (platform == Platform.Android)
{
string keystore = "~\\..\\..\\some.keystore";
AndroidAppConfigurator appConfigurator = ConfigureApp.Android
.KeyStore(
keystore,
"storePassword",
"keyPassword",
"\"keyAlias\""
)
.InstalledApp("com.company.mobiledemo.apk")
.Debug()
.EnableLocalScreenshots();
AndroidApp app = appConfigurator.StartApp(AppDataMode.Clear);
return app;
}
Then tried to launch test and got error :
System.Exception : Failed to execute: C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\jarsigner.exe -sigalg SHA1withRSA -digestalg SHA1 -signedjar "C:\Users\{user}\AppData\Local\Temp\uitest\a-287A943C412ED6ED5DEB1675E7FDF91843FD0807\20344\SignedTestServer.apk" -storepass bla-bla -keypass bla-bla -keystore "~..\Mobile\Mobile.Android\Certificate\some.keystore" "C:\Users\{user}\AppData\Local\Temp\uitest\a-287A943C412ED6ED5DEB1675E7FDF91843FD0807\TestServer.apk" ""Key Alias"" - exit code: 1
Please type jarsigner -help for usage
Only one alias can be specified
It's ok.
Open folder from error message :
C:\Users{user}\AppData\Local\Temp\uitest\
You will see something like this :
Delete all and run tests once again. After launching new test data will appear:
Copy command from error message above, go to C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin or directory where located jarsigner.exe
Execute command after System.Exception : Failed to execute:
Find SignedTestServer.apk and copy it into folder containes dummy.apk
Run tests once again and see that FinalTestServer.apk appeared
PS Close folder C:\Users\{user}\AppData\Local\Temp\uitest before 9.

Signing APK breaks installation

I am resigning an APK with my own keys using the command line jarsigner.exe -keystore Keys.jks base.apk debug0, after deleting META-INF/CERT.RSA, CERT.SF and MANIFEST.MF, without touching anything else.
My issue is that after resiging, installing via adb install base.apk gives me the error Failure [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2].
How can I solve this? In the AndroidManifest extractNativeLibs is set to false, at least as far as apktool can decode it. So I do not see any reason the libs should be extraced at all...
To get it to work i had to
zipalign the apk (zipalign.exe -p 4 base.apk base_aligned.apk)
sign it using apksigner (apksigner.exe -ks Store.ks base_aligned.apk)

Publishing Ionic app - Zipalign not working

I am trying to get my Ionic app published. However, when trying to zipalign the apk with the following command
/Users/bertcarremans/Library/Android/sdk/build-tools/23.0.3/zipalign zipalign -v 4 android-release-unsigned.apk chartly.apk
I get the message below:
Zip alignment utility
Copyright (C) 2009 The Android Open Source Project
Usage: zipalign [-f] [-p] [-v] [-z] <align> infile.zip outfile.zip
zipalign -c [-v] <align> infile.zip
<align>: alignment in bytes, e.g. '4' provides 32-bit alignment
-c: check alignment only (does not modify file)
-f: overwrite existing outfile.zip
-p: page align stored shared object files
-v: verbose output
-z: recompress using Zopfli
How can I make the zipalign tool to work? Thanks!
I found the solution.
Copy the zipalign tool to the apk folder of your app. On my computer the zipalign tool was located in /Users/bertcarremans/Library/Android/23.0.3
Then run the command ./zipalign -v 4 android-release-unsigned.apk chartly.apk
There is no need to copy zipalign file anywhere, if it is installed through command line a symbolic link will be created and then you can run it from anywhere.
You are not using the right syntax of the zipalign tool. Please check again, you have written zipalign twice so you are passing zipalign as a parameter to zipalign command which is not correct.

Titanium CLI not accepting the .keystore file provided

I am trying to make android build, target set to build for dist-playstore from Titanium CLI. I am using this command
titanium build -p android -b -d /Users/ajeetpratap005/Documents/Titanium_Studio_Workspace/androidTest
-f -L androidTest -A /Users/ajeetpratap005/android-sdks
-K /Users/ajeetpratap005/android-test.keystore
-T dist-playstore -O /Users/ajeetpratap005/Documents/Titanium_Studio_Workspace/androidTest/dist
It builds successfully but I am not able to get my build in the output folder. when I checked the build which is getting generated in the build/android/bin folder, it is signed with the default keystore file which is present in the
<titanium mobile SDK location>/3.0.0.G.A/android/dev_keystore
How do I make titanium CLI to take my .keystore file and dump the production build to the output folder mention in the command..
Please refer to this document
https://wiki.appcelerator.org/display/guides/Packaging+for+the+Android+Market
There are instructions on the android developer site for generating the certificate key file here: http://developer.android.com/guide/publishing/app-signing.html#cert
See this video for more clarity http://vimeo.com/10278960

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