3

I am developing an Android application and the time has come where new features should be tested in the same environment that serves the production app.

I have tried creating a new branch and renaming it to .testing in the manifest and gradle files, but I am havin issues with the provider, specifically stating:

I/dalvikvm: Could not find method android.app.Fragment.setSharedElementEnterTransition, referenced from method com.corp.app.AccountFrag.access$super

So I don't think this is the approach. I want the application to be installed in its two variants (they don't necessarily need to share data) and the user to open one or the other depending whether new features need to be tested in the production environment or the more reliable, stable version needs to be run.

Has anyone dealt with this problem before? I suspect I need to look into flavors, but I don't know.

Thanks in advance for the insight.

Graph
  • 592
  • 7
  • 13

1 Answers1

7

Use should use a different build type for beta.

In build.gradle of your app module,

android {

buildTypes {
        beta {
            applicationIdSuffix ".beta"
            versionNameSuffix "-beta"
            resValue "string", "app_name", "Beta App"
        }
        debug {

        }
        release {

        }
    }
}

Here, we are adding a suffix "beta" to the applicationId of your app. So you can have 2 variants of your app. If you want more than 2 variants in single mobile, simply add another variant with different suffix.

To use the package name in AndroidManifest, use ${applicationId} instead of com.example.dinesh. If you want to use the package name in java classes, use BuildConfig.APPLICATION_ID.

Product Flavors should not be used in this case. Product flavors are used, when you have two types of same product, like normal app and a paid app. To have beta of your app, you should use Build types.

Bob
  • 13,447
  • 7
  • 35
  • 45
  • Thank you for the answer, but I don't understand. I have added that code to my build.gradle file but don't know how to compile and generate different versions. – Graph May 03 '16 at 17:42
  • refer here: https://medium.com/yplan-eng/how-to-have-debug-beta-and-prod-builds-installed-at-the-same-time-696ec4c76211#.prq9repcw – Bob May 03 '16 at 18:29
  • 1
    to the bottom left corner of the Android Studio, you can see a option named "Build Variants". Tap on it and choose the build variant you want to run now. refer the image here: https://cms-assets.tutsplus.com/uploads/users/798/posts/25005/image/buildvariants.png – Bob May 03 '16 at 18:32
  • Thank you! I didn't know that :) Is it possible to create both at the same time? Also, I have problems with the content provider of the app, but I guess that is a different question... – Graph May 03 '16 at 19:15
  • In the "Gradle" view you have a variety of tasks to choose from, one in the build category will be called "assemble" that will build all variants of your app. – nasch May 04 '16 at 00:43
  • 1
    Refer here http://stackoverflow.com/a/24850080/4586742 for ContentProvider issues because of build variants. @Graph – Bob May 04 '16 at 03:28