Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES - android

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

Related

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)

java.lang.RuntimeException: Cannot start "jarsigner" process, please add it to the PATH

when i run ./gradlew bundleRelease, I have repeatedly encountered errors like this
java.lang.RuntimeException: Cannot start "jarsigner" process, please add it to the PATH
I found it when it was 99% run
if anyone has the same problem please install openjdk-8-jdk-headless
sudo apt install openjdk-8-jdk-headless
As signing is in the final stage of bundleRelease it is expected to get said error if you have any issue with the jarsigner configuration in your machine.
Check if you have jarsigner in your JDK -> bin folder.
Also bin folder should be added to your class path in your environmental variables if you are using Windows machine.
You can use command to check whether you have jarsigner configured in your machine as given below. (jarsigner is configured in the below screenshot)

Failure [INSTALL_FAILED_TEST_ONLY] Error while Installing APK [duplicate]

I am having issues installing an apk to my device.
adb install <.apk>
Using the above command returns the following:
5413 KB/s (99747 bytes in 0.017s)
pkg: /data/local/tmp/AppClient.TestOnly.App3.apk
Failure [INSTALL_FAILED_TEST_ONLY]
Any idea on what might cause this issue?
It definitely recognizes the device. Could it be an issue with the apk?
Looks like you need to modify your AndroidManifest.xml
Change android:testOnly="true" to android:testOnly="false" or remove this attribute.
If you want to keep the attribute android:testOnly as true you can use pm install command with -t option, but you may need to push the apk to device first.
$ adb push bin/hello.apk /tmp/
5210 KB/s (825660 bytes in 0.154s)
$ adb shell pm install /tmp/hello.apk
pkg: /tmp/hello.apk
Failure [INSTALL_FAILED_TEST_ONLY]
$ adb shell pm install -t /tmp/hello.apk
pkg: /tmp/hello.apk
Success
I was able to reproduce the same issue and the above solved it.
If your APK is outside the device (on your desktop), then below command would do it:
$ adb install -t hello.apk
I had a similar problem with Android Studio 3.0.0 Beta 7 and could not publish anymore to the play store.
As stated here: https://developer.android.com/studio/run/index.html
Note: The Run button builds an APK with testOnly="true", which means
the APK can only be installed via adb (which Android Studio uses). If
you want a debuggable APK that people can install without adb, select
your debug variant and click Build > Build APK(s).
Same goes for release build, with Android Studio 3 you need to go to Build > Build APK(s) to have a non testable release apk that you can submit to the store.
Add -t install flag, as on the screenshot below:
In my case this mistake was in unstable gradle version. Just use a stable version of gradle (not alpha, not even beta). And it was fixed for me
After searching and browsing all day, the only one works is adding
android.injected.testOnly=false
to the gradle.properties file
I agree with Elisey. I got this same error after opening my project in the 2.4 preview and then opening the same project in android studio 2.3
Fixed the issue by changing this line in build.gradle from
classpath 'com.android.tools.build:gradle:2.4.0-alpha5'
to
classpath 'com.android.tools.build:gradle:2.3.1'
None of the previous post solve my issue. Here is what's happening with me:
I normally load the app from android studio by clicking on the "Run" button. When you do this, android would create an app that's good for debug but not for install. If you try to install using:
adb install -r yourapk
you will get a message that says:
Failure [INSTALL_FAILED_TEST_ONLY]
When this happens, you will need to rebuilt the apk by first clean the build, then select Build->Build APK. See the image bellow:
This APK is ready to be installed either through adb install command or any other methods
Hope this helps
David
Android studio 3.0 generates test only APK.
I have solved the issue by adding the "android:testOnly" property to android manifest's tag.
<application
.....
android:testOnly="false"
android:theme="#style/AppTheme">
And then generated the APK by Android studio3.0 menu:Build-->Build APK(s).
More Info:
https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
add this line to your ‘gradle.properties’
android.injected.testOnly=false
If you want to test the apk, just add the -t command line option.
Example command:
adb install -t .\app-debug.apk
In my case was by uploading an APK, that although it was signed with production certificate and was a release variant, was generated by the run play button from Android studio.
Problem solved after generating APK from Gradle or from Build APK menu option.
In my case, using Android Studio 4.0, the below solved the issue;
Add to 'gradle.properties' file;
android.injected.testOnly=false
Android 3.6.2 or later
Build >> Build/Bundle apk >> Build apk
Its working fine.
I see the accepted answer but you dont have to actually push the apk and then run the command on adb shell direct adb install with -t flag actually works
adb install -t "path to apk in ur computer"
attaching a screenshot for reference
This works for me:
adb install -t myapk.apk
The easiest to solve this, without reverting to an older gradle version is to add the '-t' option in the run configurations (for pm install).
testOnly='false' had no effect whatsoever. The error is caused by the alpha version of gradle plugin that makes debug APK 'for test only purposes'. The -t option allows such APK to be installed. Setting it in run configuration makes it automatically install you APK as usual.
My finding is as below. If I compile using the Android Studio UI, and the APK generated, I can't just
adb install <xxx.apk>
It will generate Failure [INSTALL_FAILED_TEST_ONLY]
I need to compile it using the gradle i.e. ./gradlew app:assembleRelease. Then only the generated apk, then it can only be installed.
This is because the Android Studio UI Compile, only generate test apk for a particular device, while ./gradlew app:assembleRelease command is the actual apk generation to be installed on all device (and upload to playstore)
I don't know if it's gonna be useful for anyone or not, but I got this error message, when I accidentally tried to build and install my project with test gradle plugin ('gradle:2.4.0-alpha5') version in stable Android Studio version (2.3, not in 2.4 preview 5 version I'd downloaded and installed before).
When I realized my mistake, I launched preview Android Studio version and it built and installed my project without any problem.
As mentioned in documentation:
Android Studio automatically adds this attribute when you click Run
So, to be able to install your apk with adb install <path to apk file> you need to assemble build from terminal: ./gradlew assembleDebug and install with adb. Or just run ./gradlew installDebug to build and install on the device simultaneously.
Build your distribution .apk from Android Studio as follow
Build --> Build Apk(s) (for unsigned build)
Build --> Generate Signed APK ( for signed build)
These option builds the APK with android:testOnly="false" option which allows you to install the APK expicitly into device by the commond.
adb install yourBuilT.apk
What worked for me is performing Refresh all Gradle projects from the Gradle toolbar from the right menu.
PFB the screenshot from Android Studio.
Select Gradle toolbar from the right menu.
Select the Refresh icon
This resolved the issue for me.
Although I am sure Saurabh's answer will work for most other people, I did want to identify the extra steps I had to take in order to get my apk installed.
I tried pushing to the device with the following result:
? adb push AppClient.TestOnly.App3.apk \tmp\
failed to copy 'AppClient.TestOnly.App3.apk' to '\tmp\': Read-only file system
After looking around to change the filesystem RW permissions I ended up executing the following commands:
? adb shell
255|shell#android:/ $ su
shell#android:/ # mount -o remount,rw /
mount -o remount,rw /
I got this when I tried to push again:
? adb push AppClient.TestOnly.App3.apk /tmp
failed to copy 'AppClient.TestOnly.App3.apk' to '/tmp': Permission denied
I was able to push to the sdcard:
? adb push AppClient.TestOnly.App3.apk /sdcard/
3178 KB/s (99747 bytes in 0.030s)
At which point I was able to execute Saurabh's command:
shell#android:/ # pm install -t /sdcard/AppClient.TestOnly.App3.apk
pm install -t /sdcard/AppClient.TestOnly.App3.apk
pkg: /sdcard/AppClient.TestOnly.App3.apk
Success
For me it has worked execute the gradle task 'clean' (under :app, at Gradle pane, usually located at the right) and run again the project.
I tried external project, with multiple apk.
The command from Studio, looked like
adb install-multiple -r ....
Solution -
select console
aste command with -t
If you are looking for a less permanent solution then adding android.injected.testOnly=false to your gradle.properties file and you don't mind using the command line then the following two commands before installation will do:
rm -v **/build/**/AndroidManifest.xml
gradle build
For Windows users: delete all AndroidManifest.xml from all build directories. But not from the src directories so DEL /S is not the best idea.
I got the same issue and no answer helps.
At last, I find there's still an install in my Safe Folder(Or Secure folder depending phone brands), which had not been removed when Android uninstalled the ordinary install. Remove it and this issue fixed.
Hope this can help some guys else!
first remove the unstable version:
adb uninstall problematic-package-name
; and then reinstall the apk.

Android INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES

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?

Error in installing .apk to android emulator

i am trying to install my .apk file to emulator but it is giving me error.
subh#subh:~/subh/droidbox/android-sdk-linux/platform-tools$ ./adb -s emulator-5554 install /home/subh/subh/androidapp/HelloAndroid/bin/HelloAndroid-release-unsigned.apk
11 KB/s (2919 bytes in 0.245s)
pkg: /data/local/tmp/HelloAndroid-release-unsigned.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
then i used jarsigner to sign the .apk
subh#subh:~/subh/androidapp/HelloAndroid/bin$ jarsigner -verify -verbose -certs HelloAndroid-release-unsigned.apk
s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope
no manifest.
jar is unsigned. (signatures missing or not parsable)
subh#subh:~/subh/androidapp/HelloAndroid/bin$
but still i have problem of certificate.
The second command seems to give an error. Can you try cleaning your project in Eclipse and creating a new APK?
I got the answer .apk need to be signed before we want to release it.
In case of ant we have two modes debug and release.
# ant debug
this will automatically generate keypair and signed the .apk for us for the debug purpose.
#ant release
this will require to specify keystore in build.xml.
for more details http://developer.android.com/guide/developing/building/building-cmdline.html
http://developer.android.com/guide/publishing/app-signing.html

Categories

Resources