【问题标题】:Exception : mergeDebugResources in Android Studio异常:Android Studio 中的 mergeDebugResources
【发布时间】:2016-04-18 20:12:41
【问题描述】:

如果我尝试在 Top - level build.gradle 文件中添加依赖项,则会出现以下错误。这个依赖对于在项目中添加 GCM 非常有用,没有它 GCM 将无法工作:

依赖:

classpath 'com.google.gms:google-services:1.5.0-beta2'

错误:-

Error:Execution failed for task ':app:mergeDebugResources'.
> Some file crunching failed, see logs for details

如果我从顶级 build.gradle 中删除该依赖项,则项目编译并成功运行。

如果我添加该文件,我会收到错误,Android Studio 不会运行项目。

请帮助我摆脱这个错误。

编辑 这是我的项目级 build.gradle 文件:-

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {

//        classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
        classpath 'com.android.tools.build:gradle:2.0.0-beta5'
        classpath 'com.google.gms:google-services:2.0.0-beta5'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【问题讨论】:

    标签: android google-cloud-messaging


    【解决方案1】:

    尝试从 HERE 更改最新版本的依赖项:

    classpath 'com.google.gms:google-services:2.0.0-beta5'
    

    还要确保在根项目 gradle 文件中设置正确的 Gradle 插件依赖项。

     classpath 'com.android.tools.build:gradle:2.0.0-beta5'
    

    因此,您的最终项目 build.gradle 文件将如下所示

    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-beta5'
        classpath 'com.google.gms:google-services:2.0.0-beta5'
    }
    

    【讨论】:

    • 感谢您的帮助。我已经尝试过你的代码,但它不起作用。我又遇到了同样的错误:-(
    • 请提供您的完整项目级 gradle 文件
    • 我已经解决了问题,问题是我们必须使工具和 google-service 版本相同。我已将 google-service 版本更改为 classpath 'com.google.gms:google-services:1.3.0-beta2' 并解决了我的问题..
    • 很高兴看到它对您有所帮助。
    【解决方案2】:

    试试这个应该会有帮助。

    buildTypes {
           release {
         multiDexEnabled true;
          }
    
     }
    

    【讨论】:

      【解决方案3】:

      在您的 Gradle 日志中,如果您遇到错误/无效的 PNG 文件,请查看我在 Android Studio Gradle 2.0.0-alpha1 build errors 的回答

      希望这会有所帮助...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-02-15
        • 1970-01-01
        • 2017-05-03
        • 1970-01-01
        • 2016-06-29
        • 2019-01-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多