首页 > 解决方案 > Android 构建失败,字符串/google_app_id 重复资源错误

问题描述

我正在研究 ionic 4。当我在 cmd 中运行此命令时:

ionic Cordova build android

它给了我一个重复的资源错误。我在我的项目中使用 firebase 和 google services.json 插件。

我试图从 Andriod.xml 文件中删除 google_app_id 和 google_api_key 但没有改变。一次又一次地显示相同的错误。这是 android.xml 文件的视图。

Android.xml 文件

 "res/values/strings.xml": {
        "parents": {
          "/resources": [ 
              // removed google_app_id & google_api_key
]
        }
      }
    }

字符串.xml 文件:

<resources>
    <string name="app_name">UrbanX Driver</string>
    <string name="launcher_name">@string/app_name</string>
    <string name="activity_name">@string/launcher_name</string>
    <string name="google_app_id">@string/google_app_id</string>
    <string name="google_api_key">@string/google_api_key</string>
</resources>

Config.xml 文件:

        <resource-file src="google-services.json" target="app/google-services.json" />

标签: androidionic-frameworkgoogle-play-servicesionic4

解决方案


安装这个插件cordova-android-play-services-gradle-release

ionic cordova plugin add cordova-android-play-services-gradle-release

检查此链接的原因:

https://github.com/arnesson/cordova-plugin-firebase#google-play-services


推荐阅读