251

I was trying to change my default/main/startup (whatever you call it) activity by editing the androidmanifest.xml file. All i did was change the android:name property. however, this completely broke the entire app. when I try to install it fails and reads.

Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES

When I tried to change it back to its previous state, it was still giving me the same error... What have I done?

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
mtmurdock
  • 12,756
  • 21
  • 65
  • 108
  • 1
    For anyone else: `INSTALL_PARSE_FAILED_NO_CERTIFICATES` is error `-103` that you can get/see via `adb log` ([src](https://github.com/aosp-mirror/platform_frameworks_base/blob/2ee069f73d2e9f978fd79b1c779930654d7f074b/core/java/android/content/pm/PackageManager.java#L1193)) [eg.](https://gist.github.com/howaboutsynergy/f2282242c52207659bd38c90623e31a6#gistcomment-2975056) `D/PackageInstaller(21320): Installation error code: -103` –  Jul 21 '19 at 03:12
  • 2
    answer is true .and there is one another reason that gives this error is when you have old application with the same package name in your phone installed.. just uninstall from your phone before you install the new one – Emre Kilinc Arslan Feb 11 '20 at 10:40
  • 8
    **To anyone who stumbles upon this question - read all of the answers** below! It seems like this error message is more of a "something is wrong" type of error. The reason I encountered it was due to one of the answers way, way down the list!!!! – GMc May 01 '20 at 06:49

39 Answers39

217

I found that this error can now also occur when using the wrong signing config. As described here, Android 7.0 introduces a new signature scheme, V2. The V2 scheme signs the entire APK rather than just the JAR, as is done in the V1 scheme. If you sign with only V2, and attempt to install on a pre-7.0 target, you'll get this error since the JARs themselves are not signed and the pre-7.0 PackageManager cannot detect the presence of the V2 APK signature.

To be compatible with all target systems, make sure the APK is signed with both schemes by checking both signature version boxes in Android Studio's Generate Signed APK dialog as shown here:

enter image description here

If only 7.0 targets are anticipated, then there is no need to include the V1 signature.

Paul Ratazzi
  • 6,289
  • 3
  • 38
  • 50
  • 5
    You saved my lots of time. Upgrading Android Studio caused nightmare of troubles. This was one of them. I wonder if SO wasn't around more than half of the Android Development would have died. Android Studio gives no clues about errors. – Atul Sep 06 '18 at 05:37
  • 7
    Luckily I tested my release apk on an old device before I rolled it out on Google Play. That would be a disaster if all < Android 7.0 devices failed to install the new version. That thing with two versions should be a BIG RED POP UP DIALOG when you click to create an apk release! – Kirill Karmazin Feb 12 '19 at 14:51
  • Thanks for this. About to go crazy looking for why my APK wouldn't run on below Android 7, but it was just a simple check box. So annoying. – japzone May 17 '20 at 22:28
  • but that dialog where did it come from? Mine is show nothing after i click the menu .... Build Menu | Build Bundled(s) / APK(s) | Build Bundle(s) – gumuruh Mar 29 '22 at 13:06
  • Things have changed a lot since I wrote this answer. In fact, there is now [APK Signature Scheme v3](https://source.android.com/security/apksigning/v3) which is replacing v2. You can read the current information about the 3 schemes and how to use them [here](https://source.android.com/security/apksigning). – Paul Ratazzi Apr 02 '22 at 02:17
77

Did you edit the AndroidManifest.xml directly in the .apk file? If so, that won't work.

Every Android .apk needs to be signed if it is going to be installed on a phone, even if you're not installing through the Market. The development tools work round this by signing with a development certificate but the .apk is still signed.

One use of this is so a device can tell if an .apk is a valid upgrade for an installed application, since if it is the Certificates will be the same.

So if you make any changes to your app at all you'll need to rebuild the .apk so it gets signed properly.

Nir Duan
  • 6,164
  • 4
  • 24
  • 38
David Webb
  • 190,537
  • 57
  • 313
  • 299
55

I found this was caused by 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. 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!

Ok here it is: C:\Program Files\Java\android-sdk\tools\ant\build.xml

            <signjar
                    sigalg="MD5withRSA"
                    digestalg="SHA1"
                    jar="${out.packaged.file}"
                    signedjar="${out.unaligned.file}"
                    keystore="${key.store}"
                    storepass="${key.store.password}"
                    alias="${key.alias}"
                    keypass="${key.alias.password}"
                    verbose="${verbose}" />
Community
  • 1
  • 1
Chloe
  • 25,162
  • 40
  • 190
  • 357
  • 3
    JDK 7 was also my problem. I was lazy and uninstalled JDK 7 and installed JDK 6, also worked ^^. Other hack solution but less radical could be let both installed but set JAVA_HOME to JDK 6 and put bin path of JDK 6 first in PATH. – User May 11 '12 at 10:38
  • 1
    JDK 8 has the same problem. Changing PATH to JDK 6 worked. Thank you lifesaver! – Chris Xue Aug 14 '14 at 21:56
  • Thanks! My market app was compiled with JDK6. When I compiled the app with release keystore using JDK7 and tried to install, it gave me this problem. – Sileria Oct 17 '14 at 14:44
  • delete the runtimeVersion: { policy: "sdkVersion", }, from the app.config.js file, run it, readd it, run it again. easier. – Ajna Apr 05 '23 at 21:06
38

Most of the time the solution for this error is really simple:

  1. Uninstall your apk
  2. Clean your Android project
  3. Build your Android project
  4. Install / run your apk
Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
JanCor
  • 605
  • 5
  • 3
  • I did 2,3,4 and get the same error. What do you mean by uninstall your apk? From my device? I don't think it has ever been on my device. – Curtis May 01 '20 at 19:29
  • i suddenly started getting this error out of nothing, None if the solution but simply cleaning project worked. Thanks. – pgcan Jun 05 '20 at 16:41
19

This error could be thrown if you add your signing config(create signing key and add to the "Project Structure" > "Modules" > "Signing Configs") but forget to point out in "Project Structure" > "Build Variants" > "Build Types" > "Signing Config".

The signing config field shouldn't be empty! (See the picture below) Otherwise, you will see

"INSTALL_PARSE_FAILED_NO_CERTIFICATES...APK signature verification failed." 

error if you try to install a release variant. (or another variant with the same misconfiguration)

Signing Config Example

eddym
  • 648
  • 7
  • 11
18

solved (for me) using in keytool the args

-sigalg MD5withRSA -keyalg RSA -keysize 1024

and using in jarsigner

-sigalg MD5withRSA -digestalg SHA1

solution found in

What kind of pitfals exist for the Android APK signing?

Community
  • 1
  • 1
Alejadro Xalabarder
  • 1,551
  • 19
  • 14
  • Thanks, fixed the problem for me too (I have JDK 7). – Enrico Ros Nov 08 '13 at 22:41
  • I've fixed it the same way, since I use appcelerator titanium and don't have access to the apk generation script. Note this solutions requires the regeneration (change!) of the private key. – Federico Jul 25 '14 at 20:46
18

Recently I had this error while upgrading to Android Studio 4.0. The cause was that the project had V2 Signing Disabled in the signing configuration in build.gradle.

The solution was to remove v2SigningEnabled false or explicitly set it to true, which is the default value.

android {    
    signingConfigs {
        dev {
            v2SigningEnabled true
        }
     }
}
mikehc
  • 999
  • 8
  • 22
11

I was also facing the same issue. First I generated build using V2 and installed that in mobile devices running on OS 5.1 and I got the same issue. But build was working fine on Tablet running on OS 7.0. So I generated build with V1 Jar signature and it was working fine on both the devices.

Conclusion: If you are supporting the device below android OS 7.0. Use V1 jar signature to generate the build.

Rajiv Ranjan
  • 333
  • 4
  • 13
  • No need to check both, Select V1 if you are supporting OS 7.0 and below Check V2 if you are supporting the devices running on 7.0 and above. – Rajiv Ranjan May 25 '20 at 23:18
9

In my case, I could build and run release builds, but got the INSTALL_PARSE_FAILED_NO_CERTIFICATES error when trying to do a debug build.

The solution was to delete my debug.keystore file and let ADT recreate it. It had apparently expired.

A better long-term solution is to explicitly create a debug.keystore that does not expire after only a year, instead of letting ADT create it. Here is the command to do that:

keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 14000

When prompted, enter these values:

  • First and last name: Android Debug
  • Organizational unit: Android
  • Name of organization: Unknown
  • City or Locality: Unknown
  • State or Province: Unknown
  • Country code: US
Kristopher Johnson
  • 81,409
  • 55
  • 245
  • 302
  • I had that issue exactly after switching back to debug build from profile build (wanted to test the performance of the app on my device, using VS Code), deleting the debug.keystore file (located in C:\Users\user\.android) and running the app again in debug mode fixed it. – Jesús Hagiwara Jan 14 '22 at 00:37
8

In my case, I was installing a project with MinimumSDK bigger than the Android version of my real device. I used another device and it solved.

My project MinSDK -> 24

My Phone Android version -> 21

iman kazemayni
  • 1,255
  • 1
  • 19
  • 20
7

most answers are true . and some another reasons that happens are

► your min sdk smaller than device sdk.
► you have the older application in your device with the same package name

Emre Kilinc Arslan
  • 2,019
  • 2
  • 16
  • 12
  • This was my experience - The min sdk in my project was higher than the device sdk. It happened because I "missed" the correct selection when I was creating the project in Android Studio and accidentally selected the next higher version as my SDK then my old tablet was running. – GMc May 01 '20 at 06:47
  • making equal my min sdk and device sdk solved my problem. – Nuwan Harshakumara Piyarathna Jun 19 '20 at 16:03
6

In newer Android Studio versions 3.2+, if you are trying to run release install, and you have not defined any signing configurations, it will show the error prompt and install will fail. What you need to do is either run the debug build or set up the signing configuration (V1 or V2) correctly.

Otieno Rowland
  • 2,182
  • 1
  • 26
  • 34
5

This is an ugly but fast solution: use JDK 6 instead of 7.

After read Chloe's answer, I uninstalled my JDK 7 (don't need it currently anyways) and installed JDK 6. That fixed it. A better solution would make ant uses JDK 6 (without uninstalling 7). Maybe possible changing / setting this property:

java.library.path

in local.properties file. It's in the project directory (root).

Android doesn't work with JDK 7 anyways (only 6 or 5), so make that the ant script also uses JDK 6 or 5 is probably a good solution.

User
  • 31,811
  • 40
  • 131
  • 232
5

Its because previously generated build and current is having conflict in signature version between v1(jar signature) and v2(full APK Signature),

To fix tick proper signature version under Generate Signed APK dialog

Pankaj kumar
  • 1,357
  • 14
  • 13
4

Navigate to Run -> Edit Configurations... -> Android App -> app -> Installation Options

Then change to APK from app bundle instead of Default APK enter image description here

fahrizal89
  • 598
  • 5
  • 13
3

Also u can check

Project Structure -> Default Config -> Signing Config

after u add all that u need

Morozov
  • 4,968
  • 6
  • 39
  • 70
2

This could happen if you try to include a .jar library that contains an AndroidManifest.xml file.

  • If it's pure Java make sure you don't include it in the .jar export
  • If it's not pure Java (meaning it's an Android project) then you have to include it as a Library Project
znat
  • 13,144
  • 17
  • 71
  • 106
2

Make sure the build variant is set to debug (and not release) in Android Studio (check the build variants panel).

Shoejep
  • 4,414
  • 4
  • 22
  • 26
shubomb
  • 672
  • 7
  • 20
2

Maybe, you have changed the build variant from debug to release. Release variant requires a special certificate. You can change build variant under menu build->select build variant... .

devalapar
  • 21
  • 1
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30786619) – Bestmacros Jan 17 '22 at 11:41
  • This was exactly the problem I had when I encountered this error @Bestmacros, please give this user a break. – masterxilo Oct 29 '22 at 13:42
