Android: it is not possible to install the release on the emulator; rejection received [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION]

I can install the debug assembly on the emulator:

ant debug install 

but I can not install the release build. My steps:

 1. ant release 2. jarsigner -verbose -keystore ..\my-release-key.keystore bin\myapp-release-unsigned.apk mykey 3. ren bin\myapp-release-unsigned.apk bin\myapp-release-signed.apk 4. zipalign -v 4 myapp-release-signed.apk myapp-release.apk 5. adb install bin\myapp-release.apk 

All steps are successful, except for the last one where I get the message:

 82 KB/s (388012 bytes in 4.613s) pkg: /data/local/tmp/myapp-release.apk Failure [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION] 

I also tried to do ant installr instead of adb install bin\myapp-release.apk with the same result

EDIT: I think this is related to the key, as this is the only difference that I see between release builds and debugging. I generated a key using:

 keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 

as stated at http://developer.android.com/guide/publishing/app-signing.html . I changed the ant.properties file to http://developer.android.com/guide/developing/building/building-cmdline.html and now I'm just doing ant release install (instead of the steps above), but still facing the same problem . If someone knows how to ant generate a debug key, I could follow the same procedure to generate my release key and see if this solves the problem.

+7
source share
3 answers

Decision https://stackoverflow.com/a/216158
Notes:
1. I received INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION. I did not receive INSTALL_PARSE_FAILED_NO_CERTIFICATES
2. Running adb logcat from the cmd line showed that stacktrace is similar to the one in Android with Ant :

 W/PackageParser( 51): Exception reading /data/app/vmdl24231.tmp W/PackageParser( 51): java.lang.SecurityException: META-INF/METALLIC.SF has in valid digest for assets/myasset.xtx in /data/app/vmdl24231.tmp W/PackageParser( 51): at java.util.jar.JarVerifier.verifyCertificate(J arVerifier.java:370) W/PackageParser( 51): at java.util.jar.JarVerifier.readCertificates(Ja rVerifier.java:273) W/PackageParser( 51): at java.util.jar.JarFile.getInputStream(JarFile. java:416) W/PackageParser( 51): at android.content.pm.PackageParser.loadCertific ates(PackageParser.java:317) W/PackageParser( 51): at android.content.pm.PackageParser.collectCerti ficates(PackageParser.java:479) W/PackageParser( 51): at com.android.server.PackageManagerService.inst allPackageLI(PackageManagerService.java:4287) W/PackageParser( 51): at com.android.server.PackageManagerService.acce ss$1600(PackageManagerService.java:109) W/PackageParser( 51): at com.android.server.PackageManagerService$5.ru n(PackageManagerService.java:3779) W/PackageParser( 51): at android.os.Handler.handleCallback(Handler.jav a:587) W/PackageParser( 51): at android.os.Handler.dispatchMessage(Handler.ja va:92) W/PackageParser( 51): at android.os.Looper.loop(Looper.java:123) W/PackageParser( 51): at android.os.HandlerThread.run(HandlerThread.ja va:60) 

Literature:
http://code.google.com/p/android/issues/detail?id=19567

+5
source

I had the same problem because I used the string value in my AndroidManifest.xml file as follows:

 android:versionCode="@string/version_code" android:versionName="@string/version_name" 

Where strings.xml contains:

 <string name="version_code">3</string> <string name="version_name">1.0</string> 

versionCode must be an integer. As soon as I extracted this @string link, I no longer got this error, and the application compiled and works fine:

 android:versionCode="3" android:versionName="1.0" 
+11
source

I had the same error, but when I looked in logcat trying to install the apk file on the phone, I saw these lines:

11-10 11: 28: 26.971 20075 20085 D: Zip: EOCD not found, /data/local/tmp/myapp.apk - not zip

11-10 11: 28: 26.972 20075 20085 W zipro: opening the error archive /data/local/tmp/myapp.apk: Invalid file

11-10 11: 28: 26.972 20075 20085 Object D: Could not open the Zip archive '/data/local/tmp/myapp.apk'

11-10 11: 28: 26.972 20075 20085 W DefContainer: failed to parse package in /data/local/tmp/myapp.apk: android.content.pm.PackageParser $ PackageParserException: could not parse / data / local / tmp / myapp .apk

As mentioned in another question , it turned out that the apk file was damaged (maybe it did not load correctly), so I had to download it again, then it worked fine.

+1
source

All Articles