【问题标题】:Android Studio 2.2 Google play services sync ErrorAndroid Studio 2.2 谷歌播放服务同步错误
【发布时间】:2016-09-20 13:26:36
【问题描述】:

我已经更新到 android studio 2.2

我开始了一个新项目,我加入了

compile 'com.google.android.gms:play-services-vision:9.4.0+'

在我的依赖项中。

我在启动 gradle 同步时收到此错误。

信息:Gradle 任务 [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies] 错误:com.android.builder.internal.aapt.AaptException:无法处理文件 D:\Android\clone apps\android-vision-master\android-vision-master\visionSamples\barcode-reader\app\build\intermediates\ exploded-aar\com.google.android.gms\play-services-base\9.4.0\res\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png 到 D:\Android\cloned apps\android-vision-master\ android-vision-master\visionSamples\barcode-reader\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png 错误:任务 ':app:mergeDebugResources' 执行失败。

错误:com.android.builder.internal.aapt.AaptException:无法处理文件 D:\Android\cloned apps\android-vision-master\android-vision-master\visionSamples\barcode-reader\app\build \intermediates\exploded-aar\com.google.android.gms\play-services-base\9.4.0\res\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png 到 D:\Android\cloned apps\android-vision -master\android-vision-master\visionSamples\barcode-reader\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\common_google_signin_btn_text_dark_pressed.9.png 信息:构建失败 信息:总时间:2.132 秒 信息:2个错误 信息:0 个警告 信息:在控制台中查看完整的输出

【问题讨论】:

  • 我将我的机器更新到 AS 2.2 并创建了一个新项目。我没有收到您引用的任何错误。尝试将项目移至更短的路径并更新您的 Android SDK。

标签: android android-studio android-gradle-plugin google-play-services


【解决方案1】:

据我了解,Failed to crunch file 表示工作室无法处理该文件。当您点击 Windows 操作系统的 最大文件路径长度限制(240 个字符)时,通常会发生此错误。

我建议将您的项目移动到上层目录(如 D:\barcode-reader)。

【讨论】:

  • 很高兴我能帮上忙..:)
  • 感谢它通过重命名当前目录来解决问题,但我不明白他们为什么要限制。
  • 我认为这个限制是在 DOS 时代引入的......当您将当前目录从“barcode-reader”重命名为“br”时,文件路径中的字符数会减少。在你的情况下,我不得不假设,重命名当前目录将路径减少到少于 240 个字符..
  • 太棒了!解决了我的问题,我不明白为什么还有 240 个字符的限制。
  • 我们仍然有这个限制似乎很奇怪。似乎应该在 Windows 2000 左右消失的东西......
【解决方案2】:

问题确实是文件路径过长。但是,您可以更改项目的构建目录,而不是移动您的项目。这应该可以解决问题。 在你的根 build.gradle 添加:

allprojects {
    buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    repositories {
       ...
    }
}

【讨论】:

  • 谢谢。这似乎是一个更好的解决方案。
  • 这绝对看起来是一种更好的方法,但是在构建 SDK 时似乎抱怨没有找到适合其样式的某些文件(特别是 values-v23.xml)。我目前正在做一个 Cocos2d-x 项目,我得到的错误是:Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. Error:(34) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
  • 无法编辑我自己的评论...我的问题的解决方案是在所有子项目上升级目标并将 SDK 编译到版本 23。将构建工具版本升级到 23.0.2 也有帮助。
【解决方案3】:

只需减少文件路径长度,最多可减少 240 个字符。

【讨论】:

    【解决方案4】:

    尝试像这样添加..

    compile 'com.google.android.gms:play-services-vision:9.4.0'
    

    在 Android Studio 2.2 中,它会自动添加依赖项,只需从“Assistant”中选择它,然后在项目中选择您想要的服务并连接到 Firebase

    【讨论】:

    • 我没有工作,我仍然遇到同样的错误
    • 你的 gradle 版本是什么??
    • distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 类路径'com.android.tools.build:gradle:2.2.0'跨度>
    • 你添加了这个classpath 'com.google.gms:google-services:3.0.0'如果没有添加
    • 我做了,都加在这里了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多