是否可以将所有客户端信息只写入一个agconnect-services.json文件?

Is it possible to write all client information to only one agconnect-services.json file?

我想使用Push Kit,我在我的项目中使用了product flavors。我的项目中有 4 个不同的构建变体和包名称。

包名称:

variant: blueDebug           -  package_name: com.omfaer.pflavors.blue.debug
variant: blueRelease         -  package_name: com.omfaer.pflavors.blue
variant: developmentDebug    -  package_name: com.omfaer.pflavors.debug
variant: developmentRelease  -  package_name: com.omfaer.pflavors

我已将 agconnect-services.json 添加到不同的目录。它是这样工作的。

我的问题:

是否可以将所有客户端信息只写入一个agconnect-services.json文件。 json 文件中不能将客户信息写成数组吗?

例如,我通过如下所示为两个不同的调试变体编辑 json 文件来尝试此操作,但它不起作用。

{
    "agcgw":{
        "websocketbackurl":"connect-ws-dre.hispace.dbankcloud.cn",
        "backurl":"connect-dre.dbankcloud.cn",
        "websocketurl":"connect-ws-dre.hispace.dbankcloud.com",
        "url":"connect-dre.hispace.hicloud.com"
    },
    "client":[
        {
            "appType":"1",
            "cp_id":"****************",
            "product_id":"************",
            "client_id":"************",
            "client_secret":"********************",
            "project_id":"******************",
            "app_id":"123456789", 
            "api_key":"********************************************",
            "package_name":"com.omfaer.pflavors.debug"
        },
        {
            "appType":"1",
            "cp_id":"****************",
            "product_id":"************",
            "client_id":"************",
            "client_secret":"********************",
            "project_id":"******************",
            "app_id":"987654321",
            "api_key":"********************************************",
            "package_name":"com.omfaer.pflavors.blue.debug"
        }
    ],

    ...
}

查看了华为Push Kit文档和SDK集成文档。 我看过下面的链接。我还查看了示例代码。

https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-config-flavor

https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/service-introduction-0000001050040060

https://developer.huawei.com/consumer/en/doc/development/HMSCore-Examples/client-sample-code-0000001051066000

app/build.gradle

android {
    ...

    signingConfigs {
        release{
            storeFile file('keystore.jks')
            keyAlias '***'
            keyPassword '********'
            storePassword '********'
            v1SigningEnabled true
            v2SigningEnabled true
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }

        debug {
            signingConfig signingConfigs.release
            debuggable true
            applicationIdSuffix = '.debug'
        }
    }

    flavorDimensions "default"
    productFlavors {
        development {
            minSdkVersion 19
            resConfigs("en", "xhdpi")
            dimension "default"
        }
        blue {
            applicationIdSuffix = '.blue'
            dimension "default"
        }
    }
    
    ...
}

有解决办法吗?你能帮忙吗?

There is no .json file for .blue.debug in the question. What's the best way to do this? Should I create the "blue" directory under the "debug" directory or the "debug" directory under the "blue" directory? Do you have any other suggestions?

需要在AGC上创建一个.blue.debug工程,并下载对应的JSON文件,然后在工程中创建一个flavor,文件夹可以任意命名,只要风味对应的包名是.blue.debug。然后把JSON文件放到这个文件夹里就好了