AS配置NDK外部工具

#

1

  • 参考 [http://blog.csdn.net/tommy996633/article/details/51126804] 配置外部工具NDK
  • 增加javah、ndk-build、ndk-build clean 三个命令
  • 对于我,对应的参数是:
-d ..\jni $FileClass$

$ModuleFileDir$\src\main\java\

E:\zhangbin\Android\android-sdk\ndk-bundle
$ModuleFileDir$\src\main\jni

报错:

Error:Execution failed for task ':app:compileDebugNdk'.
> 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:
 http://tools.android.com/tech-docs/new-build-system/gradle-experimental.

-这是因为AS想自己自动生成Android.mk进行编译,而不是用你弄好的。
-解决办法是,在app的build.gralde里,jni.srcDirs置空,参考[http://stackoverflow.com/questions/27453085/execution-failed-for-task-appcompiledebugndk-failed-to-run-this-command-ndk]

        //added for jni begin
        ndk {
            moduleName "hellocjni"
            abiFilters "armeabi-v7a"
        }

        sourceSets.main {
            jni.srcDirs = []//disable automatic ndk-build call
            jniLibs.srcDir "src/main/libs"
        }
        //added for jni end

2 默认的NDK工程是使用cmake支持C++的

  • 我现在代码是c的

你可能感兴趣的:(Android,c/c++)