Android Studio使用ndk'遇到的错误

今天使用讯飞aiui串口开发包的时候遇到了如下错误

1.出现找不到ndk:

Error:Execution failed for task ':serialPortLibrary:compileReleaseNdk'.> Error: Your project contains C++ files but it is not using a supported native build system.Consider using CMake or ndk-build integration with the stable Android Gradle plugin: https://developer.android.com/studio/projects/add-native-code.htmlor use the experimental plugin: http://tools.android.com/tech-docs/new-build-system/gradle-experimental.

解决办法:在项目的gradle.properties文件中加入这句

android.useDeprecatedNdk=true
2.在解决了上述问题之后,又出现了如下错误

Error:Execution failed for task ':UARTKit:uart:compileReleaseNdk'.

> com.android.ide.common.process.ProcessException: Error while executing '/Users/kzx/Library/Android/sdk/ndk-bundle/ndk-build' with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/kzx/Downloads/AIUI评估板开发包-1042/串口开发包/UARTKit/uart/build/intermediates/ndk/release/Android.mk APP_PLATFORM=android-20 NDK_OUT=/Users/kzx/Downloads/AIUI评估板开发包-1042/串口开发包/UARTKit/uart/build/intermediates/ndk/release/obj NDK_LIBS_OUT=/Users/kzx/Downloads/AIUI评估板开发包-1042/串口开发包/UARTKit/uart/build/intermediates/ndk/release/lib APP_ABI=all}

解决方法:在你导入的包含jni的库的build.gradle文件的android标签中加入这句

sourceSets.main {
    jni.srcDirs = []
}



你可能感兴趣的:(aiui,ndk,jni)