"Parse Error : There is a problem parsing the package" while installing Android application

Viewed 419415

I got this error while installing the android application (Parse Error : There is a problem parsing the package.). I did the following steps.

  1. First time I installed the application and it works fine.

  2. I made changes to the existing application and change the version no in Manifest file.

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.openintents.samples.BasicOpenARDemo" android:versionCode="2" android:versionName="1.0.1">
    
  3. Then I export the application and finish the code signing process. For this, Right Click your Project node > select Export. There you will see a wizard. Follow the steps and finish the code signing also.

  4. I got the ARDemo.apk file, Then I changed it’s name to ARDemo1.apk

  5. Then I shipped this apk file to mobiles SD Card and started the installation I got the above error.

I googled, they say that problem with unpacking manifest file.

Can anyone tell me what could be wrong with me?

28 Answers

Instead of shooting in the dark, get the reason for this error by installing it via adb:

adb -s emulator-5555 install ~/path-to-your-apk/com.app.apk

Replace emulator-5555 with your device name. You can obtain a list using:

adb devices

Upon failing, it will give a reason. Common reasons and their fixes:

  1. INSTALL_PARSE_FAILED_NO_CERTIFICATES: Reference
  2. INSTALL_FAILED_UPDATE_INCOMPATIBLE: Reference

As mentioned by @Veneet Reddy install it via ADB.

Go to ADT Bundle/sdk/platform-tools past your .apk file and run command prompt as administrator.

Then run adb devices command which will list the connected devices or emulators that are running.

enter image description here

Then run adb -s yourDeviceID install yourApk.apk

enter image description here

Note: uninstall the app if you have already installed before installing again.

I have had this problem Parse Error : There is a problem parsing the package. I was testing on Android-8. I have same apk with same signature .Everything was same without the version number and version name. App was installing when I install it manually but this error occurred when I was downloading and installing updates programmatically. Then I have found my cause of problem.

There was an option to check canRequestPackageInstalls () When this method returns true then app get installed successfully. It was returning false always in my case.

So first I check this and then let the user to download and install updates.

In onCreate()

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            if (!packageManager.canRequestPackageInstalls()) {
                    startActivityForResult(
                        Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES).setData(
                            Uri.parse(String.format("package:%s", packageName))
                        ), requestCodeqInstallPackage
                    )
                } else {
                    canInstallPackage = true
                }

        }

In onActivityResult()

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
            if (requestCode == requestCodeqInstallPackage && resultCode == Activity.RESULT_OK) {
                if (packageManager.canRequestPackageInstalls()) {
                    canInstallPackage = true
                }
            } else {
                canInstallPackage = false
                Toast.makeText(mContext, "Auto update feature will not work", Toast.LENGTH_LONG)
                    .show()
            }
    }

Then when need to install update then-

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
   if(canInstallPackage){
      doInstallAppProcess()
   }else{
        // generate error message
   }
}

Hope it will help someone.

If you are facing this issue in device using android 12. You can fix it by adding android:exported="true" in AndroidManifest.xml as mentioned below

<activity
            android:name=".MainActivity"
            android:exported="true"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
            android:label="@string/app_name"

use it inside build.gradle (Module:app)

minSdkVersion 14
targetSdkVersion 28

This error also comes when Android version is less than minSdkVersion

In my case build 1 was installed correctly in my mobile using the signed APK (also from Google Play Store). But when I update the application with build 2 for first time, I had an issue installing it with the signed APK as I got "There was a problem parsing the package".

I tried several methods as specified above. But did not work.

After some time, I rerun the commands

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-key.keystore app-release-unsigned.apk myappkeyalias
zipalign -v 4 app-release-unsigned.apk MyApp.apk

and surprisingly, it worked.

It seems sometimes the APK built might be corrupt. So, Re-running jarsigner and zipalign commands resolved my issue.

In my case i written <activity android:".Stopwatch"/> instead of <activity android:name=".Stopwatch"/> in android manifest.

Check your manifest and gradle file again.

Related