What best way to have same two app with different names - android

I have app on git with package for example com.foo.
Now I want to create clone of this app with different name.
In order to do it I fork my app and change the name. But this app has the same package.
And I can't install the second app because they have same package name.
What would be the best way to support two apps with same functions but different names?

Create different productFlavors for another app in same code
productFlavors {
VersionFirst {
applicationId "packagename"
versionName "1.0"
}
VersionSecond {
applicationId "packagename"
versionName "1.0"
}
}
generate different build using build varient

If two applications have the same package name, only one of them will be installed. If they share the same signature, installing the second package will overwrite the first assuming it doesn't downgrade the version. If they have different signatures, you'll get an error saying that you can't install the second package.
Read this :https://developer.android.com/guide/topics/manifest/manifest-element.html

Related

User flow for providing multiple versions (environments) of mobile app to end users

We are trying to provide multiple environments to our end users and want to create one single bundle for both IOS and Android. Currently we have a hidden feature (clicking on the version number to open an environment selection screen: Dev, QA, UAT or Prod). However, I am wondering if there are better or recommended ways of achieving this same effect somehow.
Thanks!
I can help you with Android on managing Environments using Gradle file.
Let's say you have a app with package name - com.company.sampleapp
In gradle your applicationId will be com.company.sampleapp
Now we can create different flavors for different environment and we can also have different applicationId as shown below.
android {
flavorDimensions "default"
productFlavors {
production {
dimension "default"
applicationId 'com.allegion.leopard'
}
//App will have package name appended with .qa
qa {
dimension "default"
applicationId 'com.allegion.leopard.qa'
}
//App will have package name appended with .dev
dev {
dimension "default"
applicationId 'com.allegion.leopard.dev'
}
}
}
Once this is done, you can choose build variants and create APK for that build. Added image for clarity
Hope this helps.

Not working with package name and firebase

I have an app uploaded to the play store. The package is: com.pathapp but then with gradle are generated two apk, com.path debug and release (without app). Now I want to integrate firebase, but I do not know what name of the app is what I have to put in firebase, if com.path or com.pathapp in order to have a well constructed google-services.json file.
If I change the original package of the directories from pathapp to path, there would be a problem?
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.00"
}
}
applicationId in the gradle is your package name.
So you need to add that in the firebase console.
In the above example, the package name is com.example. Likewise, check your gradle.
If you go to the Play Store you can see the package name of your current app. Use this, or you won't be able to upload in the store.
To see the package name is linked with your Firebase, open your project in Firebase and click on Settings, here you will see the package name of the app.
If is not the same:
-There, you can see an option to add a new app. Click the button and add a new app with your new package: com.pathapp
-Finally, you have to download the new google-services.json and add it in your project, deleting the old one if you still have it.

Does same package name APK(with different applicationId) use same data location?

we know APK save data in /data/data/PackageName,if two different apk with same package name,will they cover other's data?(like sharepreference's data)
The Answer is No, Why? This is not possible, Play store will not let you to upload an apk with the same package,Package name at play store is important for many reasons, one of them is update detection, if you updated an application the first thing Google pay attention is the package name in order to know what is the current release version.
Somehow it will be happened by same developer at the DEVELOPMENT stage only then you can name your package whatever do you want.
As far as same package name is concerned it's not possible to have installed on same device it will be replaced.
But if we have different appliationId, yes another app can be installed on same device but in that case packageName will also be change.
Working Sample
Project 1
app/build.gradle
applicationId "com.test.sample"
Android Manifest
package="com.test.sample"
Result
When i print applicationId and package name, it was same:
applicationId: "com.test.sample"
package: "com.test.sample"
Project 2
I've added buildTypes/flavor but keeping applicationId and package name same, but in that case outpout of applicationId and package name will be changed.
build.gradle(app)
applicationId "com.test.sample"
buildTypes {
release {
applicationIdSuffix ".release"
}
debug {
applicationIdSuffix ".debug"
}
}
Android Manifest
package="com.test.sample"
Result
When i print applicationId and package name, it was different:
applicationId: "com.test.sample.debug"
package: "com.test.sample.debug"
So that is how two applications are installed due to change in buildType/flavors(pro/free).
And if you want to access sharedPreferences of each-other (assume free/pro version) than you need to create a ContentProvider to expose data you need and grant permissions to paid app.

Create separate apk for separate flavor in android to run on same device

I have already asked similar question But could not find what i seek . Hence asking again .
I want to run separate flavor apk on same device simultaneously.
I have used build.gradle(app) to create different flavors of apk. But installing different flavors of same apk overrides the previous one. I want to create different apks to run on same device simultaneously. I want to create different apk with different appicon which can be installed on same device and run simultaneously. Any link or tutorial or direct help is appreciated.
My build.gradle is as below
productFlavors {
production {
applicationId
"com.abc.def"
buildConfigField 'String', 'HOST', '"http://example.com/api/"'
}
staging {
applicationId
"staging.com.abc.def"
buildConfigField 'String', 'HOST', '"http://example.com/api/"'
}
backendtesting {
applicationId
"backendtesting.com.abc.def"
buildConfigField 'String', 'HOST', '"http://example.com/api/"'
}
}
Do not put line breaks between the gradle command and it's argument. It will read each line separately since line breaks are command separators for gradle.(like how ; is for java)
For example, use:
applicationId "com.abc.def"
instead of
applicationId
"com.abc.def"
This post explains step by step how to configure your directory structure and gradle file.
The main steps are:
add the product flavours container to the app build.gradle file
productFlavors {
free {
applicationId "antoniocappiello.com.buildvariantsexample.free"
}
paid {
applicationId "antoniocappiello.com.buildvariantsexample.paid"
}
}
create inside src a directory with the exact name of the product flavour that you want to look different from the main variant, for example with the configuration at step 1 the directory name could be paid or free . And inside that directory create the subfolder res/drawable where you are going to place your new app launcher icon.
Directory structure example
You can set different applicationId for different flavors. In this way different flavors will be treated as different applications and will not overwrite each other when you install them on same device.
As an example, following snippet will create two flavors, prod and dev with different app packages. You can install them both together on the device.
productFlavors {
dev {
applicationId "com.swagata.devbuild"
}
prod {
applicationId "com.swagata.prodbuild"
}
}

Android Studio. Organizing project for Google Play: Same application, different assets

I developed a "template" application that I want to distribute on Google Play using different names and assets depending on the specific domain I'm targeting the app for (general, "domain1", "domain2", ...).
I have read in other posts that the first thing to do is to change the package name for each new application (in fact Google Play uses it as index, so it can NOT be repeated).
The easy solution I see is to create a new project and change the package name and assets, but this is quite "bloated". I'm wondering whether it's possible somehow to use a single AndroidStudio project to generate the "template application" and the "domain specific" ones.
You can Define product flavors in the build file like general , domain1 ,domai2, .....
...
android {
...
defaultConfig { ... }
signingConfigs { ... }
buildTypes { ... }
productFlavors {
general {
applicationId "com.buildsystemexample.app.general"
versionName "1.0-demo-general"
}
domain1 {
applicationId "com.buildsystemexample.app.domain1"
versionName "1.0-full-domain1"
}
...
...
}
}
...
As you see, all flavours will have different applicationId.
And moreover , you can have different resources or src or assets for your flavors as you want.
All you have to do is build the flavor you want from android studio.
Read more here. https://developer.android.com/tools/building/configuring-gradle.html

Categories

Resources