Android NDK ndkbuildFailed - android

I tried to build android app with JNI and NDK by using tess-two but i keep getting this error. i'm using Android Studo 2.0, i've installed android ndk r11c. gradle build successfully but keep getting failed to build APK.
this is my android.mk file :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
IMAGE_PROCESSING_PATH := $(LOCAL_PATH)/../../../../Test/src
IMAGE_PROCESSING_JNI_PATH := $(LOCAL_PATH)/image_processing
TESS_TWO_PATH := $(LOCAL_PATH)/../../../../tess-two/tess-two
LEPTONICA_SRC_PATH := $(TESS_TWO_PATH)/jni/com_googlecode_leptonica_android/src
include $(IMAGE_PROCESSING_JNI_PATH)/Android.mk
This is the error message :
http://i.stack.imgur.com/yZATt.png

After taking a look onto your gradle build log:
Source cannot be found. You need to define the NDK_PROJECT_PATH to let it shop to the root folder of your project path.
As far as I know you can specify this in your gradle.build:
android {
sourceSets.main.jni.srcDirs = "src"
}

You can try to disable automatic ndk-build.
For this, update build.graddle file
android {
// ..... defaultConfig / buildTypes / etc ...
// SPECIFIC ROUTINE for NATIVE BUILD
sourceSets.main {
jniLibs.srcDir 'src/main/libs' //set .so files location to libs
jni.srcDirs = [] //disable automatic ndk-build call
}
// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', 'NDK_DEBUG=0', '-C', file('src/main/jni').absolutePath
} else {
commandLine 'ndk-build', 'NDK_DEBUG=0', '-C', file('src/main/jni').absolutePath
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
}
You may need to update graddle.properties
android.useDeprecatedNdk=true

I solved this by giving it a full path :
task ndkBuild(type: Exec,description: 'run ndk-build') {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'D:\\Application\\android-ndk-r10e\\ndk-build.cmd', '-C', 'D:\\ransel\\Citeks\\app\\src\\main\\jni'
} else {
workingDir 'src/main/jni'
commandLine 'D:\\Application\\android-ndk-r10e\\ndk-build', '-C', 'D:\\ransel\\Citeks\\app\\src\\main\\jni'
}
}
Thank you :)

Related

Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ? Error

I got project as Eclipse project, I moved it to Android studio
the build works well now, but when I try to run the app i get error message
this is my project structure:
This is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.testProj.test1"
minSdkVersion 10
targetSdkVersion 23
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
// jni.srcDirs = [] // This prevents the auto generation of Android.mk
main.jniLibs.srcDirs = ['libs']
test.jniLibs.srcDirs = ['libs']
}
// sourceSets.main {
// jni.srcDirs = [] // This prevents the auto generation of Android.mk
// jniLibs.srcDir 'src/main/libs' // This is not necessary unless you have precompiled libraries in your project.
// }
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1'
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
'clean'
}
clean.dependsOn 'cleanNative'
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile files('libs/PTAdChartboost.jar')
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
}
This is Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := player_shared
LOCAL_MODULE_FILENAME := libplayer
LOCAL_SRC_FILES := main.cpp
LOCAL_WHOLE_STATIC_LIBRARIES := core_static cocos2dx_static box2d_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module, core)
$(call import-module, cocos2dx)
$(call import-module, box2D)
The error messages:
Error:(15) *** Android NDK: Aborting. . Stop.
Android NDK: /Users/mylaptop/Documents/Lines/app/src/main/jni/Android.mk: Cannot find module with tag 'core' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
make: Entering directory `/Users/mylaptop/Documents/Lines/app/src/main/jni'
make: Leaving directory `/Users/mylaptop/Documents/Lines/app/src/main/jni'
:app:buildNative FAILED
Error:Execution failed for task ':app:buildNative'.
> Process 'command '/Users/mylaptop/Documents/android-ndk-r10e/ndk-build'' finished with non-zero exit value 2

Android Studio, gradle, ndk, aar and the inclusion of several native shared libraries

