Android release apk is created in
...\Foo\Foo\build\outputs\apk\release\foo.apk
how can I change this path?
I want to save my apk for some projects in specific path.
Is this possible ?
Android release apk is created in
...\Foo\Foo\build\outputs\apk\release\foo.apk
how can I change this path?
I want to save my apk for some projects in specific path.
Is this possible ?
Yes this is possible. you can set where your apk is to be generated,
in your Project level build.gradle
add the path you need inside allprojects :
allprojects {
buildDir = "/D:/Foo/Bar/Android/Build/"
...
}
This will create your apk alongwith the generated, intermediates, temp etc. folders inside the Build folder in the specified path. If you wish to have it generated in a folder with the Project Name etc use:
buildDir = "/D:/Foo/Bar/Android/Build/${rootProject.name}/${project.name}"
For more reference you can check this answer.
UPDATE:
I couldn't find any way to directly generate the release apk into some specific folder, But if its ok to save a copy of this apk into another folder you can achieve this using gradle's Copy
task
. In your APP level gradle you can try the below code I tested out.
afterEvaluate {
// to execute the copy task every time a release build is generated
packageRelease.finalizedBy(copyRelease)
}
task copyRelease(type: Copy) {
// set your paths here
def sourcePath = file ("/release/app-release.apk").absolutePath
def destinationPath = "/D:/Foo/Bar/Android/Build/"
// set a name for your build if you are going to rename it
def releaseName = "${rootProject.name}.apk"
from "$sourcePath"
into "$destinationPath"
//use the below line if you wish to rename the apk
rename { releaseName }
}
Even though it suggested to add this inside android {...}
block simply adding it outside seems to work. So even though apk doesn't get directly generated to your folder the task does copy the same to save it into the folder of your choice.
Incase you need it for debug builds, use packageDebug
instead and change your paths accordingly.
Hope this is what you were looking for.