runningcode / gradle-doctor

The right prescription for your Gradle build.
http://runningcode.github.io/gradle-doctor
Apache License 2.0
723 stars 47 forks source link

Is ugly crashing at synching or building project #184

Closed jblejder closed 2 years ago

jblejder commented 2 years ago

I am on M1 macbook pro and I'm freshly setting up Android environment for existing project so I am probably missing some config but the error is not much helpful and does not lead anywhere. So as it's probably my fault it's breaking I do believe it could provide more meaningful message.

So I got fresh Android Studio install from Toolbox. Doctor complain JAVA_HOME is not set Trying to set it to Android internal but no help. Decided to install Azul java 11 and use that everywhere. This crash.

I have JAVA_HOME set to /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home In android studio I have it too

Build and syncing project is ugly crashing with an error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project '(project-name)'.
> Failed to notify project evaluation listener.
   > /Users/(user))/Library/Application

Part of stack trace that I have

Caused by: java.nio.file.NoSuchFileException: /Users/(user)/Library/Application
    at com.osacky.doctor.JavaHomeCheck.isGradleUsingJavaHome(JavaHomeCheck.kt:68)
    at com.osacky.doctor.JavaHomeCheck.onStart(JavaHomeCheck.kt:41)
    at com.osacky.doctor.DoctorPlugin$apply$1.execute(DoctorPlugin.kt:63)
    at com.osacky.doctor.DoctorPlugin$apply$1.execute(DoctorPlugin.kt:31)

Update I managed to make it working fine. Once I set one java everywhere and restart android studio. What do you think about catching such exception and provide message to suggest verify java everywhere is the same + restart android studio?

runningcode commented 2 years ago

THanks for letting me know that you got it work. PRs are very welcome for the fix. I am not sure I would be able to properly catch this exception without being able to reproduce it and without having been provided the full stack trace.

runningcode commented 2 years ago

This is a bug in Android Studio. https://github.com/runningcode/gradle-doctor/issues/174#issuecomment-1022302834