Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to completely disable NDK support in Android Studio

We have a multi-platform project, with native support, that we are developing in Android Studio using libgdx. We have builds working for Desktop, IOS, Android, Android Wear, and HTML5.

On each of these platforms, we have a different "native" plugin that we are using: a static .a native library on IOS, a .dll on Windows, a bunch of .so files in Android, and a Javascript library on HTML5. All of these, except for the HTML5 version, are built on separate platforms so can't possibly be built by the same Android Studio NDK build.

The problem is that for each of the .java files that declare JNI routines, Android Studio 1.4.x wants to find the source files, but those source files can't possibly be compiled in the IOS project, and likewise for the PC project when running on a Mac.

The standard solution on SO is to add

sourceSets {
    main {
        jni.srcDirs = [] //disable automatic ndk-build
    }
}

To the android{} section, but this ONLY works for the Android, Android Wear launcher projects, and NOT Desktop, IOS, HTML5, etc.

I just want Android Studio to give up on trying to compile NDK, because it can't possibly be done on non-Android projects. Other than finding a downgrade somewhere, how do I do that?

Thanks!

like image 469
c.fogelklou Avatar asked Jul 17 '15 13:07

c.fogelklou


2 Answers

So, I decided that I could figure this out - and I did!

Of course, the NDK builder is just a plugin in IntelliJ, so all you have to do to disable it is to

  • go to your AndroidStudio installation,
  • find the "plugins" directory
  • move or delete the "android-ndk" folder

Tada! No more NDK plugin!

like image 166
c.fogelklou Avatar answered Sep 21 '22 09:09

c.fogelklou


Correct way is to uninstall NDK using SDK manager. go to Android Studio-> Tools -> SDK Manager

Under SDK tools tab uncheck "NDK", "CMake", "LLDB" and then apply changes. NDK components will be removed. Downside is NDK is removed for all project. Still struggling to find a way to disable NDK for a particular project only.

like image 32
Sojan P R Avatar answered Sep 21 '22 09:09

Sojan P R