EasyDemo*Error:Execution failed for task :app:mergeDebugResources>Some file crunching failed的根本解决方法

Error:Execution failed for task :app:mergeDebugResources>Some file crunching failed, see logs for details的根本解决方法

遇到这个问题,可能在自己的build/source目录下根本找不到r文件夹,即编译时没有生成r文件 
这里写图片描述

要解决这个问题,首先,先找到你主工程的build.gradle文件,如下图: 
这里写图片描述

打开你的build.gradle文件,在其中加上两句话aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false 像我的是这样写的:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"
    //需要加入的两句话
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false

    defaultConfig {
        applicationId "com.elife.classproject"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.android.support:design:24.2.0'
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

添加完之后,再重新编译运行一下,如果没报错那就运行成功了;如果再报错,就能显示出你的错误在哪了,并且r文件也能重新生成了,例如我的错误: 
这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq_36287601/article/details/80646775