如何修复android studio 2.3 NDK bug?

[英]How to fix android studios 2.3 NDK bug?


I'm assuming it's a bug since I didn't have any problems until the new update. So I cant use the gradle console to debug my app because I have this warning -

我认为这是一个错误,因为我没有遇到任何问题,直到新的更新。所以我不能使用gradle控制台调试我的应用程序,因为我有这个警告 -

"Configuration on demand is an incubating feature. NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\Emily Thacker\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning."

“按需配置是一个孵化功能.NDK缺少”平台“目录。如果您使用NDK,请验证ndk.dir是否设置为有效的NDK目录。它当前设置为C:\ Users \ Emily Thacker \ AppData \ Local \ Android \ Sdk \ ndk-bundle。如果您没有使用NDK,请从ANDROID_NDK_HOME或local.properties取消设置NDK变量以删除此警告。“

I am pretty sure I am not using NDK and I dont see how I can fix this problem here is my local.properties

我很确定我没有使用NDK,我不知道如何解决这个问题,这是我的local.properties

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=C\:\\Users\\Emily Thacker\\AppData\\Local\\Android\\Sdk

Also I do not see a ANDROID_NDK_HOME file in my directory.

另外,我在目录中看不到ANDROID_NDK_HOME文件。

8 个解决方案

#1


19  

I was able to prevent this annoying message; here is what worked for me.

我能够防止这个烦人的消息;这对我有用。

BACKGROUND:

背景:

  1. I am not using the NDK at all, and had never installed the NDK.

    我根本没有使用NDK,也从未安装过NDK。

  2. However, as mentioned in another answer here by xsveda, this is a Gradle bug that is documented here:

    但是,正如xsveda在另一个答案中所提到的,这是一个Gradle错误,在此处记录:

    https://code.google.com/p/android/issues/detail?id=228424

    https://code.google.com/p/android/issues/detail?id=228424

    and so even the "NDK-innocent" may become its victims.

    甚至“NDK无辜”也可能成为它的受害者。

  3. The problem is that Gradle is computing the location of an NDK folder by just tacking on the string "/ndk-bundle" to the SDK folder location, even if you have never installed the NDK.

    问题是Gradle正在计算NDK文件夹的位置,只需将字符串“/ ndk-bundle”添加到SDK文件夹位置,即使您从未安装过NDK也是如此。

  4. After establishing this false expectation of an NDK folder existing in a particular location, each time you build, Gradle gives you a warning that you're "missing" that folder. This is just a warning and does not prevent your build from completing, but it is annoying.

    在确定存在于特定位置的NDK文件夹的这种错误期望之后,每次构建时,Gradle都会向您发出警告,指出您“丢失”了该文件夹。这只是一个警告,并不会阻止您的构建完成,但它很烦人。

HOW I STOPPED THE ANNOYING MESSAGE:

我如何停止令人生气的消息:

Since disk space is cheap, and my time is precious to me, I humored this bug by installing the NDK, even though I do not intend to use it.

由于磁盘空间很便宜,而且我的时间对我来说很宝贵,所以我通过安装NDK来解决这个问题,即使我不打算使用它。

To do this, you can go to:

为此,您可以访问:

File -> Project Structure -> SDK Location

文件 - >项目结构 - > SDK位置

and look in the Android NDK location field. If you have not installed the NDK, this field will be empty.

并查看Android NDK位置字段。如果尚未安装NDK,则此字段将为空。

In that case, below that field will be a link for installing the NDK. Click on that link and install it. It takes a few minutes.

在这种情况下,该字段下方将是用于安装NDK的链接。单击该链接并进行安装。这需要几分钟。

Once the installation completes and you close the installation progress dialog, the location of the NDK will be automatically written into the Android NDK location field. This will be something like:

安装完成并关闭安装进度对话框后,NDK的位置将自动写入Android NDK位置字段。这将是这样的:

C:\dev\astudiosdk\ndk-bundle

C:\ dev的\ astudiosdk \ NDK束

Click the OK button and build again. The error disappears.

单击“确定”按钮,然后重新构建。错误消失了。

Note that you may be able to just type the expected folder into this field; I did not try that. But I don't know whether that might cause some other problems, especially if you eventually decide to actually use the NDK.

请注意,您可以只在此字段中键入预期的文件夹;我没试过。但我不知道这是否会引起其他问题,特别是如果你最终决定实际使用NDK。

#2


8  

Sounds like maybe updating SDK from Android Studio IDE could help

听起来像从Android Studio IDE更新SDK可能有所帮助

Steps are:

步骤是:

  1. Go to Tools (top-menu item) > Android > SDK Manager
  2. 转到工具(顶级菜单项)> Android> SDK Manager
  3. Click SDK Tools tab
  4. 单击SDK工具选项卡
  5. Scroll down to the NDK checkbox update-option
  6. 向下滚动到NDK复选框更新选项

Screen shots here: How to update Android NDK in place?

