簡體   English   中英

Android 動態功能 INSTALL_FAILED_INVALID_APK

[英]Android Dynamic Feature INSTALL_FAILED_INVALID_APK

我正在嘗試向現有應用程序添加一些功能。 應用程序的 build.gradle 包含幾個 productFlavors 和幾個 buildType。 我試圖在我的動態功能模塊中盡可能地復制它,但我似乎無法從 Android Studio 正確安裝它。

我遵循以下示例: https : //github.com/googlearchive/android-dynamic-features來設置我的功能模塊,因此我的項目結構如下

app
features/module/build.gradle
build.gradle

我向應用程序 build.gradle 添加了 buildType 和風味

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']
        }
}

在模塊 build.gradle 中,我試圖將其與:

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')
}

在我的 Run->Edit Configuration 屏幕中,我在要部署的動態功能部分下的基本應用程序和模塊旁邊放置了一個復選框。 我正在嘗試在運行 Android 9.0 的諾基亞 6 上對此進行測試。 我從構建中得到的唯一輸出是:

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.

它只是發生在我身上。 原來我為不同的模塊設置了不同的風格。
嘗試在View > Tool Windows > Build Variants下選擇相同的變View > Tool Windows > Build Variants

請檢查這些東西

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

嘗試Edit Configurations > Installations Options > Deploy APK from app bundle

我找到了解決我的問題的解決方案。 確保您的庫和類路徑是最新的。 我有一個過時的 firebase 插件類。 使用新的 graddle 時出現此問題。 更新類路徑后,一切看起來都很好。

就我而言。 我改變了這個

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

對此

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

當我在我的應用程序中使用 Flavors(構建變體)時,我遇到了同樣的問題。 我的解決方案是在 Build Variants 選項卡中選擇另一個構建變體(例如,發布而不是調試風格),然后選擇正確的構建變體,然后Clean, Rebuild

我在這里找到了這個解決方案: https : //stackoverflow.com/a/65630971/6543967

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM