Thursday, April 22, 2021

Android practical challenges when adding product flavours

initially did not specify the flavorDimensions property and got the below error 


Error:All flavors must now belong to a named flavor dimension.

  The flavor 'flavor_name' is not assigned to a flavor dimension.


reading more here, 

https://developer.android.com/studio/build/build-variants


it appears that the product flavors support the same properties as defaultConfig—this is because defaultConfig actually belongs to the ProductFlavor class. This means you can provide the base configuration for all flavors in the defaultConfig block, and each flavor can change any of these default values, such as the applicationId.


After you create and configure your product flavors, click Sync Now in the notification bar. After the sync completes, Gradle automatically creates build variants based on your build types and product flavors,



After adding the below configuration to the build.gradle file, started getting the below errors 

No matching client found for package name 'com.kungfugrip.touchless.dev'


flavorDimensions "version"

    productFlavors {

        devBuild {

            applicationId 'com.kungfugrip.touchless'

            resValue "string", "override_name", "Touchless Dev"

            dimension 'version'

            applicationIdSuffix 'dev'

        }

        prodBuild {

            applicationId "com.kungfugrip.touchless"

            resValue "string", "override_name", "Touchless"

            dimension 'version'

        }

    }


And from the stack overflow link it appeared that this error is due to the application Id being not present in the google-services.json file. 


Now added a new application in firebase and gave the bundle ID as com.kungfugrip.touchlessdev. the google service json was replaced however, the app was not built still. it gave the same error message. 


This was not a major concern because the issue was the google-services.json had to be replaced under app root rather than project root!


references:

https://stackoverflow.com/questions/34990479/no-matching-client-found-for-package-name-google-analytics-multiple-productf

https://developer.android.com/studio/build/build-variants

No comments:

Post a Comment