Gradle productFlavors different applicationId with GooglePlusApi - android

I added google plus login in my android app.
I want to create apk three different applicationId with productFlavors in gradle.
When i create apk diffrent applicationId, google plus login does not work.
I tried new client id in developer console with new applicationId, but console wants packagename in AndroidManifest.xml
How can i login google plus with different applicationId in my app.
Thanks,
//gradle
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 18
targetSdkVersion 21
}
productFlavors {
development {
applicationId "com.msevgi.myapp.development"
versionCode 46
versionName "1"
flavorDimension "type"
}
beta {
applicationId "com.msevgi.myapp"
versionCode 46
versionName "1"
flavorDimension "type"
}
internal {
applicationId "com.msevgi.myapp.internal"
versionCode 46
versionName "1"
flavorDimension "type"
}
}
buildTypes {
release {
zipAlignEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-android-optimize.txt'
debuggable false
}
debug {
zipAlignEnabled true
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-android-optimize.txt'
}
}
//AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.msevgi.myapp">

According to this:
"that matches a package name and SHA1 signing-certificate fingerprint"
I think you should:
Specify a package name ("applicationId" in build.gradle) for per flavor/type (as you have done).
Get the "SHA1 signing-certificate fingerprint" by running the "keytool" for each "keystore" you use to sign the APK. This means the default "~/.android/debug.keystore" for your DEBUG build, or the "keystore" which is not in the "build.gradle" but specified by you when run "Generate Signed APK" in Android Studio or Eclipse.
Create a credential on the Google API console for each combination of #1 and #2.

I think you should generate an api key for each of your flavor. The package name will be the applicationId of the flavor in your gradle build file.

Related

The APK file or Android app bundle must be signed with a certificate for now

You've uploaded an APK file or Android App Bundle, one of which is signed with an invalid certificate yet. The APK file or Android App Bundle must be signed with a certificate that is currently valid. Learn more about signing files or packages
It's been two days and I've been trying to upload the app to Google Play but the message is still the same
I have removed and reinstalled Android Studio
I cleaned the project several times and rebuilt it
And changed the package name
I still get the same message
android {
compileSdkVersion 32
defaultConfig {
applicationId "com.chat.aarabicc"
minSdkVersion 29
targetSdkVersion 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

Changing only Application ID, not package name

I only want to change application id in gradle file, but dont want to change package name.
Is it possible?
It is not recommended to change your application id. What you can do is change your application suffix.
As an example, if your application id is com.example.my_app then add different suffixes for different build types, such as com.example.myapp.dev for debug.
Go to app/build.gradle file and on android block add the suffix you want:
buildTypes {
release {
applicationIdSuffix ".production"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".dev"
versionNameSuffix '-DEBUG'
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Read more about it here
No problem. You can change your application Id as long as your app is not on store. If you change your application id, It would immediately become a different app for google play.
I have many apps with different package name and application ids.
Yes you can change androidId in defaultConfig.
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.somepkg" // <- we can change applicationId in defaultConfig
minSdkVersion 21
targetSdkVersion 26
vectorDrawables.useSupportLibrary = true
....
}
}
Also we can change applicationId in flavors use suffix or override it:
flavorDimensions "app"
productFlavors {
qa {
dimension "app"
applicationIdSuffix = ".qa" // <- add suffix (it will be )
}
production {
applicationId = "com.someotherpkg" // <- we can change applicationId in flavors
dimension "app"
}
}
However your src files will be still in the same folders.

google play store - how to promote test app with different package name?

This is a question about package names in android. I currently have two build flavors in gradle. Production and Staging.
I have created a google play store account and i want users to alpha and beta test my app. The staging app currenly has a package name of:
com.mobile.myapp.staging while the production flavor has a package name of com.mobile.myapp.
so we have
com.mobile.myapp.staging vs com.mobile.myapp
in the end i clearly want to promote com.mobile.myapp to production not the staging. but i'd like the users to test with the staging variant for a long while (as its connected to staging apis . etc etc.)
How can i do this ? would i have to create two different apps in the google play store ? I am wondering if i have to do this as
they both have different package names. They both will be signed with the same keystore. Please help.
my gradle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion project.ext.minimumSdkVersion
//check top level build.gradle file for attributes -
targetSdkVersion 25
applicationId "com.mobile.myapp"
versionCode 150010203
versionName 1.2.3
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//renderscriptTargetApi 25
//renderscriptSupportModeEnabled true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "6g"
}//for out of memory gc overhead error
lintOptions {
abortOnError false
}
productFlavors {
def STRING = "String"
def BOOLEAN = "boolean"
def TRUE = "true"
def FALSE = "false"
def FLAVOR = "FLAVOR"
def RETROFIT_LOG_ALL = "RETROFIT_LOG_ALL"
def BASE_ENDPOINT = "BASE_ENDPOINT"
staging {
// applicationId "com.mobile.myapp.staging"
buildConfigField STRING, BASE_ENDPOINT, '"https://api.flyingSaucerxx-staging.com"'
buildConfigField BOOLEAN, RETROFIT_LOG_ALL, TRUE
manifestPlaceholders = [appDrawerName: "FlyingSaucer-Staging"]
applicationIdSuffix '.staging'
versionNameSuffix '-STAGING'
}
prod {
buildConfigField STRING, BASE_ENDPOINT, '"https://api.flyingSaucerxx.com"'
buildConfigField BOOLEAN, RETROFIT_LOG_ALL, FALSE
manifestPlaceholders = [appDrawerName: "FlyingSaucer"]
}
}
}
///.. dependencies below
It is not possible to use different package names in Google Play Store for the same app.
So the only option you have is to change package name of your staging app to production one. And submit it to alpha/beta testers. And sure watch out to not promote it to production.
Another option is to use other delivery channels like hockeyapp or crashlitics beta.

