Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using multi-flavor to compile GMS and HMS packages. But an error is reported when the GMS version is compiled

I have an app that has two compilation flavors configured, one that uses HMS and the other that does not. During the compilation of flavors that do not use the HMS, the package name is inconsistent with that in the JSON file. As a result, an error occurs.

Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processAppgalleryconnectLatestDebugAGCPlugin'.
> ERROR: Failed to verify AGConnect-Config '/client/package_name', expected: 'com.dise.appge.hms', but was: 'com.dise.appge.gms'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

So how to solve this problem when different flavors use different package names?

like image 709
ooWYXNoo Avatar asked Aug 25 '21 09:08

ooWYXNoo


2 Answers

You can configure it in build.gradle of the application. For example, if two flavors, HMS and GMS, you can try to add the following code:

if (getGradle().getStartParameter().getTaskNames().toString().contains("HMS")) {
    apply plugin: 'com.huawei.agconnect'
}

That is, the AGC plug-in is not added during GMS compilation to avoid the problem of inconsistent package names in the JSON file.

like image 62
shirley Avatar answered Sep 27 '22 16:09

shirley


Respective plugins can be applied in productFlavors block, there's no need to compare anything:

flavorDimensions "vendor"
productFlavors {
    google {
        dimension "vendor"
        apply plugin: "com.google.gms.google-services"
        apply plugin: "com.google.firebase.crashlytics"
        applicationIdSuffix ".gms"
    }
    huawei {
        dimension "vendor"
        apply plugin: "com.huawei.agconnect"
        applicationIdSuffix ".hms"
    }
}
like image 44
Martin Zeitler Avatar answered Sep 27 '22 18:09

Martin Zeitler