简体   繁体   English

Gradle错误升级到Android Studio 3.0 Beta 1

[英]Gradle error upgrading to Android Studio 3.0 Beta 1

Note: This seems to be an issue with the Android plugin. 注意:这似乎是Android插件的问题。 See comments for associated issues. 查看相关问题的评论。

I get the following gradle error when building the project: 构建项目时出现以下gradle错误:

Gradle sync failed: Cause: java.lang.NullPointerException
            at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:98)
            at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
            at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
            at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
            at java.nio.file.Paths.get(Paths.java:84)
            at com.android.build.gradle.internal.scope.BuildOutput.getOutputPath(BuildOutput.java:222)
            at com.android.build.gradle.internal.scope.BuildOutputs.lambda$load$2(BuildOutputs.java:243)
            at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
            at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1376)
            at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
            at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
            at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
            ...

I will note additionally that I had to set the jdk location manually because if I used the bundled one the gradle daemon would not start, complaining of not being in the expected context (it was expecting the bundled context, instead getting the external context). 我还要注意,我必须手动设置jdk位置,因为如果我使用捆绑的那个gradle守护程序将无法启动,抱怨不在预期的上下文中(它期望捆绑的上下文,而是获取外部上下文)。

This configuration worked (with the bundled jdk) in canary 9. 这种配置在金丝雀9中工作(使用捆绑的jdk)。

Credit to @Grsmto 归功于@Grsmto

As per this blog post you need to open a terminal and launch the following commands sequentially: 根据此博客文章,您需要打开终端并按顺序启动以下命令:

UPDATE UPDATE

Now the workaround it's easier, you just need to go to Build -> Clean Project and then sync. 现在解决方法更容易,你只需要去Build - > Clean Project然后同步。

Windows 视窗

gradlew clean

gradlew assemble

Linux/Mac Linux的/苹果机

./gradlew clean

./gradlew assemble

then sync the project. 然后同步项目。

From https://androidstudio.googleblog.com/2017/08/android-studio-30-beta-1.html , this is a known issue: If you have an existing Android Studio project that's using an alpha version of Android plugin 3.0.0 (such as 3.0.0-alpha9 ), you may get the following error when you migrate to Android plugin 3.0.0-beta1 and sync your project: Gradle project refresh failed . 来自https://androidstudio.googleblog.com/2017/08/android-studio-30-beta-1.html ,这是一个已知问题:如果您现有的Android Studio项目使用的是Android版插件3.0的alpha版本.0(例如3.0.0-alpha9 ),当您迁移到Android插件3.0.0-beta1并同步项目时,可能会出现以下错误: Gradle项目刷新失败 You could solve it by doing the following steps: 您可以通过执行以下步骤来解决它:

Selecting Build > Clean Project from the menu bar—you need to perform this action only once for each project. 从菜单栏中选择Build > Clean Project - 您需要为每个项目仅执行一次此操作。 You can then sync your project files with Gradle by clicking Sync Project from the toolbar. 然后,您可以通过单击工具栏中的“ 同步项目”将项目文件与Gradle 同步

See the release note for more details. 有关详细信息,请参阅发行说明。 https://androidstudio.googleblog.com/2017/08/android-studio-30-beta-1.html https://androidstudio.googleblog.com/2017/08/android-studio-30-beta-1.html

Happy coding! 快乐的编码!

Its a known issue : As Documented here 它是一个众所周知的问题: 在这里记录

Just do this simply (No need to type commands) 只需这样做(不需要输入命令)

  • Build > Clean Project from the menu bar. 从菜单栏中构建>清理项目

  • Then sync your project files with Gradle by clicking Sync Project from the toolbar. 然后通过单击工具栏中的“同步项目” 将项目文件与Gradle同步。

Gradle sync failed: Cause: java.lang.NullPointerException
            at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:98)
            at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
            at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
            at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
            at java.nio.file.Paths.get(Paths.java:84)

Read official Release Guideline 阅读官方发布指南

Resolve this issue selecting Build > Clean Project from the menu bar —you need to perform this action only once for each project. 菜单栏中选择Build > Clean Project解决此问题 - 您只需为每个项目执行一次此操作。 You can then sync your project files with Gradle by clicking Sync Project from the toolbar . 然后,您可以通过单击Sync Project from the toolbar sync your project文件与Gradle Sync Project from the toolbar

NOTE 注意

3.0 Beta 1 or 3.0 Beta 2

An early version of a program or application that contains most of the major features, but is not yet complete. 包含大多数主要功能但尚未完成的程序或应用程序的早期版本。 Sometimes these versions are released only to a select group of people, or to the general public, for testing and feedback . 有时,这些版本仅发布给选定的一组人或公众,以进行测试和反馈。

Also if none of the 'clean', 'build' etc did not work, then go to Build menu and select "Make Project". 此外,如果“clean”,“build”等都不起作用,则转到Build菜单并选择“Make Project”。 It fixed the error for me. 它为我修复了错误。

Although it is advisable to perform a clean and build before this. 虽然建议在此之前执行清理和构建。

If clean and sync doesn't quite work for your Java+Kotlin-mixed project, it's possible that you need to change your Kotlin version to be consistent with the IDE supplied Kotlin version, which as of Android Studio 3.0 Beta 2 is 1.1.3-2 . 如果cleansync对您的Java + Kotlin混合项目不起作用,则可能需要更改Kotlin版本以与IDE提供的Kotlin版本保持一致,该版本从Android Studio 3.0 Beta 2开始是1.1.3-2 I was using 1.1.4 at the time and I found that I had drop it back down, did my clean and sync before it all works again, at which point I can move back to 1.1.4 . 我当时正在使用1.1.4 ,我发现我把它放回去了,在它全部再次工作之前做了我的cleansync ,此时我可以回到1.1.4

Known issue: If you have an existing Android Studio project that's using an alpha version of Android plugin 3.0.0 (such as 3.0.0-alpha9), you may get the following error when you migrate to Android plugin 3.0.0-beta1 and sync your project: Gradle project refresh failed. 已知问题:如果您现有的Android Studio项目使用Android版插件3.0.0的alpha版本(例如3.0.0-alpha9),则迁移到Android插件3.0.0-beta1时可能会出现以下错误:同步项目:Gradle项目刷新失败。

Resolve this issue selecting Build > Clean Project from the menu bar—you need to perform this action only once for each project. 从菜单栏中选择“生成”>“清理项目”解决此问题 - 您只需对每个项目执行一次此操作。 You can then sync your project files with Gradle by clicking Sync Project from the toolbar. 然后,您可以通过单击工具栏中的“同步项目”将项目文件与Gradle同步。

See the release note for more details. 有关详细信息,请参阅发行说明。 https://androidstudio.googleblog.com/2017/08/android-studio-30-beta-1.html https://androidstudio.googleblog.com/2017/08/android-studio-30-beta-1.html

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

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