Android项目运行触发Resources$NotFoundException,已尝试清理重启仍未解决
Hey there, I get it—this resource not found error can be super frustrating, especially after you’ve already tried cleaning the project and restarting the app. Let’s break down how to fix this step by step.
First, let’s recap the error you’re seeing:
03-19 14:57:58.523 22517-22517/com.example.vrindabhatt.wall_app E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.vrindabhatt.wall_app, PID: 22517 android.content.res.Resources$NotFoundException: Resource ID #0x7f07007a at android.content.res.Resources.getValue(Resources.java:2345) at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:330) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager....
Here’s what you can try next:
Find out what resource ID #0x7f07007a corresponds to
Open your project’s auto-generatedR.javafile (you can find it underbuild/generated/source/r/debug/com.example.vrindabhatt.wall_app/) and search for0x7f07007a. This will tell you exactly which resource is missing—whether it’s a drawable, layout, string, or something else. Alternatively, use Android Studio’s double-Shift search to look up the resource ID directly.Verify the missing resource exists and is valid
- If it’s a drawable: Check if the image file is present in the correct
drawable-*folders. Make sure the filename uses only lowercase letters, numbers, and underscores (Android is strict about this). Also, ensure the resource isn’t accidentally deleted or moved to the wrong directory. - If it’s a layout/string: Confirm the file exists in
res/layoutorres/values, and that there are no syntax errors inside the file that might prevent it from being compiled.
- If it’s a drawable: Check if the image file is present in the correct
Check for incorrect resource references
Go through your code and layout files to make sure you’re referencing the right resource ID. Sometimes a typo or copy-paste error can lead to referencing a resource that doesn’t exist. For example, if you changed a resource name but forgot to update all references to it.Do a deep clean and rebuild
Beyond the basic "Clean Project", try these steps:- Go to
File > Invalidate Caches / Restartin Android Studio—this clears out cached data that might be causing conflicts. - Delete the entire
buildfolder in your project directory, then clickFile > Sync Project with Gradle Filesto regenerate all build files from scratch.
- Go to
Check for dependency resource conflicts
If you’re using third-party libraries, there’s a chance their resource IDs are conflicting with yours. Try updating all your dependencies to their latest versions, or check if any library is defining a resource with the same name as yours.
Give these steps a shot—usually one of them will resolve the issue. Let me know if you hit any snags!
内容的提问来源于stack exchange,提问作者Harsh Patel

