121

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?

Jeremy Stein
  • 19,171
  • 16
  • 68
  • 83
Raghu
  • 2,279
  • 6
  • 23
  • 21
  • 4
    just thinking why does renaming became a problem? – Mikey Feb 22 '11 at 12:25
  • Hello Mike, I changed the name after export. That's why It is giving error. If we specify a diff name while exporting it couldn't be a problem for me.. – Raghu Feb 22 '11 at 12:25
  • why should the SDK version matter? If I build using SKD 2.1 and want to use it on 2.0, why should it be a problem? –  Feb 22 '11 at 12:26
  • 1
    Hello Cru, Changeing version no doesn't created this problem. I have renamed the apk file once I did the export. It creates this problem. – Raghu Feb 22 '11 at 12:26
  • you should put version number on three. please refer to the japanese tutorial on wikitude website –  Dec 20 '09 at 13:58
  • Hi Ejder, Thanks for ur response. My problem was already fixed. My mistake is "I have changed the apk file name manually". In above 2 is my application version code not the minsdk value. I put the minsdk value as 3. Thanks & Regards, Raghavendra K – Raghu Dec 21 '09 at 11:22

31 Answers31

53

You said that the first time you installed the application it worked fine.

The only difference in the steps you outlined between the two versions are:

  1. The version number (I'm assume that this did not participate in breaking anything)
  2. The code
  3. The name of the .apk file

Try renaming the ARDemo1.apk file back to ARDemo.apk (make sure to back up the older version) and see if that helps. My guess is that it has something to do with the name of the apk.

If it still does not work, then you can eliminate the name of the apk file as the source of the problem and start investigating 2) by rebuilding your old version and see if you have same problem again. If the problem does not exists with the rebuilt version of your old code then you know it must be something to do with your code.

I hope that gets you somewhere.

Cheers, Joseph

user175750
  • 746
  • 6
  • 5
  • Hi Joseph, Your guess is correct. I renamed the apk file to earlier one. It works...... Thank You very much for your help..... – Raghu Oct 05 '09 at 03:25
  • Hi, I am facing a similar problem. I am downloading the application from a web link. It sits on the mobile SDCard perfectly. But when I am trying to install it is showing this error. I didn't sign my application, basically I am a newbie to Android app development. Help of any sort is appreciated :) – varunrao321 May 02 '12 at 13:11
  • 2
    I faced the similar problem and the case was minimum SDK version in .gradle file. Think about that and your device's version and that will be helpful. – user2881604 Nov 26 '15 at 10:29
  • Ya, you are correct that was the problem of the apk file name...! – Arsal Imam Dec 29 '15 at 18:37
  • I renamed the apk file and the `parse error` is gone, but when trying to install it now it shows me `App not installed` I'm using a marshmallow device and maybe its the same as the issue in here http://stackoverflow.com/questions/33930223/cannot-upgrade-old-application-by-android-studio-generated-apk-file-in-lollipop – natsumiyu Nov 09 '16 at 07:48
  • Hi Joseph, I have generated an apk file using android studio but i am not able to install that file in epson moverio bt-200. when i touch apk file, device does not give any response. i have not installed any separate sdk except android sdk to develop app. minsdkversion is 14 and targetsdk version is 25 still i am not able to install the app. @user175750 – Dhruvam Gupta Apr 14 '17 at 05:52
  • some times i am facing this problem while decrypting to .apk from encrypted .txt file. can i handle inside the code? – Ashik Azeez Aug 08 '19 at 05:31
47

Installation can give the specified error at least in following cases:

  • Name of the package is changed after signing: Use the exact name as the signed package is (instead, adjust the name in Manifest)
  • Package is compiled against on higher API level: Correct the API level in Manifest file
  • Package is executed from SD-card: Run (install) the apk -file from phones memory OR use adb command to install it
jmu
  • 3,619
  • 1
  • 23
  • 12
  • I think there are other conditions that can make this happen. For instance, see my comment on kansasian's answer below about getting this error message when installing from email. – M Katz Jan 19 '13 at 23:10
  • Best answer here. For me it was changing the name of the package after it was signed. Thanks a lot. – Jannie Theunissen Aug 15 '13 at 07:18
  • i'm assuming you need to have a rooted phone to be able to install it using `adb install` right? – abbood Feb 22 '14 at 07:52
  • Nope: Rooting is _not required_ - you may need to enable Unknown sources from Security settings, though. (unconfirmed) – jmu Feb 28 '14 at 07:40
  • Unknown sources AND usb debugging... note: in windows 8 sometimes it will not recognize the phone in MTP mode, only PTP... – SparK Apr 17 '14 at 15:02
  • Thank you! For me it was the `minSdkVersion` it was higher than the android phone I was using to install the APK. Lowering it works fine – Sam Jul 31 '20 at 22:36
