Android Huawei maps agconnect-services.json can't be located

836 views Asked by At

I have the issue with Huawei maps after introducing product flavours and issue is referenced to the fact that agconnect-services.json can't be located

E/HMSSDK_AGCUtils: Get client/cp_id failed: java.io.FileNotFoundException: agconnect-services.json

So everything was working fine until product flavours are introduced.

The configuration of product flavours are following:

flavorDimensions "provider"
productFlavors {
    huawei {
        dimension "provider"
    }
    google {
        dimension "provider"
    }
}
 sourceSets {
    huawei {
        java {
            srcDirs 'src/huawei/java'
        }
        res {
            srcDirs 'src/huawei/res'
        }
    }
    google {
        java {
            srcDirs 'src/google/java'
        }
        res {
            srcDirs 'src/google/res'
        }
    }
}
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Huawei")) 
{
    apply plugin: 'com.huawei.agconnect'
}

classpath 'com.huawei.agconnect:agcp:1.6.3.300'

So the package name keeps the same nothing is changing for flavour. I tried positioning .json file to app/src/huawei but nothing helped.

enter image description here This is my current setup.

I tried positioning .json file to app/src/huawei, app/src/debugHuawei, app/src/debugHuawei, app/, app/src/huaweiDebug, app/src/debug/huawei but didn't help.

Thanks in advance

2

There are 2 answers

4
zhangxaochen On

You could try configuring the directory according to the current options of Build Variant. like following:

enter image description here

0
tasjapr On

you have to put this agconnect-services file outside the src folder: just app/agconnect-services.json

also in your screenshot there are 2 agconnect-services.json files, delete them and put only 1 file in the path I indicated above