Search code examples
androidgradlejavac

Gradle error when build, failed to calculate


I debug my app and found this error:

1. Caused by: org.gradle.api.internal.provider.AbstractProperty$PropertyQueryException: Failed to calculate the value of task ':app:compileDebugJavaWithJavac' property 'options.generatedSourceOutputDirectory'.

2. Caused by: org.gradle.api.InvalidUserCodeException: Querying the mapped value of map(java.io.File task ':app:compileDebugJavaWithJavac' property 'annotationProcessorSourcesDirectory' org.gradle.api.internal.file.DefaultFilePropertyFactory$ToFileTransformer@57cd73ff) before task ':app:compileDebugJavaWithJavac' has completed is not supported


Solution

  • Found it!

    It is because of the Gradle build version. I had 3.8.0 and it was messing it up, switch to 4.2.0 instead.

    In your build.gradle:

    • buildscript-> dependencies-> classpath

    Like this:

    buildscript {
        repositories {
            google()
            mavenCentral()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:4.2.0'
        }
    }