7

When building multiple whitelable apps on the same codebase it's easy to use the build flavor mechanism of Android Studio. I can easily set a new applicationId in build.gradle file.

android {
    productFlavors {
        original {
            applicationId "com.original.myapp"
        }
        whitelable {
            applicationId "com.whitelable.myapp"
        }
    }
}

Everything's nice BUT the package name of the whitelable app is still com.original.myapp and the component name of the main activity is com.whitelable.myapp/com.original.myapp.MainActivity. Everybody can see that the whitelable app is build upon the original app.

Is the a way to replace the package name for the build flavor so the original package name at least doesn't appear on the flavored app's component names?

Alexey Ozerov
  • 1,398
  • 13
  • 23

1 Answers1

0

The question was asked a long time ago but I'd like to answer it for new folks who will investigate. First you have to create 2 versions with Flavors. Then, if you are using it, you need to create the data for the version you just created in the "client": [] section in your google-service.json file. (You can also create a separate google-service.json file for both in their own package folders.) Then use ${packageName} instead of explicitly typing your package path in the Manifest file with your package path. I was able to create 2 completely different packageNames by following this way.

Flavors;

flavorDimensions "default"
productFlavors{
    product1{
        applicationId "com.product.package"
    }

    product2{
        applicationId "com.white.label"
    }
}

google-service.json; I cannot share the google-service.json file, but the data under "client" in the google-service.json file you will receive for your new project via Firebase should be copied and added to the "client" as the second data under the google-service.json file in your project. Sample;

"client": [
{
  "client_info": { //Old App Info
    data...
  },
  ...
},
{
  "client_info": {
    //New App Info
    data...
  },
  ...
}
]

Manifest;

com.project.package.fileprovider

use this instead

${packageName}.fileprovider