【问题标题】:How to fix Error: Duplicate resources when generate android build如何修复错误:生成android构建时重复资源
【发布时间】:2018-06-07 09:00:05
【问题描述】:

在这里,我正在尝试为 android 设备生成构建,但我收到了一个错误,定义如下,我的项目在具有 fire-store(测试版)的 ionic 中。 谁能帮我解决它:

    BUILD FAILED in 2s
    [string/google_api_key] ...............\platforms\android\app\src\main\res\values\strings.xml    [string/google_api_key] ...............\platforms\android\app\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources
    :app:mergeDebugResources FAILED
    22 actionable tasks: 2 executed, 20 up-to-date
    (node:6472) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:mergeDebugResources'.
    > [string/google_app_id] ................\platforms\android\app\src\main\res\values\strings.xml   [string/google_app_id] ................\platforms\android\app\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources
      [string/google_api_key] ................\platforms\android\app\src\main\res\values\strings.xml  [string/google_api_key] ................\platforms\android\app\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 2s
        at ChildProcess.whenDone (..............\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
        at ChildProcess.emit (events.js:160:13)
        at maybeClose (internal/child_process.js:943:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
    (node:6472) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:6472) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

【问题讨论】:

  • 发现同样的错误。你有解决办法吗?
  • @AnkitMaheshwari 是的,我得到了解决方案。这里需要从 android.json 文件中删除 google_app_id & google_api_key。
  • 谢谢@VaishaliVC 我试过了,但我通常使用 Ionic Pro Package build 生成生产版本。在那里我们无法控制 android.json 文件。
  • @AnkitMaheshwari 首先尝试解决简单构建中的错误。一旦它被删除,然后生成生产版本。

标签: android cordova firebase ionic-framework ionic3


【解决方案1】:

我在使用 cordova-plugin-facebook4 时遇到了类似的错误。

文档建议我添加:

<config-file parent="/resources" target="./res/values/strings.xml">
    <string name="fb_app_id">XXX</string>
    <string name="fb_app_name">XXX</string>
</config-file>

连同特定的插件配置:

<plugin name="cordova-plugin-facebook4" spec="^3.1.0">
    <variable name="APP_ID" value="XXX" />
    <variable name="APP_NAME" value="XXX" />
</plugin>

由于更新了一些东西,config-file 版本导致了这个问题。

config-file中删除相关项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-13
    • 2010-09-10
    • 1970-01-01
    • 2016-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多