android - 对 64 位的支持会在 build.gradle 中添加 ndk.abiFilters 时出错
问题描述
大多数安卓开发者一定已经收到谷歌的消息,要求在 2019 年 8 月之前更新应用程序以支持 64 位架构。详细说明如下: 确保您的应用程序支持 64 位设备
在我的应用程序中,我发现使用了 32 位库,因此我必须更新应用程序以支持 64 位架构。正如上面指南中所建议的,我在build.gradle
文件中添加了以下内容:
ndk.abiFilters = 'armeabi-v7a' 'arm64-v8a' 'x86' 'x86_64'
但是,在那之后,我在构建应用程序时遇到以下错误:
错误:(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, testInstrumentationRunnerArguments ={},testHandleProfiling=null,testFunctionalTest=null,signingConfig=null,resConfig=null,mBuildConfigFields={},mResValues={},mProguardFiles=[],mConsumerProguardFiles=[],mManifestPlaceholders={},mWearAppUnbundled=null}输入 com.android.build.gradle.internal.dsl。默认配置。
是否有人已经尝试将应用程序更新为 64 位?任何想法,如何解决这个问题?
解决方案
可以通过更新 build 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'
}
或者
defaultConfig {
applicationId "com.swypmedia"
minSdkVersion 16
targetSdkVersion 26
versionCode 2
versionName "2.0.2"
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86' ,'x86_64'
}
}
我已经在 android-native 和 react-native 应用程序上对此进行了测试。构建成功并且应用程序正在运行。
推荐阅读
- python - 如何在 Shapely 中找到每对 LineString 之间的交点?
- java - Google Pub/Sub 主题创建
- r - 从外部 oneDrive 下载 csv 文件使用 r 中的 download.files() 仅提供文本/html 文件
- node.js - 如何阻止 Firebase 身份验证处理的后端继续进行到其他浏览器/会话
- debugging - 在本地机器的 Clion 远程 gdb 调试中找不到源文件
- javascript - 如何使用 HTML、JavaScript 和 Laravel 插入 2 个操作?
- python - 使用python对多个json文件的日期进行排序
- excel - Object Required Error On For Each Loop Only After Importing New Data
- c - 如何使用指向结构的指针进行迭代?
- javascript - atan() 返回楠