问题
I've searched all over Google, stackoverflow and other android programming websites, many have suggestions for people who have misplaced files from one folder to another and so forth.. But none that illustrate the problem I'm facing.
It's not a corrupt file as in the case here as I tried this with no success.
The error I'm facing is similar though:
[debug] C:\Users\Name\AppData\Local\Temp\android_manifest_copy6264790980678653632tmp\AndroidManifest.xml:11: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher').
Similarly, this is happening with an @string element, @style element and another @string, examples below:
'@string/app_name'
'@style/AppTheme'
'@string/app_name'
One thing that I have noticed, and coming from the world of Eclipse, I cannot explain this behavior in Android Studio.. In my 'main' project folder, everything exists and builds correctly for debugging. It seems that Android Studio is trying to build off of a 'debug' folder, which will not build when running 'Build' > 'Rebuild Project'.
Does anyone know where I can place these missing files to get the project to build? Or is this some other problem?
回答1:
Alright, so after fussing with the rebuild for hours trying different methods (renaming particular files [i.e. those with the problems], rebuilding the app after renaming folders inside the build folder, etc) I finally decided that I would go to the source of the problem and see if it worked like other IDE's. Indeed it did, this is how I performed the fix:
- Find the location of the problem - For me, all four of the errors I had were inside the 'build' folder of the project.
- Close any open instances of the project
- While the project is closed, rename this folder from windows explorer (or other if youre using a different OS) (i.e. If the folders name is "build", rename it to "build.old")
- Open the project once more
- Go to Build > Rebuild Project
You should not have any issues doing this, like I did.
Specifications:
- IDE Platform: Android Studio
- IDE Version: Android Studio (I/O Preview) 0.2.2
- JRE: 1.7.0_25
回答2:
My problem is about @drawable/img_1
, the pic is JPEG format, while it's extension name is png, I force to rename it jpg extension. Then it builds successfully.
回答3:
If anyone is using Gradle and sees this it's good to remind about the convention directory structure.
For Gradle you have to put your resources in src/main/res. I migrated a project to Gradle and got the said error when I hadn't moved the res/ directory from the old structure.
来源:https://stackoverflow.com/questions/17893372/error-building-project-in-android-studio-error-no-resource-found-that-matches