Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get resulted apk file path from android gradle plugin

I have gradle task that depends on assembleRelease

sendReleaseCandidate.dependsOn assembleRelease

And I want to get resulted apk file path. From my task I've wrote:

def apk = android.applicationVariants.release.outputFile

But it doesn't work. What i'm doing wrong?

Thanks!

ps: android plugin 0.11.1, for now I stick with uri('./build/outputs/apk/<app_name>-release.apk').path but it seems aweful.

like image 430
MikhailKrishtop Avatar asked Mar 19 '23 09:03

MikhailKrishtop


1 Answers

You can loop through the variants to find the one you need:

def apk = null
android.applicationVariants.all { variant ->
    if ( (variant.name).equals("release") ) {
        variant.outputs.each { output ->
            apk = output.outputFile
        }
    }
}
println "Found output file: " + apk
like image 131
Kevin Brotcke Avatar answered Mar 21 '23 23:03

Kevin Brotcke