首页 > 解决方案 > 使用多风格编译 GMS 和 HMS 包。但是GMS版本编译的时候报错

问题描述

我有一个应用程序配置了两种编译风格,一种使用 HMS,另一种不使用。编译不使用HMS的flavor时,包名与json文件不一致。结果,发生错误。

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.
==============================================================================

那么当不同风味使用不同的包名时如何解决这个问题呢?

标签: androidjsonfirebasepackagehuawei-mobile-services

解决方案


各个插件可以在productFlavors块中应用,无需比较任何东西:

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"
    }
}

推荐阅读