Trying to build Android project in intellij idea and getting following error: Build file 'C:\Users...\app\build.gradle' line: 91
A problem occurred configuring project ':app'.
groovy.lang.MissingMethodException: No signature of method: org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar.toPath() is applicable for argument types: () values: [] Possible solutions: each(groovy.lang.Closure), tap(groovy.lang.Closure), with(groovy.lang.Closure), with(boolean, groovy.lang.Closure), getAt(java.lang.String), putAt(java.lang.String, java.lang.Object)
applicationVariants.all { variant ->
variant.outputs.each { output ->
def project = "Demo"
def flavourName = variant.flavorName
def variantName = "Build"
def apkName = project + "-" + flavourName + "-" + variantName + "-" + versionName + ".apk"
def relativeRootDir = variant.packageApplicationProvider.get().outputDirectory.toPath()
.relativize(rootDir.toPath()).toFile() // <-- error line
output.outputFileName = new File("$relativeRootDir/release", apkName)
}
}
How to solve this? what should I change?