how to run same android app with different name in one device? - android

I build a two apk from same source code . both have Different name,icon background .i changed only UI and app name tow app have same package,
my problem is I can't install this both app on same device .when I try to install facing error message .
How I can run this two application (build from same source just change name and icon) on same device .? what are the values I should change in application to run this app separately .?
Kindly Give me a hand with this

You need to change package name to make Android System detect your 2nd app as different from first. App name doesn't matter.

Use productFlavors in your build.gradle file.
android {
productFlavors {
dev {
applicationId "com.company.app.dev" // package name for dev flavor
}
beta {
applicationId "com.company.app.beta" // package name for beta
}
production {
applicationId "com.company.app" // package name for production
}
}
}
All your files can still be in your src/main dir. Flavor specific changes can be placed in src/beta etc.

you just have to change the name and the package name of your second instance of the application.

Related

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.

Android how to manage project name and logo and application icon for different clients

As per need i need to manage one project for different clients in which i usually need to change application icon, app name and client logo. what is the efficient way to handle this??
I have read about properties file in the Android but that does provide option to change application icon and name.. it there any why to handle this.
To achieve this you will to have use flavour in your project, if you are using Android studio add the following code in your build.gradle file.
productFlavors {
flavor1 {
applicationId "com.app.client1"
}
flavor2 {
applicationId "com.app.client2"
}
}
Then create directory structure like
flavor1>res>drawable-XXX>ic_launcher.png (app icon for client1)
flavor2>res>drawable-XXX>ic_launcher.png (app icon for client2)
For more you can refer to this blog http://www.pcsalt.com/android/product-flavors-android/
You can create Multiple flavor for multiple vendors like this:
Here is a syntax for gradle
productFlavors {
flavor1 {
packageName 'com.android.studio.test.foobar'
}
}
You can also put variable to make changes in app according to flavor

How to load same android app to device with different name

Our company has developed a android app for our customer. I want to create a new app with different name with same source code. I have already changed the app name. But when ever I load this new app to my device from android studio it gives error saying "alredy a new version of app is running in your device".
I want to release the same app with different name to the app store.
If you use android studio, use flavors to compile your app using different packages and different names
Have a look on this website : http://tools.android.com/tech-docs/new-build-system/build-system-concepts
change package name of application in manifest also change app name.
An addition to the other answers here is an example for how to do this:
android {
defaultConfig {
// your config
applicationId "com.packagename.appname"
}
productFlavors {
release {
// you config
applicationIdSuffix "release"
}
debug {
// you config
applicationIdSuffix "debug"
}
}
}
for more, feel free to read this manual

(Cordova/Phonegap) Android splash screen not being shown using Android Studio builds

I have the following product flavors in module's build.gradle
productFlavors {
pro {
applicationId "com.icounttimer.android"
}
free {
applicationId "com.icounttimer.android.free"
}
}
The package structure of my app module is:
src/main/java/com/icounttimer/android/MainActivity.java
Building pro-debug.apk shows the splashscreen correctly. However, free-debug.apk does not show the splashscreen.
Changing the applicationId of 'free' flavor to 'com.icounttimer.android' resolves the issue. But when using a different applicationId, the splash screen won't be shown.
Environment:
CordovaLib: v3.6.3
Android Studio 1.0 RC4
What is the reason for this behaviour and how to resolve this issue?
The reason which I found is as follows:
Changing applicationId via build.gradle, changes the app's package name.
Note that it is different from the package structure of the app which remains unaltered during different build variants.
The app package structure, in this case, is unaltered: src/main/java/com/icounttimer/android/MainActivity.java
Diving through the code, I found out that the showSplashScreen() methods in CordovaActivity.java (part of CordovaLib) get the resources as follows:
this.splashscreen = getResources().getIdentifier(splash, "drawable", getClass().getPackage().getName());
The third arguments for getIdentifier(...) method is the package name of app.
getClass().getPackage().getName()
gets the pkgName based on package structure which always returns 'com.icounttimer.android' no matter which build variant it is.
To fix this, replace both of its occurences in CordovaActivity.java with:
this.getPackageName() //returns the name of the application pkg which is the applicationId

Android : Install different flavors with same package names

I developed an android app with 3 different flavors (production,testing, training). Almost 99% of the source codes are identical. Only a single file in assert folder with server urls are different for each flavor. The flavors work perfectly. But i would like the app to install all 3 apps in the device without overwriting each other. Since the package name of the project is the same for all the flavors, it's overwriting the app when i install difference flavors.
Any ideas or suggestions ? Thanks in advance.
Anyway just by changing the package name in the build.gradle it works.
productFlavors {
production {
applicationId = "<your-package-surfix>.production"
}
testing {
applicationId = "<your-package-surfix>.testing"
}
training {
applicationId = "<your-package-surfix>.training"
}
}
In AndroidManifest.xml use full package name when define a activity/service/receiver.

Categories

Resources