-1

I have created an application just like Careem or Uber. I have very little knowledge of Android development at the start of building this app. I created only one application but later I know that I have to develop two separate application. Then I copy one application as original and developed two applications separately.

These two applications working perfectly on multiple devices according to requirement but the issue is that I am not able to install both application simultaneously on the device. What is the solution for this problem?

halfer
  • 19,824
  • 17
  • 99
  • 186
Waqas Ahmed
  • 3
  • 1
  • 8
  • You can't. Each app must have it's own unique package. If you want to install both apps in one device then change package name of one of the app – m3g4tr0n Mar 19 '20 at 11:10
  • If I change applicationId in build.gradle file? – Waqas Ahmed Mar 19 '20 at 11:19
  • Yes, Use this guide to change package name https://stackoverflow.com/questions/16804093/rename-package-in-android-studio – m3g4tr0n Mar 19 '20 at 11:21
  • If you are using services like `Firebase` you will have change library specific files too ex `Google-service.json` in case of `Firebase` – m3g4tr0n Mar 19 '20 at 11:22
  • That is the problem I am getting now. Because I want to add both these application to firebase for push notification. Both these application have same package. Now kindly guide me what can I do – Waqas Ahmed Mar 19 '20 at 11:27
  • Open Firebase Console -> Project Settings -> General -> Your Apps -> Add your other app here and update new `google-services.json` in your android project – m3g4tr0n Mar 19 '20 at 11:30
  • Kindly provide me step by step detail to change package name of one of the app as suggested in your first comment – Waqas Ahmed Mar 19 '20 at 11:32
  • Go through the link I provided earlier https://stackoverflow.com/questions/16804093/rename-package-in-android-studio – m3g4tr0n Mar 19 '20 at 11:34
  • Got It. Done!!! – Waqas Ahmed Mar 19 '20 at 11:46
  • You could have done it with something called flavours of android https://developer.android.com/studio/build/build-variants – quealegriamasalegre Mar 22 '20 at 03:18

1 Answers1

2

In your build.gradle you can set your applicationId. Choose a different applicationId for each app and you can install both on the same phone.

android {
    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    ...
}

see https://developer.android.com/studio/build/application-id

HarmenH
  • 171
  • 8
  • Got it. I am confusing app id with package name – Waqas Ahmed Mar 19 '20 at 11:18
  • I am trying to add these application in Firebase Console, as these application have same package name. What can I do now? – Waqas Ahmed Mar 19 '20 at 11:28
  • you can't do any thing firebase not allowed to those app who have same package name your to change the package name for other – Amit pandey Mar 19 '20 at 11:37
  • Change you applicationId in your build.gradle file. then go to your firebase console (https://console.firebase.google.com) then go to your existing project. And create a new app by clicking "+ Add app" fill in you new packagename (applicationId) -> download google-services.json and add this to your android project with the updated packageName (applicationId). That should be it. – HarmenH Mar 19 '20 at 11:41
  • You do not need to change your projects package structure. – HarmenH Mar 19 '20 at 11:42