1

Setting environment variable JAVA_HOME to JDK 5 or 6 (instead of JDK 7) fixed the error.

TN.
  • 18,874
  • 30
  • 99
  • 157
1

I was getting this error because I did release that my ant release was failing because I ran out of disk space.

Red Cricket
  • 9,762
  • 21
  • 81
  • 166
1

It's throwing this error for me today because I have an app with a min sdk of 28 and am hitting play on an emulator with an SDK version of 23. Usually this is not possible (AS gray's out the play button), but today not so much.

Daniel Wilson
  • 18,838
  • 12
  • 85
  • 135
1

For me, I forget to add the new Signing Config into

Project Structure -> Default Config -> Signing Config

Mohamed Ben Romdhane
  • 1,005
  • 3
  • 11
  • 22
0

After some time and multiple online threads on the subject I managed to fix my project.

It's mainly taking into consideration the last files (could be images or layouts) that you put in. If you delete them, it will work out, and you can build your project again.

Nikhil
  • 16,194
  • 20
  • 64
  • 81
0

I was having this error in my Eclipse Console. It turns out that I had two jars with the same content but different names and they were conflicting with each other. I just deleted one of them and managed to install the app on the device.

joao2fast4u
  • 6,868
  • 5
  • 28
  • 42
0

I got this error when I tried to install a Xamarin project built against Android N preview on a phone running api v23. Solution is to not do that.

