The problem is probably related to the gradle.properties file. If you ./gradlew tasks in the terminal ./gradlew tasks , you see the error you specified, but ./gradlew tasks --info show more detailed information about the error. For me, in all my projects, this was the same error message:
Java home is different. Wanted: DefaultDaemonContext[uid=null,javaHome=/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home,daemonRegistryDir=/Users/christian/.gradle/daemon,pid=66346,idleTimeout=null,daemonOpts=-XX:MaxPermSize=512m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant] Actual: DefaultDaemonContext[uid=4bf81505-0eab-4f50-859a-8c9c616b97e5,javaHome=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home,daemonRegistryDir=/Users/christian/.gradle/daemon,pid=65018,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=512m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
Solution: (no need to edit .bash_profile or lower degrees or delete gradle.folder).
- Add
org.gradle.java.home=path to gradle.properties. where path is the Android Studio Java path (the actual java address specified in --info ). For me, this is /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home , for you the path may be different.
This is what my gradle.properties file looks like after the change:
org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home org.gradle.daemon=true
Notes . The space between โAndroid Studioโ in the path is intentional; it does not work if the underscore is used. Escape characters \ allowed but not needed: ...Android\ Studio.app/Contents/jre....
I also included a runner to create the daemon, but was not needed to complete its tasks. If your null pointer error is different, use --info to point you in the right direction.
I'm runing:
Android Studio 3.1.4 (on a Mac 10.13) java version "10" classpath 'com.android.tools.build:gradle:3.1.4' (dependency)
Hope this helps someone!