I pretty much read through almost every question in stackoverflow about the subject.
I browsed documentation and work-notes of other people who are using AS + NDK + gradle to build an aar that would be included by other app.
I was able to build the .so in a different multi-project setup where the structure was different from the one shown in one aspect: it didn't have the first jni/ layer.
I added that extra jni layer so that I'd have a sharedObjectLib#2/ hierarchy. In that jni/ dir, all i have is a single Android.mk whose sole purpose is to include $(call all-subdir-makefiles). After I did that, gradle build reports the NDK failure:
"Error:(89) Android NDK: WARNING: There are no modules to build in this project!"
What I can't seem to be able to do is build multiple shared objects '.so' as part of the aar.
I would really like to know if (a) it is doable; and (b) some pointers to links and/or examples of gradle.build files that actually do that.
Here is the structure I currently have - skipping the usual directories created by Android Studio (v. 1.2.2, btw).
--rootProject/
--build.gradle
--gradle.properties
--local.properties
--settings.gradle
--rootProject.iml
--app/
--moduleProjectThatBuildsAAR/
--build.gradle
--build/
--libs
--src/
--main/
--res/
--AndroidManifest.xml
--jni/
--Android.mk (does include $(call all-subdir-makefiles))
--Application.mk
--sharedObjectLib#1/
--build.gradle
--src/
-- androidTest/
-- main/
--java/
--jni/
-- Android.mk
-- Application.mk
-- *.c and *.h files
--libs/
--obj/
-- build.gradle
It's pretty convoluted and I am hoping the experts would help with simplification.
thanks!
I am using 1.2.2 and found it easy to build the simple NDK projects
from the many tutorials floating around, but frustratingly difficult
to build an NDK project of any complexity. I will summarize what I
found, but I highly suggest reading
this blog
and this StackOverflow.
I found that Android Studio would completely ignore the
Android.mk file I created, and instead auto-generate its own.
To correct this, I had to first hack the build.gradle
script for my project, located at project/app/build.gradle.
You could probably hack the top-level build.gradle, if desired.
This may be what is happening in your case. The auto-generated
Android.mk looks in jni/ for .c source files and finds nothing
there.
This is my build.gradle. I build on a Windows box, so I hacked it for
Windows only. Uncomment the lines if you are using OSX or Linux.
project/app/build.gradle:
//import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.sample.app"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//ENABLE CUSTOM ANDROID.MK >>
sourceSets.main.jni.srcDirs= [] //Disable automatic ndk-build.
sourceSets.main.jniLibs.srcDir 'src/main/libs'
//Call regular ndk-build script from app directory
task ndkBuild(type: Exec) {
workingDir file('src/main')
commandLine getNdkBuildCmd()
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn { ndkBuild }
}
task cleanNative(type: Exec) {
workingDir file('src/main')
commandLine getNdkBuildCmd(), 'clean'
}
clean.dependsOn cleanNative
}
//ENABLE CUSTOM ANDROID.MK <<
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
}
//ENABLE CUSTOM ANDROID.MK >>
def getNdkDir() {
if (System.env.ANDROID_NDK_ROOT != null)
return System.env.ANDROID_NDK_ROOT
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkdir = properties.getProperty('ndk.dir', null)
if (ndkdir == null)
throw new GradleException("NDK location not found. Define location with ndk.dir in the local.properties file")
return (ndkdir)
}
def getNdkBuildCmd() {
def ndkbuild = getNdkDir() + "/ndk-build.cmd"
// def ndkbuild = getNdkDir() + "/ndk-build"
// if (Os.isFamily(Os.FAMILY_WINDOWS))
// ndkbuild += ".cmd"
return ndkbuild
}
//ENABLE CUSTOM ANDROID.MK <<

Unable to build GStreamer tutorials using Android Studio

I am trying to build the tutorials that are bundled with gstreamer-sdk-android-arm-debug-2013.6. The Android.mk file in the src/jni directory (tutorial 1 project) references environment variables such as GSTREAMER_SDK_ROOT. From what I have read, Android Studio does not use/pass environment variables to the build scripts. Is there a best practice for modifying makefiles and for defining/retrieving the key/value pairs required by the build scripts?
Ok, I have a working solution. You CAN pass environment variables to ndk-build (or any other process spawned by gradle Exec). In my case, I wanted to set these for both the clean and build tasks. This is is done using tasks.withType(Exec). The environment parameter is set here for all Exec tasks.
For GSTREAMER_SDK_ROOT, I added an entry to local.properties:
gst.dir=/Users/svenyonson/sdk/gstreamer-sdk-android-arm-debug-2013.6
For PATH, I used the default for the spawned process and added in what I needed.
Here is a working version of build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.gst_sdk_tutorials.tutorial_1"
minSdkVersion 19
targetSdkVersion 19
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
java.srcDirs += 'src/main/jni/src'
}
tasks.withType(Exec) {
def localProperties = new Properties()
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
def gstDir = localProperties.getProperty('gst.dir')
environment = [:]
environment['PATH'] = System.getenv("PATH")+ ":/usr/local/bin"
environment['GSTREAMER_SDK_ROOT'] = gstDir
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = project.plugins.findPlugin('com.android.application').getNdkFolder()
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath,
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1',
'V=1',
'APP_PLATFORM=android-19'
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkDir = project.plugins.findPlugin('com.android.application').getNdkFolder()
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath,
'clean'
}
clean.dependsOn 'cleanNative'
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
The project now builds and runs. The only other things you will need to do is add ndk.dir to local.properties:
sdk.dir=/Users/svenyonson/sdk/android-sdk
ndk.dir=/Users/svenyonson/sdk/android-ndk-r9d
gst.dir=/Users/svenyonson/sdk/gstreamer-sdk-android-arm-debug-2013.6
One more thing: These examples will not build using android-ndk-r10d. Be sure to use android-ndk-r9d.