Getting gradle exception after updating to com.google.gms:google-services:3.0.0

Yesterday, I updated my google services gradle plugin to this:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}
After that, I am getting below error in my devDebug flavour build:
Error:org.gradle.api.GradleException: No matching client found for package name 'com.example.android.dev'
Here are the relevant part of my app level build.gradle file:
defaultConfig {
applicationId 'com.example.android'
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 24
versionCode 47
versionName "1.3.2"
signingConfig signingConfigs.myConfig
renderscriptTargetApi 24
renderscriptSupportModeEnabled true
}
buildTypes {
debug {
applicationIdSuffix = ".dev"
resValue "string", "app_name", "example-debug"
}
release {
minifyEnabled false
shrinkResources false
resValue "string", "app_name", "example"
signingConfig signingConfigs.myConfig
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 16
}
}
This error does not come in my prodRelease product flavour build. How can I resolve it?
In your debug build type you are using this package:
debug {
applicationIdSuffix = ".dev"
}
This message
No matching client found for package name 'com.example.android.dev'
means that your google-services.json doesn't contain this package.
Follow these steps:
Go to Firebase console
add another android app registering also this package
Export again the google-services.json
Re-register your key on console.developers
Finally fixed the issue.
The trick is to add another app to the Firebase console with the debug package name and debug SHA1 fingerprint.
Doing this essentially creates 2 apps but the google-services.json file downloaded from any app contains information about both apps.

Android gradle product flavors with wearable apps

I'm adding a wearable component to an existing app which uses product flavors in the gradle build to build multiple versions of the app.
I know the package names / application Id's need to match between the mobile and wearable builds, but do I just need to copy the
productFlavors
signingConfigs
buildTypes
from my main mobile app. I'm not quite sure if all of this is needed to get things working or not.
The productFlavors no, unless you are going to do something specific for the wear app with a particular flavor.
The signingConfigs and buildTypes you should copy, the wear app definitely needs to be signed as well. You may adapt the buildType for wear such is enable/disable minify it you want from the main app.
Here's a portion of my own mobile and wear build configs
Mobile
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.codechimp.qrwear"
minSdkVersion 18
targetSdkVersion 20
versionCode 26
versionName "1.20"
}
productFlavors {
prod {
}
dev {
versionName = android.defaultConfig.versionName + " dev"
}
}
signingConfigs { release }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
Wear
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.codechimp.qrwear"
minSdkVersion 20
targetSdkVersion 20
versionCode 26
versionName "1.20"
}
signingConfigs { release }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}

Categories

Resources