Derek
Derek

Reputation: 11915

Android Dynamic Feature INSTALL_FAILED_INVALID_APK

I am trying to add some functionality to an existing application. The app's build.gradle contains several productFlavors and a couple of buildTypes. I have tried to replicate that as best I can in my dynamic-feature module, but I cannot seem to get it to install properly from Android Studio.

I followed the example from: https://github.com/googlearchive/android-dynamic-features to set up my feature module, so my project is structured like

app
features/module/build.gradle
build.gradle

I added a buildType and flavor to the app build.gradle

defaultConfig {
    minSdkVersion 24
    targetSdkVersion 28
 }
dynamicFeatures = [":features:module"]
buildTypes{
    myBuildType {
        debuggable true
        multiDexEnabled true
    }
}

flavorDimensions "blah"
productFlavors{
        arm64 {
            ndk {
                abiFilters "arm64-v8a"
            }
            ext {
                abiVersionCode = 5
            }
            matchingFallbacks = ['defaultFlavor']
        }
}

and in the module build.gradle, I have attempted to match that with:

defaultConfig {
    minSdkVersion 24
    targetSdkVersion 28
    }
buildTypes {

    dynamic {
        multiDexEnabled true
        debuggable true
    }
}


flavorDimensions "blah"
productFlavors {
    arm64 {
        ext {
            abiVersionCode = 5
        }
    }
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':app')
}

In my Run->Edit Configuration screen, I have put a checkbox next to both the base app and the module under the dynamic features to deploy section. I am trying to test this on a Nokia 6, with Android 9.0 running on it. The only output I get from the build is:

01/12 22:39:25: Launching 'app' on HMD Global TA-1025.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_INVALID_APK
The APKs are invalid.

Upvotes: 3

Views: 2984

Answers (5)

Ruslan
Ruslan

Reputation: 117

I had same problem when I used Flavors (Build variants) in my app. The solution for me was select another build variant in Build Variants tab (for example, release instead of debug flavor), then select the correct build variant, and then Clean, Rebuild.

I found this solution here: https://stackoverflow.com/a/65630971/6543967

Upvotes: -2

Chetan
Chetan

Reputation: 226

Try Edit Configurations > Installations Options > Deploy APK from app bundle

Upvotes: 2

Cesar Castro
Cesar Castro

Reputation: 1970

It just happened to me. Turns out I was setting different flavors for different modules.
Try selecting the same variants under View > Tool Windows > Build Variants.

Upvotes: 3

Daniel Pína
Daniel Pína

Reputation: 403

I found a solution that resolved my problem. Make sure your libraries and class paths are up to date. I had a class for firebase plugins that were out of date. This problem occurred when using the new graddle. After updating the classpath, everything looks fine.

In my case. I changed this

classpath 'com.google.firebase:firebase-plugins:1.1.0'

to this

classpath 'com.google.firebase:perf-plugin:1.3.1'

Upvotes: 0

isuru
isuru

Reputation: 565

Please check those things

1) making sure that the AndroidManifest.xml package name was the same as the 
   build.grade applicationId
2) check package name in your Androidmanifest.xml see whether started with one empty space character. like " com.example.test" instead of "com.example.test" and make sure contain at least one dot in your package name like "com.exampletest" instead of "comexampletest" https://code.google.com/p/android/issues/detail?id=55841
3)"Build" > "Clean Project"
4)reboot the android system

Upvotes: 2

Related Questions