2

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 Answers2

0

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

enter image description here

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • I already tried that but didn't help. – Marko Radosavljevic Jan 28 '22 at 08:45
  • maybe you could refer to [this docs](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-config-flavor-android-0000001057944603), aslo could you mind provide your Project directory screenshot for me to check? just like i provided above. – zhangxaochen Jan 28 '22 at 08:51
  • I updated my original post, please check – Marko Radosavljevic Jan 28 '22 at 11:05
  • Sorry, looks like we cannot reproduced this issue according to the information provided above. Could you mind upload a simple demo to Github that we can reproduce the problem scene for us to check? – zhangxaochen Jan 29 '22 at 06:05
0

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

tasjapr
  • 632
  • 4
  • 13