25

I've only seen the parsing error when the android version on the device was lower than the version the app was compiled for. For example if the app is compiled for android OS v2.2 and your device only has android OS v2.1 you'd get a parse error when you try to install the app.

Sir Scalawag
  • 251
  • 3
  • 2
19

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
Veneet Reddy
  • 2,707
  • 1
  • 24
  • 40
14

The reason is apk is not signed. Once the apk is signed, the issue will be resolved. http://ionicframework.com/docs/guide/publishing.html Please use the link on instructions to sign the apk.

Shivendra
  • 1,542
  • 2
  • 22
  • 35
  • Same problem here. After signing the apk, it worked as expected. – Dino Tw Mar 08 '16 at 00:32
  • 3
    This was a problem for me with Xamarin Android builds - it first creates an APK in the Archive Manager that is unsigned. You have to then choose "Distribute" to create a signed APK that can be installed. – dodgy_coder Nov 15 '16 at 08:52
  • Adding to what dodgy_coder wrote: for [Xamarin.Android 7 or greater](https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_2_-_signing_the_android_application_package/) or [earlier versions](https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_2_-_signing_the_android_application_package/visual-studio-xa-4.2.6-to-6.1/). – Veverke Mar 01 '17 at 12:50
7

Check whether your device supports the version you specified in minSdkVersion in AndroidManifest.xml . If not specify the lower version and try again

7

If you're compiling and exporting your apk file under SDK version 2.1, it will not work on any android version below your SDK export "2.1". Android software is forward compatible not backward compatible. For example if you're programming using the android NDK (ann add-on to the android SDK) package that allows development in the C/C++ family, this is only compatible with android 2.3, android version 2.2 and below support java builds only. Therefore you will reaceive the "There is a problem parsing the package" error.

Mike
  • 71
  • 1
  • 1
5

I'm not repeating what is instructed here to input the Key store, password, etc. Try

Build -> Generate Signed APK -> [ Input ] ---Next---> select BOTH

  • V1 (Jar Signature)
  • V2 (Full APK Signature)

I don't know why, but at least it worked in my situation.

JeffNhan
  • 363
  • 3
  • 3
  • 1
    Worked for me. It was not checked in Android Studio MacOS by default. – vojta May 16 '18 at 10:40
  • 1
    I had the same problem for older Android versions before 7.0. But I only used V2 (Full APK Signature). This was sufficient for newer Android versions. When you provide versions before 7.0 you MUST also use V1 (Jar Signature)! – Harald Mandl Oct 20 '20 at 09:00
3

Another possibility is that you have saved the apk file into application PRIVATE folder and then try to install (by starting an intent from your code). in this case, when you start intent, you get error parsing package. In this case, the raised error is about permission issues. The point is saving the file into private folders is not a good practice, however if you really want to do that, you should write file in MODE_WORL_READABLE when you download it. Please consider that MODE_WORLD_READABLE is deprecated and this solution is not the best as it has some security issues. The best is to save your file in an external storage.

MojAmiri
  • 506
  • 7
  • 8
3

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"
Anupam Chaplot
  • 1,134
  • 1
  • 9
  • 22
2

I got the same error (Parse Error, There is a problem parsing the package) while trying to install an .apk package from email. I was able to get around the problem by installing the 3rd party package installer ApKatcher:

http://www.addictivetips.com/mobile/install-android-apps-from-gmail/

ApKatcher isn't the only solution. A colleague of mine got around the problem by installing Astro File Manager.

You can find both applications in the Android Marketplace.

kansasian
  • 99
  • 2
  • To add another data point here, I was also getting this error when installing from email, but it installed fine when I used a cord and adb to install the same package. Unfortunately I was trying to install via yahoo mail, so I don't think ApKatcher could help. – M Katz Jan 19 '13 at 23:09
1

And just to help possible new readers, another reason may be errors in the manifest file. I had mistyped android:service as android.service and ran into the same error...

dsh
  • 12,037
  • 3
  • 33
  • 51
MortenSickel
  • 2,118
  • 4
  • 26
  • 44
1

Similar issue, using this "borrowed" and slightly modified code:

                Intent intent = new Intent(Intent.ACTION_VIEW);
                File newApk = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "myapp.apk");
                intent.setDataAndType(Uri.fromFile(newApk), "application/vnd.android.package-archive");
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
                result = true;

Needed to change the file creation to this (comma instead of plus in the File constructor, was missing '/' after the download directory):

                    File newApk = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "myapp.apk");
William T. Mallard
  • 1,562
  • 2
  • 25
  • 33
1

I had a bad tag pair in my manifest file.

<meta-data>
</meta-data>

