NDK support is deprecated for Android Studio 1.1.0

Currently running Android Studio 1.1.0. Installed NDK and added a link to the build.gradle file. Building a project gives a trace with the following text.

WARNING [Project: :app] Current NDK support is deprecated. Alternative will be provided in the future. android-ndk-r10d\ndk-build.cmd'' finished with non-zero exit value 1 

Is NDK r10d unsupported by Android Studio?

+6
source share
3 answers

Current NDK support still works for simple projects (for example, C / C ++ sources independent of other pre-built NDK libraries), including when using the latest version of NDK r10d.

But this is really limited, and as the warning says, it is outdated, yes.

I recommend simply disabling it and making the gradle call ndk-build directly. This way you can save your classic Android.mk/Application.mk configuration files, and the ndk-build call from your project will still work the same as with the eclipse project:

 import org.apache.tools.ant.taskdefs.condition.Os ... android { ... sourceSets.main { jniLibs.srcDir 'src/main/libs' //set .so files location to libs instead of jniLibs jni.srcDirs = [] //disable automatic ndk-build call } // add a task that calls 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 } } // add this task as a dependency of Java compilation tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn ndkBuild } } 
+10
source

I use the method below to build the absolute ndk-build path:

 def getNdkBuildExecutablePath() { File ndkDir = android.ndkDirectory if (ndkDir == null) { throw new Exception('NDK directory is not configured.') } def isWindows = System.properties['os.name'].toLowerCase().contains('windows') def ndkBuildFile = new File(ndkDir, isWindows ? 'ndk-build.cmd' : 'ndk-build') if (!ndkBuildFile.exists()) { throw new Exception( "ndk-build executable not found: $ndkBuildFile.absolutePath") } ndkBuildFile.absolutePath } 

Used as:

 commandLine getNdkBuildExecutablePath(), '-C', ... 
+1
source

Now Android Studio 1.3 on the Canary channel fully supports NDK. Give it a try. Link: http://tools.android.com/download/studio/canary/latest

+1
source

Source: https://habr.com/ru/post/982977/


All Articles