Android 'Application not Installed' java.lang.SecurityException [invalid digest for] or [Package ... has no certificates at entry]
07 August 2013
How to solve Android 'Application not Installed' caused by java.lang.SecurityException [invalid digest for] or [Package ... has no certificates at entry] when we sign an Android APK and install it in an Android device.
The Problem
We sign an Android application (APK) using jarsigner signing tool. While installing the signed APK in an Android device we get the following exception in LogCat:
Exception reading res/drawable/[some_resource].xml in /data/app/vmdl125026663.tmp
java.lang.SecurityException: META-INF/[YOUR_APP].SF has invalid digest for res/layout/[some_resource].xml in /data/app/vmdl125026663.tmp
at java.util.jar.JarVerifier.invalidDigest(JarVerifier.java:131)
at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:350)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:258)
at java.util.jar.JarFile.getInputStream(JarFile.java:378)
at android.content.pm.PackageParser.loadCertificates(PackageParser.java:364)
at android.content.pm.PackageParser.collectCertificates(PackageParser.java:565)
at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:7113)
at com.android.server.pm.PackageManagerService.access$1600(PackageManagerService.java:170)
at com.android.server.pm.PackageManagerService$5.run(PackageManagerService.java:5639)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)
Package your.app.package has no certificates at entry res/drawable/[some_resource].xml; ignoring!
GC_EXPLICIT freed 2798K, 26% free 17142K/23139K, paused 5ms+15ms
java.lang.SecurityException: META-INF/[YOUR_APP].SF has invalid digest for res/layout/[some_resource].xml in /data/app/vmdl125026663.tmp
at java.util.jar.JarVerifier.invalidDigest(JarVerifier.java:131)
at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:350)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:258)
at java.util.jar.JarFile.getInputStream(JarFile.java:378)
at android.content.pm.PackageParser.loadCertificates(PackageParser.java:364)
at android.content.pm.PackageParser.collectCertificates(PackageParser.java:565)
at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:7113)
at com.android.server.pm.PackageManagerService.access$1600(PackageManagerService.java:170)
at com.android.server.pm.PackageManagerService$5.run(PackageManagerService.java:5639)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)
Package your.app.package has no certificates at entry res/drawable/[some_resource].xml; ignoring!
GC_EXPLICIT freed 2798K, 26% free 17142K/23139K, paused 5ms+15ms
The Solution
One of the common causes of the problem mentioned above is the usage of JDK 1.7 to sign the APK.
A possible solution is to include the following arguments in your jarsigner command:
-digestalg SHA1 -sigalg MD5withRSA
Other solution is to run jarsigner from JDK 1.6.