James Moore
  • 8,636
  • 5
  • 71
  • 90
0

Another way to get this error is to build using ant on macOS and have a Finder icon file (Icon\r) in the source tree of the app. It appears jarsigner can't cope with the carriage return in the filename and, although it will claim the signing is valid if you -verify the APK, it always results in an APK that wont install on a device. Ironically, the Google Drive Finder plugin is a great source of Finder icon files.

The solution is to exclude the offending files (which are useless in the APK anyway) with a specifier like this in the fileset:

    <exclude name="**/Icon&#13;" />
Perry
  • 1,152
  • 10
  • 14
0

This problem will happen if you are installing un-signed version of APK. Check if you are install correct APK.

NeeK
  • 662
  • 1
  • 8
  • 21
0

I had that problem with ionic / Visual Studio Code (Run Android on device):

I uninstalled the App on the mobile device (Settings / Apps), the error is gone and the app is starting.

Michael Maier
  • 208
  • 2
  • 11
0

Firstly just try to do that:

  • go to Gradle script → bulid.gradle(module:app) → then you have to change (minSdkVersion) value. As an example, if you used 26 you can try to decrease the value, like (minSdkVersion 20 )
  • then try (sync now ).
Alexey Vazhnov
  • 1,291
  • 17
  • 20
0

