执行失败的任务':app:MergedEbugresources' ,无法在源集中找到资源文件
每当我从项目中对XML文件进行任何更改并尝试运行该文件时,我都会得到此错误 -
执行任务失败':app:MergedEbugresources'。 java.lang.illegalargumentException:无法找到资源文件(d:q \ app \ build \ intermediates \ merged-not-compiled-resources \ debug \ debug \ layout \ layout \ notification_action.xml) 在源组中。
为了运行该项目,我需要进行构建>如果我对XML进行任何更改,则每次清洁项目。
以下是我的成绩文件 -
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "xxxxx"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
}
Whenever I made any change to an XML file from the project and tried to run it, I got this error-
Execution failed for task ':app:mergeDebugResources'.
java.lang.IllegalArgumentException: Unable to locate resourceFile (D:Q\app\build\intermediates\merged-not-compiled-resources\debug\layout\notification_action.xml)
in source-sets.
For running the project I need to do Build > Clean Project every time if I make any changes to XML.
Below is my grade file -
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "xxxxx"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
只需再次按Shift + F10即可。这是最快的方法,耗时少于清洁 - >重建
just press Shift + F10 again.This is the fastest way, less time consuming than Clean -> Rebuild
这是AGP中的一个已知问题,请参见: https://issuetracker.google.google.com/issues/sissues/20667492
显然固定在8.0中。
It's a known issue in AGP, see: https://issuetracker.google.com/issues/206674992
Apparently fixed in 8.0.
带有JPG图像的再生图标有助于我解决此错误。
Regenerating icons with JPG image helped me fix this error.
简而言之:
“清洁项目并继续前进”
详细信息:
转到Android Studio中的“构建标签”>然后单击“清洁项目”。
享受!
In short:
"clean project and move on"
Details:
Go to the "build tab" in the android studio > then click on "clean project".
enjoy!
我通过几次测试发现,前卫规则是此错误的问题。更改调试的前进规则可以解决该问题。只需要在调试构建类型中设置
缩小false
即可。I found by several testing that proguard rule is the issue for this error. Changing the proguard rules for debug solves the issue. Just need to set
shrinkResources false
in the debug buildTypes.就我而言,重新启动Android Studio是解决方案。
无需设置
缩小false
。我已经将其设置为True,它的工作原理很好。Restarting Android Studio was the solution in my case.
There is no need to set
shrinkResouces false
. I have set it to true and it works completely fine.“清洁项目然后运行应用程序”,这项工作对我来说,您也可以尝试一下
"Clean Project and then run the app", this work for me you can also try this
R8是Google的新代码收缩器,当您构建版本APK或AAB时,默认情况下启用了它。要禁用R8,请传递-no-shrink Flag以扑动构建APK或Flutter Build Build appBundle。
要获取.aab(appbundle),
以获取.apk,
R8 is the new code shrinker from Google, and it’s enabled by default when you build a release APK or AAB. To disable R8, pass the --no-shrink flag to flutter build apk or flutter build appbundle.
To get .aab(appbundle),
To get .apk,
清除Android Studio的缓存为我解决了问题。
选择'文件>无效的caches',然后单击“无效并重新启动”按钮。
Clearing Android Studio's cache resolved the issue for me.
Select 'File > Invalidate Caches' and then click the 'Invalidate and Restart' button.
就我而言,我构建了我的APK。我单击构建 - >生成签名的捆绑包或apk,
然后,我得到错误
,我在项目中删除了.IDEA文件夹。
然后我再次构建我的APK,这不再是错误。它对我有用。
In my case,I build my apk. I click build ->generate signed bundle or APK,
then I get the error
I delete the .idea folder in my project.
Then I build my apk again, it's no more error. it's working for me.
构建>> 重建项目解决了我的问题
Build >> Rebuild Project solved my probem