C Forge
C Forge

Reputation: 63

How to install two separate versions of an app from android studio?

I am working with the Firebase chat project from github. I am trying to make 2 apps, one client-side and one admin-side. I have two copies of the project with different project names and different app names. Still, I can't run both on the same device with android studio. Running one requires uninstalling the other. I understand it might be a pretty basic thing, but any suggestions? Thanks

Upvotes: 2

Views: 3185

Answers (2)

Grishma Ukani
Grishma Ukani

Reputation: 656

In your app level build.gradle file under android tag define different product flavors for different app. Please find the below code and do changes according to your project.

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    flavorDimensions "default"
    project.archivesBaseName = "Visualogyx";
    signingConfigs {
        release {
            storeFile file(System.getenv('KEYSTOREPATH'))
            storePassword System.getenv("VISUALOGYX_KEYSTORE_PASSWORD")
            keyAlias System.getenv("VISUALOGYX_KEYALIAS_NAME")
            keyPassword System.getenv("VISUALOGYX_KEYALIAS_PASSWORD")
        }
    }

    defaultConfig {
        applicationId "com.visualogyx.app"
        minSdkVersion 16
        targetSdkVersion 26
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        signingConfig signingConfigs.release

        ndk {
            abiFilters "armeabi-v7a"
        }
    }
    lintOptions {
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    dexOptions {
        javaMaxHeapSize "4g"
        jumboMode true
    }
    productFlavors {
        dev {
            versionCode 778899
            versionName "v.1.1.BUILD_NUM"
            applicationIdSuffix ".dev"
            resValue "string", "app_name", "VisualogyxDEV"
            buildConfigField "String", "HOST", System.getenv("VISUALOGYX_HOST_DEV") 
        }
        qa {
            versionCode 778899
            versionName "v.1.0.BUILD_NUM"
            applicationIdSuffix ".qa"
            resValue "string", "app_name", "VisualogyxQA"
            buildConfigField "String", "HOST", System.getenv("VISUALOGYX_HOST_QA") 
        }
        pro {
            versionCode 778899
            versionName "v.1.0.BUILD_NUM"
            resValue "string", "app_name", "Visualogyx"
            buildConfigField "String", "HOST", System.getenv("VISUALOGYX_HOST_PRO")
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            applicationVariants.all { variant ->
                variant.outputs.all {
                    outputFileName = "Visualogyx-${variant.baseName}-${variant.versionName}.apk"
                }
            }
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'META-INF/XXX'
    }
} 

Hope it works.Thanks.

Upvotes: 2

Wendy Liga
Wendy Liga

Reputation: 740

what you need to do is change package name on App Build.Gradle, find applicationId and change one of your project package name

hopefully it works

Upvotes: 3

Related Questions