I changed gradle version 5.6.1 to 6.5.1 and also 'com.android.tools.build:gradle:3.5.0' to 'com.android.tools.build:gradle:4.0.1'. After that I got FAILURE: Build failed with an exception.
* What went wrong:
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: with(groovy.lang.Closure), each(groovy.lang.Closure), tap(groovy.lang.Closure), with(boolean, groovy.lang.Closure), getAt(java.lang.String), putAt(java.lang.String, java.lang.Object)
I understand that in new gradle does not exist method .toPath(), but what alternative was added to new gradle? Or is it exist another way to get relative path of my project?
here is code example:
buildTypes {
release {
applicationVariants.all { variant ->
variant.outputs.all { output ->
def relative_apk_folder = output.packageApplication.outputDirectory.toPath().relativize(project.rootDir.toPath()).toString() + "/bin/"
outputFileName = new File("$relative_apk_folder" + "MyAPK.apk")
}
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.sign_app
}
debug {
}
}
Try this one:
def relative_apk_folder = "../../../../../bin/" outputFileName = new File(relative_apk_folder + "MyAPK.apk")
It helped in my project.