gradle 没有与Android模拟器兼容的拆分APK

cwxwcias  于 2023-03-08  发布在  Android
关注(0)|答案(3)|浏览(170)

我有一个NDK项目,我正在为armeabi-v7 a、arm 64-v8 a和x86构建。在手机上运行代码可以正常工作,但尝试在x86模拟器上运行代码可以正确构建,但会出现以下错误:
The currently selected variant "debug" uses split APKs, but none of the 1 split apks are compatible with the current device with density "560" and ABIs "x86".
最初,我尝试通过在我的build.gradle中执行以下操作来避免使用拆分apk:

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。只有1个APK生成,并且不兼容,所以我猜生成了错误的APK?我可以使用什么工具来深入挖掘?

kwvwclae

kwvwclae1#

你试试这边

include 'x86', 'armeabi-v7a', 'armeabi'

并尝试设置

universalApk false
v1l68za4

v1l68za42#

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

tct7dpnv

tct7dpnv3#

在MacBook M1 Pro上运行minos移动应用程序时也面临同样的问题。

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

相关问题