从 NDK 版本 16 更新到 NDK 版本 17 时出错 [英] Errors updating from NDK version 16 to NDK version 17

查看:30
本文介绍了从 NDK 版本 16 更新到 NDK 版本 17 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个使用 JNI 和 NDK 的 Android 项目.我正在使用 Android Studio 3.0.1 构建项目.我最近将我的 NDK 从 16 版更新到了 17 版,希望能够提供更多的编译器优化.更新后,我收到以下错误:

This is for an Android project using JNI with the NDK. I'm building the project with Android Studio 3.0.1. I recently updated my NDK from version 16 to version 17 in the hopes of making more compiler optimizations available. After the update, I'm getting the following errors:

CMake 错误在 C:/Users/John/AppData/Local/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake:312(消息):无效的 Android ABI:armeabi.(不再支持 armeabi.使用armeabi-v7a.)调用堆栈(最近调用优先):C:/Users/John/AppData/Local/Android/Sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeDetermineSystem.cmake:98(包括)CMakeLists.txtCMake 错误:在 EnableLanguage 之后未设置 CMAKE_C_COMPILERCMake 错误:在 EnableLanguage 之后未设置 CMAKE_CXX_COMPILER-- 配置不完整,出现错误!

CMake Error at C:/Users/John/AppData/Local/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake:312 (message): Invalid Android ABI: armeabi. (armeabi is no longer supported. Use armeabi-v7a.) Call Stack (most recent call first): C:/Users/John/AppData/Local/Android/Sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/CMakeDetermineSystem.cmake:98 (include) CMakeLists.txt CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred!

对于每个已弃用的 ABI,armeabi、mips 和 mips64,我都收到此错误.我知道我应该从构建中删除这些 ABI,但我找不到有关如何执行此操作的说明.我没有使用 Application.mk,也没有看到在任何地方指定了 ABI;如何从我的 Android Studio 项目中删除这些未使用的 ABI,或者更好的是,如何将我的项目设置为仅使用当前未弃用的 ABI?谢谢.

I'm getting this error for each of the deprecated ABIs armeabi, mips, and mips64. I understand that I should remove these ABIs from the build, but I can't find instructions on how to do that. I'm not using an Application.mk and I don't see the ABIs being specified anywhere; how can I remove these unused ABIs from my Android Studio project, or better yet, how can I set my project to just use the current non-deprecated ABIs? Thank you.

推荐答案

在根(项目)build.gradle 脚本中,将您的 gradle 插件升级到 3.1.2 或更高版本应该就足够了.建议使用最新的插件,不仅要兼容最新的 NDK:

It should be enough to upgrade your gradle plugin to 3.1.2 or higher, in root (project) build.gradle script. Using the latest plugin is recommended not only to be compliant with latest NDK:

buildscript {
  dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
  }
}

您还必须更改gradle/wrapper/gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip v.4.4

如果您负担不起此类更改,您可以尝试跳过已弃用的用于构建和打包的 ABI:

If you cannot afford such change, you may try to skip the deprecated ABIs for build and packaging:

android {
  defaultConfig {
    ndk {
      abiFilters 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
    }
  }

  packagingOptions {
    doNotStrip '*/mips/*.so'
    doNotStrip '*/mips64/*.so'
  }
}

这篇关于从 NDK 版本 16 更新到 NDK 版本 17 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