Android Studio NDK Build trouble Error:Execution failed for task ':app:buildNative'

Hi. I'm in Android Studio NDK Build trouble. I've not used native library. just java classes for library use and JNI c or header files.
So I've confused how to write gradle file for my project(saskin library ; I'm studying it).
Please help me~!
Error message
Error:Execution failed for task ':app:buildNative'.
A problem occurred starting process 'command 'C:\NDK/ndk-build''
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 8
buildToolsVersion "21.1.1"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
jni.srcDirs = []
//jniLibs.srcDir 'src/main/libs'
}
}
defaultConfig {
applicationId "com.sasken.player"
minSdkVersion 8
targetSdkVersion 8
ndk {
moduleName "equalizer"
}
}
// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
commandLine 'ndk-build', '-C', file('src/main/jni').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
}
dependencies {
}
since you're using Windows, you should call ndk-build.cmd instead of ndk-build, from your ndkBuild task.
To make your gradle file work on windows and unix-compatible systems you can modify your task this way:
import org.apache.tools.ant.taskdefs.condition.Os
// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
} else {
commandLine 'ndk-build', '-C', file('src/main').absolutePath
}
}
Also, as you're using ndk-build directly, the ndk will generate your libraries inside the libs folder, so you should uncomment jniLibs.srcDir 'src/main/libs' inside your gradle file, in order for your generated libs to be taken in account.

JNI and Gradle in Android Studio

