Loading app/build.gradle +30 −0 Original line number Diff line number Diff line import java.util.regex.Matcher import java.util.regex.Pattern plugins { id 'com.android.application' id 'kotlin-android' Loading Loading @@ -136,3 +139,30 @@ dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' } def getCurrentFlavor() { Gradle gradle = getGradle() String tskReqStr = gradle.getStartParameter().getTaskRequests().toString() println("tskReqStr:" +tskReqStr) Pattern pattern if( tskReqStr.contains( "assemble" ) ) // to run ./gradlew assembleRelease to build APK pattern = Pattern.compile("assemble(\\w+)(Release|Debug)") else if( tskReqStr.contains( "bundle" ) ) // to run ./gradlew bundleRelease to build .aab pattern = Pattern.compile("assemble(\\w+)(Release|Debug)") else pattern = Pattern.compile("generate(\\w+)(Release|Debug)") Matcher matcher = pattern.matcher( tskReqStr ) println(tskReqStr) if( matcher.find() ) return matcher.group(1).toLowerCase() else { println "NO MATCH FOUND" return "" } } println("Flavor: ${getCurrentFlavor()}") if ( getCurrentFlavor() == "playstore" ){ apply plugin: 'com.google.gms.google-services' } No newline at end of file app/src/debug/playstore/google-services.json 0 → 100644 +68 −0 Original line number Diff line number Diff line { "project_info": { "project_number": "479837431022", "project_id": "pc-api-4835782490875392372-140", "storage_bucket": "pc-api-4835782490875392372-140.appspot.com" }, "client": [ { "client_info": { "mobilesdk_app_id": "1:479837431022:android:1102a97a55202beb547fff", "android_client_info": { "package_name": "app.fedilab.android" } }, "oauth_client": [ { "client_id": "479837431022-mettpakdcso72c35djvikfc57l4i7n53.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { "current_key": "AIzaSyCklTEEgLUxy__0Vzcr5_H179kYPXGjmGo" } ], "services": { "appinvite_service": { "other_platform_oauth_client": [ { "client_id": "479837431022-mettpakdcso72c35djvikfc57l4i7n53.apps.googleusercontent.com", "client_type": 3 } ] } } }, { "client_info": { "mobilesdk_app_id": "1:479837431022:android:529536f519b8f4ce547fff", "android_client_info": { "package_name": "app.fedilab.android.debug" } }, "oauth_client": [ { "client_id": "479837431022-mettpakdcso72c35djvikfc57l4i7n53.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { "current_key": "AIzaSyCklTEEgLUxy__0Vzcr5_H179kYPXGjmGo" } ], "services": { "appinvite_service": { "other_platform_oauth_client": [ { "client_id": "479837431022-mettpakdcso72c35djvikfc57l4i7n53.apps.googleusercontent.com", "client_type": 3 } ] } } } ], "configuration_version": "1" } No newline at end of file build.gradle +2 −1 Original line number Diff line number Diff line Loading @@ -3,12 +3,13 @@ buildscript { repositories { mavenCentral() google() } dependencies { classpath 'com.android.tools.build:gradle:7.0.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.1" classpath 'com.google.gms:google-services:4.3.8' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } Loading Loading
app/build.gradle +30 −0 Original line number Diff line number Diff line import java.util.regex.Matcher import java.util.regex.Pattern plugins { id 'com.android.application' id 'kotlin-android' Loading Loading @@ -136,3 +139,30 @@ dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' } def getCurrentFlavor() { Gradle gradle = getGradle() String tskReqStr = gradle.getStartParameter().getTaskRequests().toString() println("tskReqStr:" +tskReqStr) Pattern pattern if( tskReqStr.contains( "assemble" ) ) // to run ./gradlew assembleRelease to build APK pattern = Pattern.compile("assemble(\\w+)(Release|Debug)") else if( tskReqStr.contains( "bundle" ) ) // to run ./gradlew bundleRelease to build .aab pattern = Pattern.compile("assemble(\\w+)(Release|Debug)") else pattern = Pattern.compile("generate(\\w+)(Release|Debug)") Matcher matcher = pattern.matcher( tskReqStr ) println(tskReqStr) if( matcher.find() ) return matcher.group(1).toLowerCase() else { println "NO MATCH FOUND" return "" } } println("Flavor: ${getCurrentFlavor()}") if ( getCurrentFlavor() == "playstore" ){ apply plugin: 'com.google.gms.google-services' } No newline at end of file
app/src/debug/playstore/google-services.json 0 → 100644 +68 −0 Original line number Diff line number Diff line { "project_info": { "project_number": "479837431022", "project_id": "pc-api-4835782490875392372-140", "storage_bucket": "pc-api-4835782490875392372-140.appspot.com" }, "client": [ { "client_info": { "mobilesdk_app_id": "1:479837431022:android:1102a97a55202beb547fff", "android_client_info": { "package_name": "app.fedilab.android" } }, "oauth_client": [ { "client_id": "479837431022-mettpakdcso72c35djvikfc57l4i7n53.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { "current_key": "AIzaSyCklTEEgLUxy__0Vzcr5_H179kYPXGjmGo" } ], "services": { "appinvite_service": { "other_platform_oauth_client": [ { "client_id": "479837431022-mettpakdcso72c35djvikfc57l4i7n53.apps.googleusercontent.com", "client_type": 3 } ] } } }, { "client_info": { "mobilesdk_app_id": "1:479837431022:android:529536f519b8f4ce547fff", "android_client_info": { "package_name": "app.fedilab.android.debug" } }, "oauth_client": [ { "client_id": "479837431022-mettpakdcso72c35djvikfc57l4i7n53.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { "current_key": "AIzaSyCklTEEgLUxy__0Vzcr5_H179kYPXGjmGo" } ], "services": { "appinvite_service": { "other_platform_oauth_client": [ { "client_id": "479837431022-mettpakdcso72c35djvikfc57l4i7n53.apps.googleusercontent.com", "client_type": 3 } ] } } } ], "configuration_version": "1" } No newline at end of file
build.gradle +2 −1 Original line number Diff line number Diff line Loading @@ -3,12 +3,13 @@ buildscript { repositories { mavenCentral() google() } dependencies { classpath 'com.android.tools.build:gradle:7.0.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.1" classpath 'com.google.gms:google-services:4.3.8' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } Loading