Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle error upgrading to Android Studio 3.0 Beta 1

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.

like image 935
der_Fidelis Avatar asked Aug 09 '17 17:08

der_Fidelis


People also ask

How do I upgrade Android Gradle to latest version?

Update Gradle For the best performance, you should use the latest possible version of both Gradle and the plugin. You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or update your Gradle version using the command line.

How do I fix Gradle issues?

For this, you have to connect your PC to the internet and you have to open your Android studio. After opening your project click on the Sync Project with Gradle files option. This will automatically download the new Gradle files and will fix the issue which is caused by the Gradle files.

Why is Gradle sync failing?

Missing Files: There is a chance of Gradle files getting misplaced. This can be solved by re-installing the required files. Using the Proxy Servers: There was an issue with the syncing of the Gradle when Proxy Servers were turned on. Disabling it can help.

Why is my Gradle version not up-to-date?

The Android Studio uses Gradle to help add features to the Android apps. It is advised to keep the Gradle version up-to-date and compatible in tandem with the Android Studio. If your Gradle version is not updated you might also get the below error – Generating signed Bundle requires you to update the Android Gradle plugin to version x.y.z or higher

How to set Gradle version in Android Studio?

Step 1: Open Android Studio and navigate to File → Settings Then just click on Build, Execution, Deployment Tab Build →... Step 2: Selecting desired Gradle version.

What is the Android Gradle plugin?

The Android Studio build system is based on Gradle, and the Android Gradle plugin adds several features that are specific to building Android apps. Although the Android plugin is typically updated in lock-step with Android Studio, the plugin (and the rest of the Gradle system) can run independent of Android Studio and be updated separately.

Why is androidtestapi not working in Gradle?

Because local modules can't depend on your app's test APK, adding dependencies to your instrumented tests using the androidTestApi configuration, instead of androidTestImplementation, causes Gradle to issue the following warning: Fixes an issue where Android Studio doesn't properly recognize dependencies in composite builds.


1 Answers

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.

like image 103
der_Fidelis Avatar answered Oct 02 '22 17:10

der_Fidelis