I\'m having trouble getting my NDK to compile properly in Android Studio. Whenever I try running to compile I am getting the following error.
Error:Ex
try this
commandLine'E:\\Android\\ndk\\ndkbuild.cmd','-C',file('src/main/jni').absolutePath
replace (E:\\Android\\ndk\\) with your ndk path.
I met this kind of problem. First of all You have to give your NDK path in local.properties
of your app.
e.g. ndk.dir=/home/user/bin/android_ndk/android-ndk-r10e
Then in my build.gradle
file I had something like this for calling ndk build command.
commandLine 'ndk-build', '-C', file('src/main/jni').absolutePath
I'v change it to
commandLine '/home/user/bin/android_ndk/android-ndk-r10e/ndk-build', '-C', file('src/main/jni').absolutePath
I gave full path of NDK build. Hope it'll help you.
Have a look in these link below.
You must know the path where the NDK is usually at
Library/Android/sdk/ndk/<version_number>
https://developer.android.com/studio/releases?utm_source=android-studio#4-0-0-ndk-dir
and
https://developer.android.com/studio/projects/install-ndk
and
https://wiki.appcelerator.org/display/guides2/Installing+the+Android+NDK
its easy for android studio 2.3.3. just follow File->Project Structure -> android NDK Location-> Click download button. after install ndk solve my problem.
The accepted answer is OK, but it doesn't work since android tools gradle plugin 2.3: No sdkHandler field in LibraryPlugin after updating to build tools 2.3.0, so you need to use project.android.ndkDirectory.absolutePath
variable then, ie:
task ndkBuild(type: Exec) {
commandLine project.android.ndkDirectory.absolutePath + '/ndk-build', '-C', file('src/main/jni/').absolutePath
}
Alternatively you can read ndk.dir directly from local.properties: https://stackoverflow.com/a/32649204/1028256
First of all you have to check local.properties file in your project. In local.properties check ndk path. It looks like this ndk.dir=D:\\sdk\\ndk-bundle.
Now go to the build.gradle(Module library) and find getNdkPath(). It will return ndk path location which concatnate the ndk-build
Change ndk-build --> ndk-build.cmd. It looks like this:
Hope it will help you!