The following Android Developers Guide Configuring Gradle Builds I was able to create an application that uses the same code with different resources.
Firstly, after creating a new project in Android Studio (Gradle: Android Module), I added the build.gradle file (located in your modules directory, for example, "Project / app / build.gradle"), "blue" and "red" aromas:
android { // ... productFlavors { blue { applicationId 'com.example.app.blue' versionName '1.0-blue' } red { applicationId 'com.example.app.red' versionName '1.0-red' } } }
The IDE requested to sync project files with Gradle, so I did this. Then I added the colors.xml resource file to the “red” flavor by right-clicking on the “application” directory in the root of the project in the Project panel (“New” → “Android resource file”, selected “red” as the source set )
Next, I changed the new file to contain the definition of a color resource:
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="primary">#ff0000</color> </resources>
I did the same for my blue fragrance (but with a different color value).
I changed the background color of the activity layout, created automatically when creating a new project, to see if it will work.
<RelativeLayout ... android:background="@color/primary" />
The panel "Switch assembly of options in the panel" Assembly options "(opened by the names of the lower left buttons) led to different background colors in my activity.
I assume that you save your images, json and other files in Android, restores directories, so the way you have to store different files in different versions is similar to what I achieved.
See this site for a better understanding of product tastes and build options.