Android studioにJNIを追加してエラーを報告

1462 ワード

Error:Execution failed for task ':app: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.html
or use the experimental plugin:
 https://developer.android.com/studio/build/experimental-plugin.html.
1つ目の方法はCMAKEのコンパイル方法です.
2つ目はndkでコンパイルするか
主に第2の方法を記録します.
1.工事buildを修正する.gradleファイル
classpath 'com.android.tools.build:gradle:2.3.0'
2.プロジェクトbuildを修正する.gradleファイル
ndk {
    moduleName "led"
    ldLibs "log", "z", "m"
    abiFilters "armeabi-v7a", "x86"
}
3.プロジェクト追加ファイルgradle.properties
 
  
android.useDeprecatedNdk=true
4.JniディレクトリはMainファイルの下に配置されます.