Note: This seems to be an issue with the Android plugin. See comments for associated issues.
I get the following gradle error when building the project:
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).
This configuration worked (with the bundled jdk) in canary 9.
Credit to @Grsmto
As per this blog post you need to open a terminal and launch the following commands sequentially:
UPDATE
Now the workaround it's easier, you just need to go to Build -> Clean Project and then sync.
Windows
gradlew clean
gradlew assemble
Linux/Mac
./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. 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. You can then sync your project files with Gradle by clicking Sync Project from the toolbar.
See the release note for more details. 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)
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. You can then sync your project
files with Gradle by clicking 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". 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
. 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
.
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.
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.
See the release note for more details. https://androidstudio.googleblog.com/2017/08/android-studio-30-beta-1.html