How to implement pro version android app - android

So I am making this app . I wanna have an app for free and a paid version too. I tried searching on google on how to implement it, but I couldnt find any proper threads. From some research I see In-app purchases is an option , but I'm not entirely clear. Can someone explain to me how this can be done? Thanks

You have to use flavors to achieve what you want. You need to have two different application id for each version. It will create *.apk with different id for free and paid version and therefore you will be able to upload two separate apps on Google Play.
android {
productFlavors {
free {
applicationId "com.myapp.free"
}
paid {
applicationId "com.myapp.paid"
}
}
}
Free version is build with:
gradlew assembleFreeRelease
Paid version is build with:
gradlew assemblePaidRelease
Your actual package can be different than application id:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.myapp">
</manifest>
In code you can check what flavor is used:
if (BuildConfig.FLAVOR.equals("free")) {
//do sth only for free version
}

Related

free and paid app signed one keystore

I was sign 2 apps (free and paid) with one keystore but with different aliases and have the same versionName of free and paid app its 1.0 ofc. So, people who buy paid app cant install this paid app because they have free app on device. When they delete free app - instalation is good. The names of applications are different! Please help me understand what wrong? Thanks
An app is identified as 'unique' only by it's application ID.
They can use the same keystore alias, name etc. but as long as the application id is different they are different apps and can be installed next to each other.
A good approach would be to add a suffix to the free version such as 'lite'.
Assuming you have one app project with a 'free' and 'paid' flavour you could configure your build.gradle to use a different application id per flavour:
defaultConfig {
applicationId "com.example.awesomeapp"
}
productFlavors {
free {
applicationIdSuffix ".lite"
}
paid {
}
}
Please see the documentation on Application ID

Add Flavors to the new version of published App

Is it possible to add Flavors to the new version of an already published App?
If yes, suppose the following senario:
I have a published app in Play Store (e.g. com.example.android). In the new version of the app I add (e.g. free and paid) Flavors. This addition changes the package name of the app to com.example.android.free and com.example.android.paid.
Suppose I publish only the com.example.android.free Flavor.
What will the link to the Play store be like?
https://play.google.com/store/apps/details?id=com.android.example (as it already was)
or it will be renamed to
https://play.google.com/store/apps/details?id=com.android.example.free
Just to be clear on the answer by marmor:
You CAN create flavours after you have a published application. But if you wish to keep the app published and updatable on Play Store that same app MUST have the original package name which means that it has to be one of the flavours created AND its package name left untouched.
As an example, imagine that you have one published app and then you decide that you want a FREE and a PRO version of it. You change your build.gradle file to have two flavours:
defaultConfig {
applicationId "com.mycompany.awesomeapp"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
flavorDimensions "feature"
productFlavors {
free{
}
pro{
applicationIdSuffix ".pro"
}
}
Now what this means is that the original app in the store is now the FREE product flavour and you can sign it and update it to the Play Store. You can even change its name. What matters is that its package name remains the same, in this case
com.mycompany.awesomeapp
which is the default defined and that uniquely identifies your app.
The PRO version is a different app now that you can publish and update as a new app. Its package name is now
com.mycompany.awesomeapp.pro
Meaning it is a new, different app, even though it shares some code base.
You can't change the package name of an already published app, you can however have two flavors free/paid, but one of them should have the original package name:
e.g.
free = com.example.android
paid = com.example.android.paid
which will mean the free app would update the currently existing one, and the paid app will be a new app on Google Play (with zero statistics and downloads).
the links to the 2 apps would be as expected:
https://play.google.com/store/apps/details?id=com.android.example
and
https://play.google.com/store/apps/details?id=com.android.example.paid
If you want to enjoy the best of both worlds, look into [in-app-billing][1] to allow your users to download the app for free, and pay within the app to unlock premium features.

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

Android application with two packages

I do an application in two versions: premium and free. Now for me the functional of premium version works after verification of:
if (isPremiumVersion){
//to do premium fuctions
}.
But I do not think that it is good tone. How is it possible to divide these two versions, that they were independent of each other? Only at the start of application to do verification, and then already, for example, to start the certain manifest file with a certain package, and classes. Unfortunately, does not turn out to find material, how more correct to do it.
What you need is Product flavors.
You can define them in build.gradle:
android {
....
productFlavors {
free {
applicationId 'com.myapp.free'
}
premium {
applicationId 'com.myapp.premium'
}
}
}
For each product flavor you can create it's own source set by creating directory with name of flavor in app src directory so your app structure will be like:
src/
main/
free/
premium/
You can add customized AndroidManifest.xml, resources and sources in flavor source sets and they will be merged with main source set.
You should carefully read official documentation at link I mentioned above. There much more possibilities and details then I described here.

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