I'm trying to implement play services and huawei services in the same app, but want to be able to configure which one to use by flavor. Each flavor uses it's own applicationIdSuffix. So for each different flavor, huawei plugin fails and I cannot compile.
I have app module that contains agconnect-services.json file in it's root. How could I specify different versions of this file for each build flavor?
If it's not possible, then in my root build.gradle file I have this line:
classpath 'com.huawei.agconnect:agcp:1.1.1.300'
Is it possible to use this line only on specific flavor?
Build variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Although you do not configure build variants directly, you do configure the build types and product flavors that form them.
void missingDimensionStrategy ( String dimension, String requestedValue) Specifies a flavor that the plugin should try to use from a given dimension in a dependency. Android plugin 3.0. 0 and higher try to match each variant of your module with the same one from its dependencies.
Build types define certain properties that Gradle uses when building and packaging your app, and are typically configured for different stages of your development lifecycle.
NOTE: By default, the Android Studio will generate "debug" and "release" Build Types for your project. So, to change a Build Type, all you need to do is just select your Build Type from the Build Variant and after the project sync, you are good to go.
This library is an enterprise entity and different clients have different requirements with respect to minSdkVersion, targetSdkVersion, support library versions and other internal dependencies. Using product flavors on a regular applications is easy. Just add the productFlavors block and you are good to go.
If you want to have flavor specific files, you will have to omit the file from main, and add it to each flavors source directory directly.
As you can see, just by defining the flavorDimensions and dimension attribute, the product flavors can be grouped, and Android creates variants that are all possible combinations of flavors of all types of dimensions and build types. These variants are reflected everywhere, including the build variants tab on lower left side of android studio.
To build and run (or debug) any of the multiple flavors, Click the Build Variants tab, or select Build – Select Build Variant, and select the desired variant. While building multiple flavors, you might come across a situation where each flavor will require its own specific code file.
The possible cause is that your AppGallery Connect plug-in version is not the latest one. Please upgrade it by referring to HUAWEI AppGallery Connect Guide. To support multiple channels, you need to add the agconnect-services.json file to the folder of only the Huawei channel and ensure that the AppGallery Connect plug-in version in the project is 1.2.1.301 or later (classpath'com.huawei.agconnect:agcp:1.2.1.301'). If the plug-in version is earlier than 1.2.1.301, upgrade it to 1.2.1.301 or later. To obtain the latest AppGallery Connect plug-in version, please refer to Configuring Address Information for the AppGallery Connect SDK.
The configuration procedure is as follows: If your app needs to support multiple build types or flavors, configure the agconnect-services.json configuration file downloaded from AppGallery Connect for your app to implement the function. The agconnect-services.json file provides configuration information required by various services in your AppGalleryConnect project. Therefore, if you need to use multiple flavors to release different app versions, copy the agconnect-services.json file to the folder of each flavor and configure it. To support multiple build types, such as release, debug, rest, and mirror for your app, set buildTypes in the build.gradle file in the app directory. You also need to copy the agconnect-services.json file to the folder of each build type. If your project needs to support different app packages for different channels, the package name needs to vary depending on the channel. Change the package name in productFlavor in the build.gradle file under the app directory.
The possible cause is that your AppGallery Connect plug-in version is not the latest one. Please upgrade it by referring to HUAWEI AppGallery Connect Guide. To support multiple channels, you need to add the agconnect-services.json file to the folder of only the Huawei channel and ensure that the AppGallery Connect plug-in version in the project is 1.2.1.301 or later (classpath'com.huawei.agconnect:agcp:1.2.1.301'). If the plug-in version is earlier than 1.2.1.301, upgrade it to 1.2.1.301 or later. To obtain the latest AppGallery Connect plug-in version, please refer to Configuring Address Information for the AppGallery Connect SDK.
The configuration procedure is as follows: If your app needs to support multiple build types or flavors, configure the agconnect-services.json configuration file downloaded from AppGallery Connect for your app to implement the function. The agconnect-services.json file provides configuration information required by various services in your AppGalleryConnect project. Therefore, if you need to use multiple flavors to release different app versions, copy the agconnect-services.json file to the folder of each flavor and configure it. To support multiple build types, such as release, debug, rest, and mirror for your app, set buildTypes in the build.gradle file in the app directory. You also need to copy the agconnect-services.json file to the folder of each build type. If your project needs to support different app packages for different channels, the package name needs to vary depending on the channel. Change the package name in productFlavor in the build.gradle file under the app directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With