I have an android sdk which requires the app using it to have google-services.json file in its project directory.
I am wondering what will happen if the app already has a google-services.jsonfile from its implementation and is receiving FCMs from its own google developers console.
Can an app have multiple google-services.json file for the same flavor.
Can an app receive FCM's from two different google developers console account? or How can an app receive FCM's from two different google developers console?
I am just trying to explore ways as to how I can send FCM from my server to the app without making the app change its underlying design.
Downvoting must be accompanied with reason.
If you have multiple flavors configured in your app is intende to say that you will create multiple apps with different package name, for example:
flavorDimensions "mysite"
productFlavors {
elnorte {
applicationId 'com.jorgesys.creatorhdplayer'
manifestPlaceholders = [appName: "Creator hd player"]
dimension "mysite"
}
reforma {
applicationId 'com.jorgesys.creatorhdfree'
manifestPlaceholders = [appName: "Creator hd free"]
dimension "mysite"
}
mural {
applicationId 'com.jorgesys.creatorhd'
manifestPlaceholders = [appName: "Creator hd"]
dimension "mysite"
}
}
therefore you need to add diferent google-services.json files in your proyect for every application that needs google play services :
The google-services.json file is related to the package name so you just need one file for every application. The same if you have only one flavor configured (one application)
Related
Following is my app package name
com.test.myapp
and I have created 2 product flavors, 1 for development & 1 for production like following.
productFlavors {
dev {
applicationId = "com.test.myapp.dev"
}
production {
applicationId = "com.test.myapp"
}
}
It works fine, when i launch app from android studio, it also creates signed apk fine, but when i try to upload development apk on play store, it gives following error message.
Your APK or Android App Bundle needs to have the package name
com.test.myapp.
Technically it is not possible, Google not allows this, you need to create 2 apps on Google play for this. But why you need flavor for development with different package name? does Google's Alpha testing not solve your problems?
Edit:
Based on comments the issue was how to load different strings.xml based on build config without creating new package name.
Solution:
flavorDimensions "dev"
productFlavors {
dev {
flavorDimensions "dev"
}
prod {
flavorDimensions "dev"
}
}
Create new strings.xml resource in dev source set
\src\dev\res\values\strings.xml
I have uploaded demo project:
https://github.com/pavelpoley/FlavorTest
More info you can find in docs:
https://developer.android.com/studio/build/build-variants#sourcesets
I am setting up Firebase for my Android application and have run into a slight wrinkle/problem. I have multiple product flavors such as the standard dev, qa and prod. These product flavors share the same application id. However, I have one flavor where the application id is different:
productFlavors {
dev {
applicationId "com.acme.myandroidapp"
}
qa {
applicationId "com.acme.myandroidapp"
}
foo {
applicationId "com.acme.foo"
}
prod {
applicationId "com.acme.myandroidapp"
}
This is causing my gradle build to fail with a "No matching client found for package name 'com.acme.foo'" error.
I have looked at both: No matching client found for package name (Google Analytics) - multiple productFlavors & buildTypes and google-services.json for different productFlavors
Unfortunately, neither question deals with the wrinkle of having a different application id for a particular product flavor. I did try putting a copy of the google-services.json file at the base of each flavor but there was no joy.
Thoughts on how do you support different applicationIds with Google Services under Android?
You can Add app for both the application Ids in Project setting in Firebase Console.
By doing so the new google-services.json file will contain two client-info, 1 for each application ID.
Putting a copy of the google-services.json file at at the base of each flavor should solve the issue.
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.
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
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