1

My apk file format is like this:

xxxx-debug.apk
xx-xxx-debug-xxx-1.0.1.apk

I can download the apk files but I cannot install them. I'm facing the following error:

Parse error
    There was a problem while parsing the package.

Code used for Installation:

protected void install(String fileName) {
    Intent install = new Intent(Intent.ACTION_VIEW);
    install.setDataAndType(Uri.fromFile(new File(fileName)),"application/vnd.android.package-archive");
    startActivity(install);
}

When the apk file are downloaded, a number is appended at the end of the file e.g. some.apk becomes some-1.apk.

What I have tried/checked so far:

  • check on the option “Unknown sources.”
  • uses-permission android:name="android.permission.INSTALL_PACKAGES" tools:ignore="ProtectedPermissions"
  • android device version is 5.0.1
  • apk files are not corrupted because I've managed to install it in a different way
Benjamin
  • 7,055
  • 6
  • 40
  • 60
Tony
  • 529
  • 2
  • 6
  • 24

3 Answers3

0

Please try disabling instant run and then generate apk.It will work.Hope it helps.

Anu Bhalla
  • 422
  • 4
  • 11
0

I faced this issue previously. This is how I debugged it. First, install the APK through terminal adb install path_to_your_app/name_of_your_app.apk if you get error message: adb: failed to install name_of_your_app.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries this means that the architecture that you are building mismatches with the emulator architecture.

The way I fixed this issue is by forcing the build architecture in build.gradle

    buildTypes {
        debug {
            ndk {
                abiFilters 'x86_64'
            }

Hope this helps

Angie
  • 21
  • 2
0

I had this same problem and for me the issue was the Minimum API Level. I had the minimum API too high, which means some devices were not able to use the app. In Unity go to: Player Settings > Other Settings > Identification >

Minimum API Level: This should be set to the minimum which for me Android 4.4 'KitKat' (API level 19) Maximum API Level: This should be set to the maximum according to Google, see link https://developer.android.com/distribute/best-practices/develop/target-sdk