对 64 位的支持会在 build.gradle 中添加 ndk.abiFilters 时出错

use*_*316 5 android android-ndk android-build android-gradle-plugin

大多数 android 开发者必须在 2019 年 8 月之前收到来自 Google 的消息,要求更新应用程序以支持 64 位架构。此处提供了详细说明: 确保您的应用程序支持 64 位设备

在我的应用程序中,我发现使用了 32 位库,因此我必须更新应用程序以支持 64 位架构。正如上面指南中所建议的,我在build.gradle文件中添加了以下内容:

ndk.abiFilters = 'armeabi-v7a' 'arm64-v8a' 'x86' 'x86_64'
Run Code Online (Sandbox Code Playgroud)

但是,在那之后,我在构建应用程序时遇到以下错误:

错误:(35, 0) 在 DefaultConfig_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=16, mCodename='null'}, targetSdkVersion 上找不到参数 [arm64-v8a] 的方法 armeabi-v7a() =DefaultApiVersion{mApiLevel=28, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=3, versionName=1.2, applicationId=, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArgu ={}、testHandleProfiling=null、testFunctionalTest=null、signingConfig=null、resConfig=null、mBuildConfigFields={}、mResValues={}、mProguardFiles=[]、mConsumerProguardFiles=[]、mManifestPlaceholders={}、mWearAppUnbundled=null}输入 com.android.build.gradle.internal.dsl。默认配置。

有没有人已经尝试将应用程序更新到 64 位?任何想法,如何解决这个问题?

Sur*_*ant 6

可以通过更新构建 gradle defaultConfig 来完成

defaultConfig {
    applicationId "my.test.64bitapp"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 42
    versionName "1.0.2"
    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true
    ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' ,'x86_64'
}
Run Code Online (Sandbox Code Playgroud)

或者

defaultConfig {
    applicationId "com.swypmedia"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 2
    versionName "2.0.2"
    ndk {
        abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' ,'x86_64'
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经在 android-native 和 react-native 应用程序上对此进行了测试。构建成功并且应用程序正在运行。