【主要参考】----<http://blog.csdn.net/jdh99/article/details/51765441>
【开发NDK步骤】 1.安装ndk 【http://blog.csdn.net/jdh99/article/details/51765441】 打开Tools->Android->SDK Manager->SDK Tools选中【LLDB和NDK】,点击确认,软件会自动安装NDK。 2.配置环境变量 增加一项:NDK_ROOT,如:C:\soft\adt-bundle-windows-x86-20130911\sdk\ndk-bundle 在path中增加%NDK_ROOT% 3.在工程的Project视图下main中新建文件夹jni 4.新建hello-jni.c 函数需按照规则命名:Java_包名类名方法名 5.新建Android.mk 6.在build.gradle中配置 配置好,make project即可生成.so文件 /**BUG-1**/+/**BUG-2**/ 在app\build\intermediates\ndk-build\debug\lib中。 增加语句******* /**BUG-3**/ 【BUG】 1.【 NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin. For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental. Set "Android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.】 ---->【http://blog.csdn.net/u014657752/article/details/48106081】 ---->【在gradle.properties 文件里面添加 android.useDeprecatedNdk=true】 2. 【 Warning:Native C/C++ source code is found, but it seems that NDK option is not configured. Note that if you have an Android.mk, it is not used for compilation. The recommended workaround is to remove the default jni source code directory by adding: android { sourceSets { main { jni.srcDirs = [] } } } to build.gradle, manually compile the code with ndk-build, and then place the resulting shared object in src/main/jniLibs.】 ---->【翻译照做】 ---->【http://blog.csdn.net/qjay_dev/article/details/51343312】 ---->【概意思就是我们缺少一个文件:Android.mk,但人家给了我们推荐的方法,那就是在对应module工程中的build.gradle文件中添加如下代码: sourceSets { main { jni.srcDirs = [] } }】 3. 【 Error:(21, 0) Gradle DSL method not found: 'externalNativeBuild()' Possible causes:<ul><li>The project 'NdkTest' may be using a version of Gradle that does not contain the method. <a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin. <a href="apply.gradle.plugin">Apply Gradle plugin</a></li>】 ---->【找不到这个externalNativeBuild(),缘由出处Gradle版本低缘由最大】 ---->【1. Gradle版本较低】 --->【http://stackoverflow.com/questions/39506379/could-not-find-method-externalnativebuild-for-arguments Answ:1·7赞】 --->【大体理解就是这个方法要求最低2.2.0的Gradle版本,在项目工程build.gradle添加(只是增加<classpath 'com.android.tools.build:gradle:2.2.0>,原来的不改动) buildscript { dependencies { classpath 'com.android.tools.build:gradle:2.2.0'}}】 --->【Bug.4】 ---->【2. 缺失Gradle插件:apply Gradle plugin】 4. 【 Warning:Minimum supported Gradle version is 2.14.1. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in D:\Studio\WorkSpace\AStudio\NdkTest\gradle\wrapper\gradle-wrapper.properties to gradle-2.14.1-all.zip】 ---->【翻译照做】 ---->【http://stackoverflow.com/questions/34814368/gradle-version-2-10-is-required-error 74赞那个answer】
