android - gradle无法正常工作

标签 android gradle

我正在使用Android Studio,因此决定将recyclerView添加到build.gradle。但是在添加它并同步gradle之后,我得到了这个错误:

enter image description here

    Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]

即使我做重建项目,但在此任务中我也遇到了相同的错误。以其他方式,我做了使缓存无效/重新启动,但是它不起作用,仍然存在我的问题。
我关闭立即运行,但出现了同样的错误。
我在用户中删除了.gradle文件夹,但仍然出现此错误!!!
我该如何解决这个问题?

我的build.gradle:
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
    applicationId "com.example.sayres.mychat"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner  "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),  'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-  core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
    exclude module: 'support-v4'
}
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.3-SNAPSHOT') {
    exclude module: 'support-v4'
}
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}

编辑:

在gradle控制台中,请注意以下几行:
Error: Some file crunching failed, see logs for details

:app:mergeDebugResources失败

失败:生成失败,发生异常。
  • 出了什么问题:
    任务':app:mergeDebugResources'的执行失败。

    Error: Some file crunching failed, see logs for details

  • 尝试:
    使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行,以获取更多日志输出。

    建立失败

  • 总时间:3.358秒

    这是我的日志:enter link description here

    我删除了建立文件夹,但出现了同样的错误。在这些文件夹中没有PNG图像。

    最佳答案

    尝试一下,确保您清理项目:

     android {
     aaptOptions {  
                cruncherEnabled = false  
            } 
     }
    

    希望这可以帮助。

    关于android - gradle无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44994101/

    相关文章:

    android - webView 在加载 epub3 内容时忽略 CSS

    java - 获取带有 fragment 的布局的 inflate ViewGroup

    android - 如何使用 `gradlew` 构建 APK 的路径和名称?

    java - IntelliJ 无法解析 gradle java 跨模块测试依赖

    安卓 : translate the language of whole app on click

    android - 如何在@GET 注解中动态改变值?

    gradle - 为什么 kotlin gradle 插件无法使用 1.8 目标构建?

    groovy - gradle获取相对资源路径

    android - 来自 XML 首选项的 UnknownFormatConversionException(仅在 Oneplus One 上)

    android - Google Play服务已过时。需要9683000但找到9452230