Search code examples
androidandroid-studiopackage-managers

Installing APK not working, but deploying from Android studio works


Edit

The APK is a signed one which have the problem, while installing directly from android studio causes no issues. (Only using the APK).

After finishing developing the app I tried to generate an APK and give to a friend for a test; He said it's not working (not installable). So I grapped the phone Motorolla with Android 6.0.1 and tried to debug the problem from the Android Monitor in Android studio and this was the error there :

unable to parse package file android

Then i tried the same APK on the same phone i was using to test (Samsung J3 with 5.1.1 Android version) and got the following error in the logs of Android monitor:

Class not found when unmarshalling: com.android.packageinstaller.InstallFlowAnalytics

I never had this or something like it before, googled a bit and tried to find an answer on SOF found a couple of answers which none of them worked.

  • disabled proGuard
  • added android:extractNativeLibs="true" to manifest
  • Increased/Decreased the SDK version

as I said none of these worked, any idea ?

This is my manifest and my Gradle files :

Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="my.package.myapp">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:icon="@drawable/ice_launder"
        android:label="@string/app_name"
        android:roundIcon="@drawable/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name="my.package.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="my.package.MoreLikeThisActivity" />
        <activity android:name="my.package.SearchResultActivity" />
        <activity android:name="my.package.LastResultsActivity" />
        <activity android:name="my.package.CompanyDetailsActivity" />
        <activity android:name="my.package.OnboardingActivity"/>
    </application>

</manifest>

Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "my.package.myapp"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral() // jcenter() works as well because it pulls from Maven Central
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.code.gson:gson:2.8.1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.github.bumptech.glide:glide:4.0.0'
    compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
    compile 'com.ogaclejapan.smarttablayout:library:1.2.1@aar'
    testCompile 'junit:junit:4.12'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'
}

Solution

  • just build your project by Build >Build APK

    while using signed apk make sure you have checked both the checkbox v1 and v2