Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create multiple apk files with one project build in Android Studio

I have two flavors in my Android project, one works with test server and one with production. I store the URL inside a string resource, so I may access the correct URL based on a flavor that I choose for compilation. Usually I need to create multiple apk files during a day, each time for both servers.

Is there a way to create two apk files each time I run my project or build an apk from Build menu?

like image 756
Yury Fedorov Avatar asked Mar 22 '16 16:03

Yury Fedorov


1 Answers

If you have something like this:

android {
    productFlavors {
        dev {
            applicationId "your.com.android.devel"
            buildConfigField 'String', 'HOST', '"http://192.168.1.78"'

        }

        prod {
            applicationId "your.com.android"
            buildConfigField 'String', 'HOST', '"http://yourserver.com"'
        }
    }
}

You only have to run assemble in Gradle projects

enter image description here

And you can find all the different apks build/outputs/apk

enter image description here

Hope this time I'd be more helpful

like image 174
Miguel Benitez Avatar answered Oct 12 '22 09:10

Miguel Benitez