简体   繁体   English

禁用特定项目的Gradle NDK构建

[英]Disable NDK build in gradle for specific project

I have an android library project that builds lib.aar artefact and an app project that imports this lib.aar after it was built. 我有一个构建lib.aar人工制品的android库项目,以及一个在构建后导入此lib.aar的应用程序项目。 lib.aar requires NDK 17 to be built since it has some C++ 17 code. lib.aar需要构建NDK 17,因为它具有一些C ++ 17代码。 I manage to build .aar file successfully but the app fails to compile with this message: A problem occurred starting process 'command '/Users/user/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/bin/mips64el-linux-android-strip'' . 我设法成功建立.aar文件,但应用无法通过以下消息编译: A problem occurred starting process 'command '/Users/user/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/bin/mips64el-linux-android-strip'' This is caused by the fact that NDK 17 removed support for MIPS and I can't upgrade to a newer version of android studio that uses NDK 18beta 这是因为NDK 17删除了对MIPS的支持,并且我无法升级到使用NDK 18beta的较新版本的android studio

If I remove the content of '/Users/user/Library/Android/sdk/ndk-bundle' folder, deleting the NDK, then the app builds without errors and I can use lib.aar code inside the app. 如果我删除“ / Users / user / Library / Android / sdk / ndk-bundle”文件夹中的内容,删除了NDK,则该应用程序会正确构建,并且可以在应用程序内部使用lib.aar代码。

So far I've tried this: How do I disable the NDK build in Android Studio 1.0.1 , this https://gist.github.com/ph0b/9e59058ac59cac104398 . 到目前为止,我已经尝试过: 如何禁用Android Studio 1.0.1中的NDK构建 ,该https://gist.github.com/ph0b/9e59058ac59cac104398 Setting env variable ANDROID_NDK_HOME to a dummy folder works, the app builds, but it's kind of a hack. 将env变量ANDROID_NDK_HOME设置为虚拟文件夹即可,应用程序可以构建,但这有点黑。

Is there any way to programmatically disable NDK build for the app project without deleting NDK folder? 有什么方法可以以编程方式禁用应用程序项目的NDK构建,而不删除NDK文件夹吗?

This is caused by the fact that NDK 17 removed support for MIPS and I can't upgrade to a newer version of android studio that uses NDK 18beta 这是因为NDK 17删除了对MIPS的支持,并且我无法升级到使用NDK 18beta的较新版本的android studio

r18 won't fix this problem either; r18也无法解决此问题; it still doesn't have mips support. 它仍然没有mips支持。 The fix to the problem is upgrading the gradle plugin version in your application to at least 3.1, which is the minimum required for NDK r17 (and, extremely unfortunately, is required for even having the NDK installed for some reason). 解决此问题的方法是将应用程序中的gradle插件版本至少升级到3.1,这是NDK r17所要求的最低要求(并且非常不幸的是,出于某种原因甚至安装了NDK也是必需的)。

The other solution here would be to install NDK r16b somewhere and then point at it from the app's local.properties, letting the aar pick from the SDK. 这里的另一个解决方案是将NDK r16b安装在某个地方,然后从应用程序的local.properties指向它,然后从SDK中选择aar。 If you're just working on a local build this will work, but since local.properties shouldn't be checked in to version control it won't help others much. 如果您只是在本地版本上工作,那么它将起作用,但是由于不应将local.properties签入版本控制,因此不会对其他人有太大帮助。

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

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