Basically got in when I copied a bad meta-data sample code from payu pdf file. Crap.

Siddharth
  • 9,349
  • 16
  • 86
  • 148
1

One reason could be, that your activity'name is not defined in the manifest

    <activity
          android:name=""
          ...>
</activity>

above code was creating the same issue with me

Abhishek
  • 1,337
  • 10
  • 29
1

Another problem causing this error can be installing APK from restricted SD card mount point /mnt/media_rw/MicroSD.

Use unrestricted mount point /Removable/MicroSD.

Honza
  • 974
  • 10
  • 18
1

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.

Muhammad
  • 6,725
  • 5
  • 47
  • 54
1

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.

Rasel
  • 5,488
  • 3
  • 30
  • 39
0

For anyone else having this issue the only time i ever got this error was when the API version in your Android Build configuration does not match what's on the physical device.

Go into Eclipse and right click on your project and go to properties. Select Android--WHICH BRINGS YOU TO ANDROID BUILD TARGET. Adjust you target to match the device and see if that resolves the issue.

j2emanue
  • 60,549
  • 65
  • 286
  • 456
0

I had this problem, even when I specified the correct minSDK and targetSDK version. My problem was, I was using "android:theme="@android:style/Theme.NoTitleBar.Fullscreen" in launcher activity, on Jellybean device. When I removed this attribute, it worked.

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
user1035292
  • 1,378
  • 12
  • 14
0

As a couple of the other answers have mentioned, there can be problems when installing from the SD card. In my case I was distributing my app via email attachment, and it usually worked fine. Just open the email and download the attachment (it apparently goes to the SD card) and click on it again and it gets installed.

But then one day it didn't work, and it turned out it was because I had the phone connected to my development PC via USB, and that placed the SD card in a different mode or something. So the solution was simply to disconnect the phone from the PC and then send the e-mail again and download the attachment again. Or else place the USB connection in "charging only" mode so the SD card is not "connected" to the PC.

RenniePet
  • 11,420
  • 7
  • 80
  • 106
0

You might also want to check the logs on the device to see if it's something simple like a permissions problem. You can check the logs using adb from a host/debug computer:

adb logcat

Or if you have access to the console (or when using Android-x86 get console by typing Alt+F1) then you can check the logs by using the logcat command:

logcat
Pierz
  • 7,064
  • 52
  • 59
0

I had the same problem using the apk file exported from android‌ Tools > Export. I used the apk file in bin folder instead and it worked!

P.S. apk file in bin folder is created after first time you run the application in eclipse.

Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82
0

use it inside build.gradle (Module:app)

minSdkVersion 14
targetSdkVersion 28

This error also comes when Android version is less than minSdkVersion

Ishaan Kumar
  • 968
  • 1
  • 11
  • 24
SHUBHASIS MAHATA
  • 873
  • 7
  • 12
0

In my case I signed with only V2 signature (from Android 7 onward) but tried to install on 5 and 6. Adding V1 during ARK generation/signing fixed the issue.

See Difference between signature versions - V1 (Jar Signature) and V2 (Full APK Signature) while generating a signed APK in Android Studio?.

Alex Martian
  • 3,423
  • 7
  • 36
  • 71
0

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.

Naveen Kumar V
  • 2,559
  • 2
  • 29
  • 43
0

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

Check your manifest and gradle file again.

0

Try this it works for me-

Changing the compileSdkVersion and targetSdkVersion to 31 or later will not let build the app on some devices, do the following thing-

In tags to be included with android:exported="true" or android:exported="false".

Aditya Nandardhane
  • 915
  • 1
  • 8
  • 22
0

Install android studio version 2020.3.1 Canary 2

update AndroidManifest.xml

compileSdkVersion 30

targetSdkVersion 30

It will fix your issue for Android 12

0

<activity android:name=".MainActivity"

        android:exported="true" ---------> add this line in AndroidManifest.xml file 
Nikhil Kadam
  • 109
  • 4
-1

I am experiencing the same “Parse error: There is a problem parsing the package “ error message with my signed APKs as others but I suspect it could be caused by different reasons.

To test this I did the following:

Setup Windows 8.1 Eclipse ADT Build: v22.6.2-1085508

I generated a typical new Helloworld app accepting all defaults.

I ran the app on an emulator and live device successfully.

I then sideloaded and installed the apk to my live device and ran it successfully.

It had generated an apk in the bin folder with a size of 782 KB.

I then exported the Helloworld app to the same bin folder signing the app from my key store which has been used successfully in the past to promote to Google Play.

It created an APK with a size of 385 KB (replacing the original apk).

I sideloaded the apk to my device and when I went to install it I got the error “Parse error: There is a problem parsing the package” (this is the same package that sideloaded and installed when done as a non exported form).