If you are using emulator then try reset it and if you at mobile first uninstall the application then switch off the developer mode, and then switch it on the problem will be solved.

Shashank Pandey
  • 683
  • 6
  • 14
0

I encountered this issue in the JetBrains Rider IDE.

Full Error

INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates from /data/app/vmdl1252907876.tmp/base.apk: Attempt to get length of null array

The problem was a result of using JDK8. Switching to JDK11 solved the issue.

enter image description here

Ryan Payne
  • 5,249
  • 4
  • 28
  • 69
0

open the terminal, write Clean project->hit enter->this problem will be solved automatically within few seconds.

0

Simple but silly fix for me was installing JRE and JDK.

I started a new Kotlin project with a fresh install of Android Studio for a work assignment. I tried to build the default template to an emulated phone and got the given error.

I did the following:

  • installed the latest JRE and JDK versions
  • Opened CMD and did java -version to ensure it was installed. It came back with a valid version message.
  • Restarted Android Studio and loaded my project
  • Click the Play button to install to my emulated device.
  • All working fine.
James Gould
  • 4,492
  • 2
  • 27
  • 50
0

For Xamarin users building and distributing on app center, uninstalling may not solve this. The problem can be if you upgrade your target sdk to 30+, you need to reupload your keystore file to the app center build config. This will force app center to sign with v2, which is required from v30 onwards. Full credit to this github issue comment

Adam Diament
  • 4,290
  • 3
  • 34
  • 55
0

This issue happened to me with the new run on multiple devices feature on android studio.

I had 3 emulators with api levels 22 , 27 and 30. I got this error with the multiple run option but it didn't happen when I installed my app on each device separately.

0

If you are using Azure build pipelines, and you are using the Android Signing task to sign your APK, make sure to use version 3+ to sign your app. This enables the v2 scheme Android signing which is required for Android 11+.

Tinus
  • 193
  • 4
  • 11
0

This error can happen for many reasons. Check in the Event Log for more details. In my case, I was getting this error:

Failed to commit install session 1278974094 with command cmd package install-commit 1278974094. Error: INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed collecting certificates for /data/app/vmdl1278974094.tmp/0_app-debug: Failed to collect certificates from /data/app/vmdl1278974094.tmp/0_app-debug: Attempt to get length of null array

This might be dumb, but I couldn't find the answer for months, and this was only happening with my company's project. If I created a brand new project, it installed perfectly fine.

If you're on Windows, do you have Java installed? Check if you have a C:\Program Files\Java\jdk1.8.0_your_version folder.

If you don't, download the JDK from the official Oracle website. And add variable JAVA_HOME with value "C:\Program Files\Java\jdk1.8.0_your_version" to the environment variables and then add JAVA_HOME to the PATH too.

Now try installing again.

-1

You can also just change the build variant to Debug and you should be good to goenter image description here

Pascal Nitcheu
  • 667
  • 7
  • 8