tableple.blogg.se

Build variant in android studio
Build variant in android studio









build variant in android studio

In - create new Class - PackageReader.I have a list of build variants in my project and the default selected is the first one in the top of the list,.We will be following these steps to create Native Module, read the package name, and then send this info over Bridge JS> bridge, so we can use it within our APP logic. We are going to need to add custom Native package to get the package name and based on that to produce the right image. We will simply read the package name and point to the right image in assets. In this phase we are going to add logic to show different assets/images on HomePage of our APP, depending on the flavor installed. Now run command to build Mario flavor, and repeat same steps from above 1) to verify.Īt this point we should have 2 flavors of the same APP installed with different icons and APP names! - Nice, huh?.Then run command: (this will list the installed packages) in Terminal and you should see the package: “com.android_flavors.spongebob” Run command “npm run android-bob” to build Sponge Bob flavor, after build copleted, we will see the APP with name “Sponge Bob” and respective icon.Also, for release version, will need to generate signing keys - just google how to do that (it is very easy to sign your APP with Android Studio). Create launch icons - launch Android Studio, choose from menu, then navigate to the android folder inside your project and open, once project opened and gradle is synced, to make it easier choose on top:įor this demo I only added “Debug” builds, so do not forget to add script to create release package of your flavor, something like that.Add assets folder in the root of your project and place 2 images to it - I use mario.png and spongebob.png.React-native init android_flavors(Mac OS users - do not forget to add local.properties with path to SDK).The complete solution source code can be found here. We’ll build a test application with 2 flavors - Sponge Bob and Mario.

build variant in android studio

I assume that you are familiar with basic React-Native, know what and are, have Android Studio and ADB installed on your system. And this article is about how I solved it. Recently I was faced with the task to use a different set of assets in application, while keeping the same codebase. Android Flavors, how to change icons of your build and assets based on the flavor using the same code base.











Build variant in android studio