使用参数 {NDK_PROJECT_PATH=null 执行进程 .../ndk-bundle/ndk-build 时出错

Error while executing process .../ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null

为什么会出现下一个错误? p.s。 ndk-bundle 处没有任何 ndk-build 文件夹这是什么意思?

Build command failed.


Error while executing process /home/user/Android/Sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/user/JNI/app/src/main/jni/Android.mk NDK_APPLICATION_MK=/home/user/JNI/app/src/main/jni/Application.mk APP_ABI=arm64-v8a NDK_ALL_ABIS=arm64-v8a NDK_DEBUG=1 APP_PLATFORM=android-23 NDK_OUT=/home/user/JNI/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/home/user/JNI/app/build/intermediates/ndkBuild/debug/lib APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}

在我的 ~/.bashrc 我有下一个:

export NDK=/home/user/Android/Sdk/ndk-bundle
export PATH=$PATH:$NDK
export PATH=$PATH:/home/user/Android/Sdk

更新

来自终端:

user@user-X556UQK:~/Android/Sdk/ndk-bundle$ ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/user/Android/AndroidStudioProjects/JNIINVOKEFFMPEG1/app/src/main/jni/Android.mk NDK_APPLICATION_MK=/home/user/Android/AndroidStudioProjects/JNIINVOKEFFMPEG1/app/src/main/jni/Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-23 NDK_OUT=/home/user/Android/AndroidStudioProjects/JNIINVOKEFFMPEG1/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/home/user/Android/AndroidStudioProjects/JNIINVOKEFFMPEG1/app/build/intermediates/ndkBuild/debug/lib APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n
Android NDK: /home/user/Android/AndroidStudioProjects/JNIINVOKEFFMPEG1/app/src/main/jni/Android.mk: Cannot find module with tag 'ffmpeg/android/arm' in import path    
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?    
Android NDK: The following directories were searched:    
Android NDK:         
/home/user/Android/AndroidStudioProjects/JNIINVOKEFFMPEG1/app/src/main/jni/Android.mk:14: *** Android NDK: Aborting.    .  Stop.

所以底线是,当您在 Android Studio 中看到此消息时,

Error while executing process …/ndk-bundle/ndk-build with arguments {…}

并且您不知道真正导致错误的原因,您应该尝试 运行 在终端中使用完全相同的参数执行完全相同的命令。输出可能会给你一个合理的提示。

特别是在这种情况下,来自 Android NDK 的错误消息解释了哪个文件 (/home/user/Android/AndroidStudioProjects/JNIINVOKEFFMPEG1/app/src/main/jni/Android.mk) 和哪一行 (14) 有问题,甚至解释了你可以做些什么来修复:

define NDK_MODULE_PATH in your environment to let NDK find the module ffmpeg/android/arm

此解决方案适用于 android 工作室。

在包中,select有ndk文件的文件夹,删除生成的中间体(包括.build和.externalndkbuild)并清理项目 如果需要尝试使缓存无效并在 android studio

中重新启动

已在终端中启动。得到这个答案:

Android NDK: Could not find application project directory!

Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.

结果,原因是最大路径长度限制(260个字符)。

通过将此代码添加到 build.gradle (app),项目构建:

allprojects {
 if (Os.isFamily (Os.FAMILY_WINDOWS)) {
     buildDir = "$ {projectDir} /../../../../ build"
 }
}