Search code examples
androidgoogle-playandroid-productflavors

How to merge two different projects that are already in playstore using flavors


The problem i am facing is there is two project(apps) similar and there will be more in future and when i change a code in one i will need to do same changes in other projects. when i searched on web i found product flavors but not sure if it's the answer for my problem.

How can i merge two different projects (apps) in playstore. Projects codes are %85 similar can i use flavors to merge both project in one and will i be able to update them in playstore using different jks with different package names and a few different permissions. Will i need AndroidManifest file for each flavor.

How can i solve this problem. Thanks


Solution

  • To change packageName you have to create product Flavor like

    flavorDimensions "versionCode"
    
    productFlavors {
    
        doctorApp {
            dimension "versionCode"
            applicationId  "com.doctor.app"
    
        }
        patientApp {
            dimension "versionCode"
            applicationId  "com.patient.app"
        }
    }
    

    After that create two sibling folder of main after switch project View to Project

    app -> src -> main       /// write all common classes here
    app -> src -> doctorApp  // doctor related classes here along with their resources
    app -> src -> patientApp // patient related classes here along with their resources
    

    create same package name and res folder under patientApp and doctorApp