I'm trying to add native code to my app. I have everything in ../main/jni as it was in my Eclipse project. I have added ndk.dir=... to my local.properties. I haven't done anything else yet (I'm not sure what else is actually required, so if I've missed something let me know). When I try and build I get this error:
Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/me/android-ndk-r8e/ndk-build NDK_PROJECT_PATH=null
APP_BUILD_SCRIPT=/Users/me/Project/app/build/ndk/debug/Android.mk APP_PLATFORM=android-19
NDK_OUT=/Users/me/Project/app/build/ndk/debug/obj
NDK_LIBS_OUT=/Users/me/Project/app/build/ndk/debug/lib APP_ABI=all
Error Code:
2
Output:
make: *** No rule to make target `/Users/me/Project/webapp/build/ndk/debug//Users/me/Project/app/src/main/jni/jni_part.cpp',
needed by `/Users/me/Project/app/build/ndk/debug/obj/local/armeabi-v7a/objs/webapp//Users/me/Project/app/src/main/jni/jni_part.o'.
Stop.
What do I need to do?
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# OpenCV
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include .../OpenCV-2.4.5-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := native_part
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
Application.mk:
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-8
Gradle Build Tools 2.2.0+ - The closest the NDK has ever come to being called 'magic'
In trying to avoid experimental and frankly fed up with the NDK and all its hackery I am happy that 2.2.x of the Gradle Build Tools came out and now it just works. The key is the externalNativeBuild and pointing ndkBuild path argument at an Android.mk or change ndkBuild to cmake and point the path argument at a CMakeLists.txt build script.
android {
compileSdkVersion 19
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
ndk {
abiFilters 'armeabi', 'armeabi-v7a', 'x86'
}
externalNativeBuild {
cmake {
cppFlags '-std=c++11'
arguments '-DANDROID_TOOLCHAIN=clang',
'-DANDROID_PLATFORM=android-19',
'-DANDROID_STL=gnustl_static',
'-DANDROID_ARM_NEON=TRUE',
'-DANDROID_CPP_FEATURES=exceptions rtti'
}
}
}
externalNativeBuild {
cmake {
path 'src/main/jni/CMakeLists.txt'
}
//ndkBuild {
// path 'src/main/jni/Android.mk'
//}
}
}
For much more detail check Google's page on adding native code.
After this is setup correctly you can ./gradlew installDebug and off you go. You will also need to be aware that the NDK is moving to clang since gcc is now deprecated in the Android NDK.
Android Studio Clean and Build Integration - DEPRECATED
The other answers do point out the correct way to prevent the automatic creation of Android.mk files, but they fail to go the extra step of integrating better with Android Studio. I have added the ability to actually clean and build from source without needing to go to the command-line. Your local.properties file will need to have ndk.dir=/path/to/ndk
apply plugin: 'com.android.application'
android {
compileSdkVersion 14
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.application"
minSdkVersion 14
targetSdkVersion 14
ndk {
moduleName "YourModuleName"
}
}
sourceSets.main {
jni.srcDirs = [] // This prevents the auto generation of Android.mk
jniLibs.srcDir 'src/main/libs' // This is not necessary unless you have precompiled libraries in your project.
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1'
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
'clean'
}
clean.dependsOn 'cleanNative'
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
}
The src/main/jni directory assumes a standard layout of the project. It should be the relative from this build.gradle file location to the jni directory.
Gradle - for those having issues
Also check this Stack Overflow answer.
It is really important that your gradle version and general setup are correct. If you have an older project I highly recommend creating a new one with the latest Android Studio and see what Google considers the standard project. Also, use gradlew. This protects the developer from a gradle version mismatch. Finally, the gradle plugin must be configured correctly.
And you ask what is the latest version of the gradle plugin? Check the tools page and edit the version accordingly.
Final product - /build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
// Running 'gradle wrapper' will generate gradlew - Getting gradle wrapper working and using it will save you a lot of pain.
task wrapper(type: Wrapper) {
gradleVersion = '2.2'
}
// Look Google doesn't use Maven Central, they use jcenter now.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Make sure gradle wrapper generates the gradlew file and gradle/wrapper subdirectory. This is a big gotcha.
ndkDirectory
This has come up a number of times, but android.ndkDirectory is the correct way to get the folder after 1.1. Migrating Gradle Projects to version 1.0.0. If you're using an experimental or ancient version of the plugin your mileage may vary.
gradle supports ndk compilation by generating another Android.mk file with absolute paths to your sources.
NDK supports absolute paths since r9 on OSX, r9c on Windows, so you need to upgrade your NDK to r9+.
You may run into other troubles as NDK support by gradle is preliminary. If so you can deactivate the ndk compilation from gradle by setting:
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
to be able to call ndk-build yourself and integrate libs from libs/.
btw, you have any issue compiling for x86 ? I see you haven't included it in your APP_ABI.
In my case, I'm on Windows and following the answer by Cameron above only works if you use the full name of the ndk-build which is ndk-build.cmd. I have to clean and rebuild the project, then restart the emulator before getting the app to work (Actually I imported the sample HelloJni from NDK, into Android Studio). However, make sure the path to NDK does not contain space.
Finally, my build.gradle is full listed as below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.hellojni"
minSdkVersion 4
targetSdkVersion 4
ndk {
moduleName "hello-jni"
}
testApplicationId "com.example.hellojni.tests"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
sourceSets.main {
jni.srcDirs = [] // This prevents the auto generation of Android.mk
// sourceSets.main.jni.srcDirs = []
jniLibs.srcDir 'src/main/libs' // This is not necessary unless you have precompiled libraries in your project.
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.plugin.ndkFolder
commandLine "$ndkDir/ndk-build.cmd",
'-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1'
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkDir = android.plugin.ndkFolder
commandLine "$ndkDir/ndk-build.cmd",
'-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
'clean'
}
clean.dependsOn 'cleanNative'
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
}
dependencies {
compile 'com.android.support:support-v4:21.0.3'
}
Android Studio 2.2 came out with the ability to use ndk-build and cMake. Though, we had to wait til 2.2.3 for the Application.mk support. I've tried it, it works...though, my variables aren't showing up in the debugger. I can still query them via command line though.
You need to do something like this:
externalNativeBuild{
ndkBuild{
path "Android.mk"
}
}
defaultConfig {
externalNativeBuild{
ndkBuild {
arguments "NDK_APPLICATION_MK:=Application.mk"
cFlags "-DTEST_C_FLAG1" "-DTEST_C_FLAG2"
cppFlags "-DTEST_CPP_FLAG2" "-DTEST_CPP_FLAG2"
abiFilters "armeabi-v7a", "armeabi"
}
}
}
See http://tools.android.com/tech-docs/external-c-builds
NB: The extra nesting of externalNativeBuild inside defaultConfig was a breaking change introduced with Android Studio 2.2 Preview 5 (July 8, 2016). See the release notes at the above link.
My issue on OSX it was gradle version. Gradle was ignoring my Android.mk.
So, in order to override this option, and use my make instead, I have entered this line:
sourceSets.main.jni.srcDirs = []
inside of the android tag in build.gradle.
I have wasted lot of time on this!
In the module build.gradle, in the task field, I get an error unless I use:
def ndkDir = plugins.getPlugin('com.android.application').sdkHandler.getNdkFolder()
I see people using
def ndkDir = android.plugin.ndkFolder
and
def ndkDir = plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder()
but neither of those worked until I changed it to the plugin I was actually importing.

Categories

Resources