不兼容Android模拟器的分割APK

4
我有一个 NDK 项目,我正在构建 armeabi-v7a、arm64-v8a 和 x86 的版本。在手机上运行代码很好,但尝试在 x86 模拟器上运行时,虽然可以成功构建,但会报以下错误:
当前选择的变体“debug”使用分离 APK,但没有一个分离的 apk 与具有密度“560”和 ABI “x86”的当前设备兼容。
最初,我尝试避免使用分离的 APK,通过在 build.gradle 中执行以下操作:
splits {

    // Configures multiple APKs based on screen density.
    density {

        // Configures multiple APKs based on screen density.
        enable false
    }

    // Configures multiple APKs based on ABI
    abi {
        // Enables building multiple APKs per ABI.
        enable true

        // By default all ABIs are included, so use reset() and include to specify that we only
        // want APKs for armeabi-v7a, arm64-v8a, and x86

        // Resets the list of ABIs that Gradle should create APKs for to none.
        reset()

        // Specifies a list of ABIs that Gradle should create APKs for.
        include 'armeabi-v7a', 'arm64-v8a', 'x86'

        // Specifies that we do not want to also generate a universal APK that includes all ABIs.
        universalApk true
    }
}

但是重新阅读错误提示后,它说没有任何1个分割APK。只有一个不兼容的生成的APK文件,所以我猜测可能是生成了错误的APK文件?那么我应该使用哪些工具来深入挖掘呢?
3个回答

3
你可以尝试这种方式。
  include 'x86', 'armeabi-v7a', 'armeabi'

尝试设置

universalApk false

1

在 MacBook M1 Pro 上运行 minos-mobile 应用程序时,遇到了相同的问题。

Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: The currently selected variant "debug" uses split APKs, but none of the 1 split apks are compatible with the current device with ABIs "arm64-v8a".

我在 build.gradle 文件中添加了 APK 分割配置。
android {
 
 ....

splits {
    abi {
        enable true
        reset()
        include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips'
        universalApk true
    }
}

project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]

android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.versionCodeOverride =
                project.ext.versionCodes.get(output.getFilter(
                        com.android.build.OutputFile.ABI), 0) * 10000000 + android.defaultConfig.versionCode
    }
}
}

0

仔细检查后,我犯了一个错误,没有将x86包含在我的abi拆分列表中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接