屏幕截图:如何更新Android NDK?

#3


7  

Just install the Android NDK.

只需安装Android NDK即可。

That fixed my error and warning!

这修复了我的错误和警告!

https://i.stack.imgur.com/Lsu8E.png

  1. Go to Tools -> Android -> SDK Manager
  2. 转到工具 - > Android - > SDK Manager
  3. Click SDK Tools
  4. 单击SDK工具
  5. CHECK NDK
  6. 检查NDK
  7. Apply and quit.
  8. 申请并退出。

#4


6  

You can give it a try :

你可以尝试一下:

There is a checkbox for it in android studio already.

android studio中已经有一个复选框。

Android Studio -> Preferences -> Compiler -> Gradle -> Command-line Options -> Configure on Demand

Android Studio - >首选项 - >编译器 - > Gradle - >命令行选项 - >按需配置

Uncheck it and then sync gradle again

取消选中它,然后再次同步gradle

enter image description here

#5


4  

Fixed this issue by removing an empty ndk-bundle folder from SDK root folder (have no idea why and when it has appeared):

修复了此问题,方法是从SDK根文件夹中删除一个空的ndk-bundle文件夹(不知道为什么以及何时出现):

ndk-bundle folder in android SDK folder

Here is the explanation why it helps from the issue on Android bug tracker:

以下是解释为什么它可以帮助解决Android错误跟踪器上的问题:

For anyone still experience this issue on plugin 3.0.0-alpha1 or later. Please file a new bug and try to answer all question in #33. We need more information to debug the problem and adding comments to a closed bug is an easy way for it to get lost.

对于任何人仍然在插件3.0.0-alpha1或更高版本上遇到此问题。请提交新的错误并尝试回答#33中的所有问题。我们需要更多信息来调试问题,并向已关闭的bug添加注释是一种让它迷失的简单方法。

To give a bit of background, the plugin checks whether the NDK directory is valid. Most likely, you are not using NDK. We automatically assume it's in {sdk}/ndk-bundle. It will be ignored if {sdk}/ndk-bundle does not exist. If you see 'NDK is missing a "platforms" directory.', it means there is an {sdk}/ndk-bundle, but not a {sdk}/ndk-bundle/platforms directory. This means you have a corrupted NDK for some reason. It is safe to just remove {sdk}/ndk-bundle if you are not using it.

为了给出一些背景知识,插件会检查NDK目录是否有效。最有可能的是,您没有使用NDK。我们自动假设它在{sdk} / ndk-bundle中。如果{sdk} / ndk-bundle不存在,将被忽略。如果您看到'NDK缺少“平台”目录。',则表示存在{sdk} / ndk-bundle,但不是{sdk} / ndk-bundle / platforms目录。这意味着由于某种原因你有一个损坏的NDK。如果您不使用它,可以安全地删除{sdk} / ndk-bundle。

#6


2  

You should not use a directory path with spaces for Android SDK. As an easy cure you can manually change

您不应该为Android SDK使用带空格的目录路径。作为一种简单的治疗,您可以手动更改

sdk.dir=C:/Users/EMILYT~1/AppData/Local/Android/Sdk

You don't need to install NDK.

您不需要安装NDK。

#7


0  

For me, the NDK error turned out to be a false diagnosis. This error occurred when gradle threw a ClassNotFound exception on java.io.UncheckedIOException class.

对我来说,NDK错误被证明是错误的诊断。 gradle在java.io.UncheckedIOException类上抛出ClassNotFound异常时发生此错误。

Although the class is defined in Java 8, it was not included in the JDK 1.8.0u51 (or presumably earlier versions) which I had installed.

尽管该类是在Java 8中定义的,但它并未包含在我安装的JDK 1.8.0u51(或者可能是早期版本)中。

Updating the JDK and removing the 1.8.0u51 version resolved the issue.

更新JDK并删除1.8.0u51版本解决了该问题。

#8


0  

This type of error statement are:-

这种类型的错误陈述是: -

  1. NDK is missing a "platforms" directory.
  2. NDK缺少“平台”目录。
  3. How to set ANDROID_NDK_HOME so that Android Studio does not ask for ndk location?
  4. 如何设置ANDROID_NDK_HOME以便Android Studio不要求ndk位置?

Solution:

解:

Open your build.gradle and here you are see two gradle path like: classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.android.tools.build:gradle:2.2.0'

打开build.gradle,在这里你可以看到两个gradle路径:classpath'com.android.tools.build:gradle:2.3.0'classpath'com.android.tools.build:gradle:2.2.0'

You can remove one of those classpath and keep only one Classpath.

您可以删除其中一个类路径并仅保留一个Classpath。

Clean the project gradlew clean

清洁项目gradlew清洁

This is working for me never require to set the ndk path or the ndk setting.

这对我来说永远不需要设置ndk路径或ndk设置。

Android Studio NDK 2.3 BUG


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2017/03/08/18972113fb5e8e7d4da57578a18c7d7c.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号