重装Android Studio后构建项目反复出现资源错误,求解决方案
Hey Dennis, I’ve dealt with this exact frustrating issue before after a fresh Android Studio reinstall—here are the practical fixes that worked for me and other developers:
Do a full, deep clean of build caches
Don’t just rely on Android Studio’s built-in clean. Try this sequence:- Click
Build > Clean ProjectthenBuild > Rebuild Projectin Android Studio. - Close Android Studio completely.
- Manually delete the
buildfolders in both your project root directory and theappmodule. - Delete the
.gradle/cachesfolder in your user directory (Windows:C:\Users\<YourName>\.gradle\caches; Mac:~/Library/.gradle/caches). - Restart Android Studio and rebuild your project. This wipes out all leftover corrupted cache files that the standard clean misses.
- Click
Verify Gradle plugin and wrapper version compatibility
A fresh AS install sometimes defaults to a newer plugin version that clashes with your project’s Gradle wrapper. Check these files:- In your project’s root
build.gradle, ensure thecom.android.tools.build:gradleversion matches your Android Studio version (e.g., AS Hedgehog uses plugin 8.2.x). - Open
gradle/wrapper/gradle-wrapper.propertiesand confirm thedistributionUrlpoints to a Gradle version compatible with the plugin (e.g., plugin 8.2 requires Gradle 8.2).
- In your project’s root
Check for hidden syntax errors in your resource files
The corruptedvalues.xmlis a merged file—so the root issue is likely a broken resource file in your project (likestrings.xml,styles.xml, orcolors.xml). Look for:- Unclosed XML tags
- Unescaped special characters (e.g., use
&instead of&) - Duplicate resource names across different value files
You can also runAnalyze > Inspect Codein Android Studio to auto-detect these issues.
Disable incremental resource merging
Since the error stems from incremental resource merging, you can turn this off for your debug build to bypass the issue:
Add this to your app module’sbuild.gradlefile:android { ... buildTypes { debug { androidResources { incremental = false } } } }This forces a full resource merge every time you build, which prevents the corrupted incremental file from being generated.
Re-import your project
If all else fails, back up your project, then go toFile > New > Import Projectin Android Studio to re-import it. This resets any misconfigured project settings that might have carried over from the reinstall.
内容的提问来源于stack exchange,提问作者Dennis Rieke

