Android Studio: How to fix error "java.lang.NullPointerException (no error message)"
I try to work with old project that hasn’t been updated years ago. I got an exception without any explanation.
Code:
A problem occurred configuring project ':app'.
> java.lang.NullPointerException (no error message)
The error is caused by gradle. Most of the answers I found didn’t help, because whatever I do, it always fails. After hours and hours, I finally found a fix by myself. Change gradle version to latest verison
Assuming you know the latest version of gradle version, open build.gradle (NOT in /app/build.gradle) and change com.android.tools.build:gradle to latest version in the dependencies.
Example:
Code:
'com.android.tools.build:gradle:3.4.0'
to
Code:
'com.android.tools.build:gradle:4.1.2'
(4.1.2 as of March 2021)
Now Sync, if asked
You will now get another error about Gradle version, just click the blue text Fix Gradle wrapper and re-import project.
You should be good to go \o/
Hope it helps!