2

I have a core product (for example School core) Now I need to launch it for 2 school (example School A and School B). Only different is app icon splash screen. I try to manage this through flavour. As we know to upload to google play store we need different package name, so I got stuck there.

My flavour looks like this -

productFlavors {
    main {
        applicationId "net.school.main"
        versionCode 7
        versionName "2.12"
    }
    schoolA {
        versionCode 2
        versionName '1.01'
        applicationId 'net.school.schoolA'
    }
    schoolB {
        versionCode 1
        versionName '1.0'
        applicationId 'net.school.schoolB'
    }
}

When I run the flavour schoolA it's saying package not found. I am looking for best approach so that in future any new school can be added with minimal changes.

A J
  • 4,542
  • 5
  • 50
  • 80

2 Answers2

1

Unfortunately you cannot change Package name for different flavour.

Every Android app has a unique application ID that looks like a Java package name, such as com.example.myapp. This ID uniquely identifies your app on the device and in Google Play Store. So you can either redefine the complete applicationId property, or you can append a segment to the default application ID using applicationIdSuffix suffice. Refer to official document for more details.

Sagar
  • 23,903
  • 4
  • 62
  • 62
  • I already added the applicationId based on the flavour as you can see. But when I am running the app (Flavour schoolA) it's looking for the net.school.main.SplashScreenActivity but I have added the SplashScreenActivity net.school.schoolA – A J May 27 '18 at 04:37
  • Can you update your question with Manifest.xml? If SplashScreenActivity is launcher activity then you have to define it for `main` too – Sagar May 27 '18 at 04:39
1

Did you solve the problem?

In my case it works perfectly. try like this

buildTypes {
        release {

        }
    }

flavorDimensions "main"

productFlavors {
main {
    applicationId "net.school.main"
    versionCode 7
    versionName "2.12"
}
schoolA {
    versionCode 2
    versionName '1.01'
    applicationId 'net.school.schoolA'
}
schoolB {
    versionCode 1
    versionName '1.0'
    applicationId 'net.school.schoolB'
}
}

And now you can put app icon to src/scholA/res/ standard folders like drawable or mipmap. And use Build Variants to make debug or release of each flavor.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Vadim Eksler
  • 865
  • 9
  • 24