Android Studio编译开源项目(含NDK开发)常见报错

缥帙各舒散,前后互相逾。这篇文章主要讲述Android Studio编译开源项目(含NDK开发)常见报错相关的知识,希望能为你提供帮助。
1.未设置NDK的路径Error:Execution failed for task \':library:ndkBuild\'. > A problem occurred starting process \'command \'null/ndk-build\'\'
配置NDK的的安装路径即可。
1)设置环境变量:新增android_NDK_HOME键值为Android NDK安装目录,在PATH末尾增加; %ANDROID_NDK_HOME%
或者2)在AS的project structure设置,如下图:
【Android Studio编译开源项目(含NDK开发)常见报错】

Android Studio编译开源项目(含NDK开发)常见报错

文章图片

 
2. 调用的ndk-build命令不对Error:Execution failed for task \':library:ndkBuild\'.> A problem occurred starting process \'command \'D:\\androidDev\\android-ndk-r10e/ndk-build\'\'
在stackoverflow上找到原因,build.gradle文件中
taskndkBuild(type: Exec,description:\'Compile JNI source via NDK\') { defndkDir =project.plugins.findPlugin(\'com.android.library\').sdkHandler.ndkFolder workingDir"$projectDir/src/main/jni" commandLine"$ndkDir/ndk-build" }


commandLine"$ndkDir/ndk-build"这一行windows下应该用ndk-build.cmd(项目中有遇到)
3. 找不到boost库文件项目Readme中有说明
Manual Build Make sure$ANDROID_NDK_HOMEis correctly set to the root directory of your NDK installation. Also, if Boost lives in a non-standard directory (or you\'re on Windows) you\'ll need to set$BYPASS_INCLUDE_PATH to its parent directory.


设置环境变量:新增BYPASS_INCLUDE_PATH键值为boost的安装目录,在PATH末尾增加; %BYPASS_INCLUDE_PATH%

    推荐阅读