如何在 Android 项目的 google-services.json 中获取 mobilesdk_app_id 参数?
How to get mobilesdk_app_id parameter in google-services.json for Android projects?
您可以创建一个新项目并向其添加服务。本网站会自动为您的新项目生成一个google-services.json文件。
我的问题是,在这个 google-services.json 文件中,我们如何检索参数 mobilesdk_app_id 的值?是否可以手动找到此值?似乎无法在 google 开发人员控制台中找到它。
我找到了这份文档 Processing the JSON File,它可以帮助您。
Every value in the XML files is present in the google-services.json
file at the locations below. If your Android project has some configuration that prevents you from using the google-services
plugin, you can safely recreate the XML files manually using these values:
google_app_id:
{YOUR_CLIENT}/client_info/mobilesdk_app_id
还有
The main result of the JSON processing is to produce two XML files which you can reference as Android resources in your Java code. Below is an example of each file:
app/build/generated/res/google-services/{build_type}/values/values.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="ga_trackingId" translatable="false">UA-65557218-3</string>
<string name="gcm_defaultSenderId" translatable="false">1035469437078</string>
<string name="google_app_id" translatable="false">1:1035469437078:android:73a4fb8297b2cd4f</string>
<string name="test_banner_ad_unit_id" translatable="false">ca-app-pub-3940256099942544/6300978111</string>
<string name="test_interstitial_ad_unit_id" translatable="false">ca-app-pub-3940256099942544/1033173712</string>
</resources>
看来mobilesdk_app_id
可以通过获取Android资源中的google_app_id
来获取mobilesdk_app_id
。
编辑:mobilesdk_app_id 可以在 google-services.json
中找到
您可以创建一个新项目并向其添加服务。本网站会自动为您的新项目生成一个google-services.json文件。
我的问题是,在这个 google-services.json 文件中,我们如何检索参数 mobilesdk_app_id 的值?是否可以手动找到此值?似乎无法在 google 开发人员控制台中找到它。
我找到了这份文档 Processing the JSON File,它可以帮助您。
Every value in the XML files is present in the
google-services.json
file at the locations below. If your Android project has some configuration that prevents you from using thegoogle-services
plugin, you can safely recreate the XML files manually using these values:google_app_id:
{YOUR_CLIENT}/client_info/mobilesdk_app_id
还有
The main result of the JSON processing is to produce two XML files which you can reference as Android resources in your Java code. Below is an example of each file:
app/build/generated/res/google-services/{build_type}/values/values.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="ga_trackingId" translatable="false">UA-65557218-3</string> <string name="gcm_defaultSenderId" translatable="false">1035469437078</string> <string name="google_app_id" translatable="false">1:1035469437078:android:73a4fb8297b2cd4f</string> <string name="test_banner_ad_unit_id" translatable="false">ca-app-pub-3940256099942544/6300978111</string> <string name="test_interstitial_ad_unit_id" translatable="false">ca-app-pub-3940256099942544/1033173712</string> </resources>
看来mobilesdk_app_id
可以通过获取Android资源中的google_app_id
来获取mobilesdk_app_id
。
编辑:mobilesdk_app_id 可以在 google-services.json
中找到