Browse Tag

gradle

Gradle – How to open folder with generated APK?

android {
    applicationVariants.all { variant ->
        variant.outputs.all {
            def flavor = variant.productFlavors[0].name
            if (flavor == 'prod') { // Open folder for specific flavor
                variant.assemble.finalizedBy openFolderWithApk
            }
        }
    }

    task openFolderWithApk(type:Exec) {
        workingDir '../app/prod/release/' //Update flavor and buildType
        commandLine 'cmd', '/c', 'start .' //on windows
    }
}

Change output apk name using build.gradle

Output result:  AppNameProd4.1.2_050718.apk

android {
    applicationVariants.all { variant ->
        variant.outputs.all {
            def flavor = variant.productFlavors[0].name.capitalize()
            def version = variant.versionName
            def date = new Date()
            def formattedDate = date.format('ddMMyy')
            outputFileName = "AppName${flavor}${version}_${formattedDate}.apk"
        }
    }
}

Keep Reading