As in gradle
4.4
it is not possible to change path of APK output file and we can't use absolute path for the apk's output now from the docs - Modifying variant outputs at build time may not work so I searched on SO and found a solution that we can copy apk
to our desired location after it gets build but I don't have much idea on gradle scripting and i am not able to call copy task. Can anyone help me.
code from my gradle :
android {
................
android.applicationVariants.all { variant ->
variant.outputs.all {
if (variant.name.contains("Release")) {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
assembleRelease {
dependsOn copyDocs
}
}// end of android brace
task copyApk(type: Copy) {
from outputFileName
into file("${project.buildDir}/outputs/apk")
}
}
From this way i am getting error :
Could not get unknown property 'outputFileName' for task
Any idea how to copy apk file to another path? Thanks.