omfaer
omfaer

Reputation: 187

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

I want to use Push Kit and I use product flavors in my project. There are 4 different build variants and package names in my project.

enter image description here

Package Names:

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

I have added agconnect-services.json to different directories. It works this way.

enter image description here

My Question:

Is it possible to write all client information to only one agconnect-services.json file. Can't I write client information as a array in json file?

For example, I tried this by editing the json file for two different debug variants as below and it doesn't work.

{
    "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"
        }
    ],

    ...
}

I've looked at the Huawei Push Kit documentation and SDK integration documentation. I have looked at the links below. I've also reviewed the sample codes.

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

Is there a solution for this? Can you help with this?

Upvotes: 3

Views: 299

Answers (1)

zhangxaochen
zhangxaochen

Reputation: 34047

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?

You need to create a .blue.debug project on AGC, and download the corresponding JSON file, then create a flavor in the project,The folder can be named randomly,as long as the package name corresponding to the flavor is .blue.debug. Then put the JSON file in this folder is fine.

Upvotes: 1

Related Questions