Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build android bundle for app using Gradle script?

I want to upgrade my release gradle script to make android bundle instead android apk package, but I can't find the command to create bundle programmatically from gradle script instead apk.

This is what I have to convert. What is the particular command that create the apk? And what is the specified command to use to create bundle? I can't find.

            // copy apk file
            variant.outputs.each { output ->
                if (output.outputFile != null) {
                    println "outputFile name ${output.outputFile.name}"

                    variant.assemble.doLast {
                        copy {
                            from output.outputFile
                            into destination
                            rename { String fileName ->
                                "app-${variant.productFlavors[0].name}-${buildType.name}-${versName}.apk"
                            }
                        }
                    }
                }
            }
        }
    }

I thought that was the

like image 809
tangalor Avatar asked Jul 25 '19 14:07

tangalor


1 Answers

You can use the command:

./gradlew bundle

or in general ./gradlew bundle<VariantName>.

The bundle can be found at: project-name/app/build/outputs/bundle/

More info in the official doc.

like image 82
Gabriele Mariotti Avatar answered Nov 01 '22 01:11

Gabriele Mariotti