找不到与包名称匹配的客户端 (Google Analytics) - 多个 productFlavors &构建类型 [英] No matching client found for package name (Google Analytics) - multiple productFlavors & buildTypes
问题描述
上下文:
我正在尝试为我的应用设置 Google Analytics(分析).(有 4 个自定义 buildTypes
和多个 productFlavors
)
I'm trying to set up Google Analytics for my app. (having 4 custom buildTypes
and more than a few productFlavors
)
当我选择 applicationId
设置为 com.my.app.package.name
(生成 google-services.json
时使用的包名称).但是,我的其他口味有不同的 applicationId.
It works fine when I select the Build Variant
which has the applicationId
set to com.my.app.package.name
(the package name used when generating the google-services.json
). But, my other flavors have different applicationIds.
我按照官方开发指南进行设置.
在Build Variants Tab
(具有不同的applicationId
(包名称)如下所示)中选择任何其他构建变体时出现的错误:
Error I get when any another build variant is selected in Build Variants Tab
(which has a different applicationId
(package name) is as follows:
错误:任务执行失败':app:processAllcategoriesDebugfreeGoogleServices'.
Error:Execution failed for task ':app:processAllcategoriesDebugfreeGoogleServices'.
找不到与包名称com.my.app.package.name.debug"匹配的客户端
No matching client found for package name 'com.my.app.package.name.debug'
错误信息说明:
在上面错误消息的任务名称中,Debugfree
是我的自定义 buildType
,Allcategories
是我的 productFlavors代码>.
In the task name in the error message above Debugfree
is my custom buildType
and Allcategories
is one of my productFlavors
.
我理解错误,并且知道包名称与我在生成 json 时使用的名称不同,但这正是我想要解决的问题.
问题:
现在,google-services.json
位于 app
文件夹中,因此我无法通过将它们放入风味特定的源集文件夹.
Now, the google-services.json
resides in the app
folder and hence I am not being able to separate them out for each product flavor by dropping them in the flavor specific source set folder.
问题:
- 我的自定义
byildType
用于调试后缀.debug
到applicationId
(包名称).有没有一种方法可以使它与具有我的版本applicationId
(即没有后缀.debug
)的google-services.json
一起使用 - 有没有办法在同一个
google-services.json
文件中配置多种产品风格,而无需使用单独的文件和任务将所需文件复制到app
文件夹.我知道它可以使用task
完成,如 这篇文章中所述.有没有一种更简单的方法来只拥有一个文件或根据 gradle 配置选择正确的文件? - 我看到
google-services.json
中的package_name
字段具有包名称com.my.app.package.name
.我可以手动添加多个包名称以适用于所有构建变体吗?如果是,如何做到这一点?在文档中找不到任何说明.
- My custom
byildType
for debugging suffixes.debug
to theapplicationId
(package name). Is there a way I can make it work with thegoogle-services.json
which has my releaseapplicationId
(i.e. without the suffix.debug
) - Is there a way to have multiple product flavors configured in the same
google-services.json
file without using separate files and tasks to copy the required file toapp
folder. I know it can be done usingtask
as mentioned in this post. Is there a simpler way to just have one file or pick right file based on gradle configuration? - I see the
package_name
field ingoogle-services.json
has the package namecom.my.app.package.name
. Can I add multiple package names manually to work for all build variants? If yes, how to do that? Could not find any instructions in documentations.
推荐答案
检查 google-services.json 上的包名称,它应该与应用的本地包名称相同
Check your package name on your google-services.json it should be same with your local package name of your app
示例
"client_info": {
"mobilesdk_app_id": "1:6596814400689:android:65d6f25f5006145",
"android_client_info": {
"package_name": "com.my.app.package.name"
}
在这种情况下,我的本地包名称是 com.my.app.package.name 所以我也在 google-services.json 中更改了我的包名称本地包名
In this case my local package name is com.my.app.package.name so also i have changed my package name in google-services.json with my local package name
这篇关于找不到与包名称匹配的客户端 (Google Analytics) - 多个 productFlavors &构建类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!