在打包APK:colors.xml期间重复文件

时间:2015-09-05 01:54:59

标签: android

我正在尝试构建项目,我看到了这个错误:

Error:duplicate files during packaging of APK C:\Android\Git\my_android_project\project\build\outputs\apk\project-debug-unaligned.apk
    Path in archive: values/colors.xml
    Origin 1: C:\Android\Git\my_android_project\project\build\intermediates\javaResources\debug\values\colors.xml
    Origin 2: C:\Android\Git\my_android_project\project\build\intermediates\exploded-aar\my_android_project\androidsupportv7appcompat\unspecified\jars\classes.jar
You can ignore those files in your build.gradle:
    android {
      packagingOptions {
        exclude 'values/colors.xml'
      }
    }
Error:Execution failed for task ':project:packageDebug'.
> Duplicate files copied in APK values/colors.xml
    File 1: C:\Android\Git\my_android_project\project\build\intermediates\javaResources\debug\values\colors.xml
    File 2: C:\Android\Git\my_android_project\project\build\intermediates\exploded-aar\my_android_project\androidsupportv7appcompat\unspecified\jars\classes.jar

当然有几个/res/values/colors.xml因为支持库和我自己的项目......我认为它们应该被合并了?!

为什么colors.xml没有合并到APK?

没有重复的值:

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <color name="button_background_rest">#CCFFFFFF</color>
     <color name="button_background_press">#CC00529C</color>
     <color name="loading_gray">#CC56595E</color>
     <color name="loading_bar_blue_20">#2079C7F7</color>
     <color name="loading_bar_blue_80">#8079C7F7</color>
     <color name="loading_bar_blue_100">#ff79C7F7</color>
     <color name="transparent">@android:color/transparent</color>
     <color name="skyblue">#79C7F7</color>
     <color name="gray">#6C6F73</color>
     <color name="semitransparent_gray">#806C6F73</color>
     <color name="blaze">#72C000</color>
     <color name="dusk">#F26A08</color>
     <color name="envy">#950A14</color>
     <color name="white">@android:color/white</color>
     <!-- color name="light_gray">#87898D</color -->
     <color name="dark_gray">#56595E</color>
     <color name="light_gray">#8C97A5</color>
     <color name="transparent_dark_gray">#B0000000</color>
     <color name="blue">#80D1F5</color>
     <color name="recent_gray">#B0888A8D</color>
     <color name="black">@android:color/black</color>
</resources>

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>
    <color name="abc_search_url_text_normal">#7fa87f</color>
    <color name="abc_search_url_text_selected">@android:color/black</color>
    <color name="abc_search_url_text_pressed">@android:color/black</color>
</resources>

1 个答案:

答案 0 :(得分:0)

我玩了很多,例如升级到appCompat 23.0.1并使用编译器ver编译。 23

然而,这些东西都没有阻止APK构建失败。

最终解决了什么:

1) Android Studio,当我从Eclipse导入项目时,创建了&#34; res&#34;和&#34;资源&#34;文件夹。

2)我浏览了所有模块并删除了&#34;资源&#34;文件夹!!

3)清理项目并重建。

Android Studio创建&#34;资源&#34;的重点是什么?文件夹?