Search code examples
android-ndkndk-buildandroid-ndk-r5

Android - NDK integration is deprecated error


I am trying to import an project from github called android-netspoof , I am new to NDK platform tools , I don't know about it. I already downloaded the NDK and extracted the zip , and added the path in environment variables. I want to import that project for learning but I am getting this error Error:(12, 0) Error: 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. <a href="openFile:C:\Users\Shreyash-2107\Desktop\android-netspoof-1.9.01111111\app\build.gradle">Open File</a> please help me importing this project.


Solution

  • The answer is in the error message (TL;DR: add "android.useDeprecatedNdk=true" to your gradle.properties), but it might not be obvious if you're not familiar with the history.

    Once upon a time, the Android tools team released a version of the Gradle plugin with NDK support. But Gradle wasn't very good at compiling C++, so the support wasn't everything they hoped it would be.

    Then Gradle decided to add really good C++ support. Only one problem: C++ is really different from Java, and the Gradle team realized that their Java-centric object model wasn't going to be up to the task. So they invented a new object model (which, incidentally, appears to be a much better design.) Unfortunately, the new object model has taken a while to incubate and still (as of April 2016) isn't officially released.

    That leaves Android Studio in an awkward place. There doesn't seem to be much point in trying to shoehorn C++ support into the old Gradle model, but at the same time it can't move to the new model until it's stable. The interim solution is to continue on the stable path for now, but also provide a plugin that works with Gradle's new experimental model.

    With that in mind, you can evaluate the two options that the error message is giving you. One is to continue with the old NDK support by adding "android.useDeprecatedNDK=true" to your gradle.properties file. The other is to use the experimental plugin, which requires you to make substantial changes to your current project.

    It sounds like you're trying to compile an existing project that you didn't write, and that existing project has a build script that uses the old NDK support. So you're probably going to want to go with the "useDeprecatedNDK" option. If you were writing a project from scratch, you'd probably be happier with the experimental plugin.