简体   繁体   English

如何在Android Studio中完全禁用NDK支持

[英]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. 我们有一个带有本机支持的多平台项目,我们正在使用libgdx在Android Studio中进行开发。 We have builds working for Desktop, IOS, Android, Android Wear, and HTML5. 我们拥有适用于台式机,IOS,Android,Android Wear和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. 在上述每个平台上,我们都有一个不同的“本机”插件正在使用:IOS上的静态.a本机库,Windows上的.dll,Android上的.so文件堆以及HTML5上的Javascript库。 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. 所有这些(HTML5版本除外)都是在单独的平台上构建的,因此不可能由同一Android Studio NDK构建构建。

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. 问题在于,对于每个声明JNI例程的.java文件,Android Studio 1.4.x都希望找到源文件,但是这些源文件可能无法在IOS项目中进行编译,对于PC项目也同样如此。在Mac上运行。

The standard solution on SO is to add SO的标准解决方案是添加

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. 到android {}部分,但这仅适用于Android,Android Wear启动器项目,不适用于桌面,IOS,HTML5等。

I just want Android Studio to give up on trying to compile NDK, because it can't possibly be done on non-Android projects. 我只想让Android Studio放弃尝试编译NDK,因为它不可能在非Android项目上完成。 Other than finding a downgrade somewhere, how do I do that? 除了在某处找到降级之外,我该怎么做?

Thanks! 谢谢!

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 当然,NDK构建器只是IntelliJ中的一个插件,因此要禁用它,您要做的就是

  • go to your AndroidStudio installation, 转到您的AndroidStudio安装,
  • find the "plugins" directory 找到“插件”目录
  • move or delete the "android-ndk" folder 移动或删除“ android-ndk”文件夹

Tada! 多田! No more NDK plugin! 没有更多的NDK插件!

Correct way is to uninstall NDK using SDK manager. 正确的方法是使用SDK管理器卸载NDK。 go to Android Studio-> Tools -> SDK Manager 转到Android Studio->工具-> SDK管理器

Under SDK tools tab uncheck "NDK", "CMake", "LLDB" and then apply changes. 在“ SDK工具”选项卡下,取消选中“ NDK”,“ CMake”,“ LLDB” ,然后应用更改。 NDK components will be removed. NDK组件将被删除。 Downside is NDK is removed for all project. 缺点是NDK对于所有项目都已删除。 Still struggling to find a way to disable NDK for a particular project only. 仍在努力寻找一种仅对特定项目禁用NDK的方法。

If you would like to keep the NDK build for future use and not use it for specific projects just make sure to uncheck these options in the new project dialog... 如果您想保留NDK构建以供将来使用,而不是将其用于特定项目,只需确保在新项目对话框中取消选中这些选项即可。

链接到屏幕截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM