Reputation: 1267
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'
}
Upvotes: 30
Views: 30925
Reputation: 31
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),
flutter build appbundle --no-shrink
To get .apk,
flutter build apk --no-shrink
Upvotes: 3
Reputation: 22647
It's a known issue in AGP, see: https://issuetracker.google.com/issues/206674992
Apparently fixed in 8.0.
Upvotes: 0
Reputation: 1218
just press Shift + F10 again.This is the fastest way, less time consuming than Clean -> Rebuild
Upvotes: 0
Reputation: 211
"Clean Project and then run the app", this work for me you can also try this
Upvotes: 8
Reputation: 447
In short: "clean project and move on"
Details: Go to the "build tab" in the android studio > then click on "clean project". enjoy!
Upvotes: 36
Reputation: 3408
In my case,I build my apk. I click build ->generate signed bundle or APK, then I get the error
Unable to locate resourceFile
I delete the .idea folder in my project.
Then I build my apk again, it's no more error. it's working for me.
Upvotes: 1
Reputation: 109
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.
Upvotes: 9
Reputation: 21
Clearing Android Studio's cache resolved the issue for me.
Select 'File > Invalidate Caches' and then click the 'Invalidate and Restart' button.
Upvotes: 2
Reputation: 1267
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.
buildTypes {
debug {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Upvotes: 24