My NDK project fails to compile with a CPU architecture-related issue

时间:2018-05-14 17:37:00

标签: android android-ndk android-gradle

Can someone explain why I get this errors please?

Build command failed.


Error while executing process C:\Users\Kevin\Desktop\Android\Sdk\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\Kevin\Desktop\Mygame\proj.android-studio\app\jni\Android.mk NDK_APPLICATION_MK=C:\Users\Kevin\Desktop\Mygame\proj.android-studio\app\jni\Application.mk APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDK_DEBUG=1 APP_PLATFORM=android-14 NDK_OUT=C:/Users/Kevin/Desktop/Mygame/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=C:\Users\Kevin\Desktop\Mygame\proj.android-studio\app\build\intermediates\ndkBuild\debug\lib NDK_TOOLCHAIN_VERSION=4.9 APP_PLATFORM=android-10 NDK_MODULE_PATH=C:/Users/Kevin/Desktop/Mygame/cocos2d;C:/Users/Kevin/Desktop/Mygame/cocos2d/cocos;C:/Users/Kevin/Desktop/Mygame/cocos2d/external -j4 NDK_DEBUG=1 APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}


Android NDK: INTERNAL ERROR: The armeabi ABI should have exactly one `architecture definitions. Found: ''`    
process_begin: CreateProcess(NULL, "", ...) failed. 
*** Android NDK: Aborting...    .  Stop.
Build command failed.


Error while executing process C:\Users\Kevin\Desktop\Android\Sdk\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\Kevin\Desktop\Mygame\proj.android-studio\app\jni\Android.mk NDK_APPLICATION_MK=C:\Users\Kevin\Desktop\Mygame\proj.android-studio\app\jni\Application.mk APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDK_DEBUG=0 APP_PLATFORM=android-14 NDK_OUT=C:/Users/Kevin/Desktop/Mygame/proj.android-studio/app/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=C:\Users\Kevin\Desktop\Mygame\proj.android-studio\app\build\intermediates\ndkBuild\release\lib NDK_TOOLCHAIN_VERSION=4.9 APP_PLATFORM=android-10 NDK_MODULE_PATH=C:/Users/Kevin/Desktop/Mygame/cocos2d;C:/Users/Kevin/Desktop/Mygame/cocos2d/cocos;C:/Users/Kevin/Desktop/Mygame/cocos2d/external -j4 NDK_DEBUG=0 APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}

Android NDK: INTERNAL ERROR: The armeabi ABI should have exactly one architecture definitions. Found: ''    
process_begin: CreateProcess(NULL, "", ...) failed.
*** Android NDK: Aborting...    .  Stop.

I leave here a screenshot of my android studio if can be helpful enter image description here

2 个答案:

答案 0 :(得分:10)

最有可能的是,您安装了NDK r17,不再支持 armeabi 。您的gradle插件不知道最近的更改。您必须升级:在 build.gradle 中,您应该

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

并在 gradle / wrapper / gradle-wrapper.properties

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

但即使升级后,您的 build.gradle 也很可能缺少 abiFilters 语句,因此您的项目构建速度较慢且APK大于必要。

您可能只需要在APK中使用ABI,

android { defaultConfig { ndk {
    abiFilters 'armeabi-v7a'
} } }

答案 1 :(得分:1)

我最近收到此错误-原因仍然是个谜。我重新安装了所有内容,但无法将我的项目清理。

最后,我手动删除了app/buildapp/.externalNativeBuild文件夹,并重新构建了项目,然后我又可以再次运行Clean了,而且没有错误。