简体   繁体   中英

problem with resources and android library project

I'm having a problem adding resources to my Android project when i have a Library project referenced. This is what I'm seeing:

Both Projects compile and run fine. When i have the library project linked and I want to add a string resource to the main project, the line is there in the XML file, everything compiles but the resources is not added to the R class. I've tried cleaning the project, removing the R class etc. But all the resources that were already there before i linked the Library are all present in R. Also the resources that were present in both projects are correctly merged.

To work around this I need to unlink the library project, comment all the references to it in the main project and then all the resources i add are added to the R class. (then I need to re-link the library).

I'm using Eclipse and ADT .

What could cause this?

Thanks!

It seems like Eclipse sometimes doesn't realize that it needs to regenerate the R.java file even with a clean + rebuild. it's the compile pass that fixes this but the resource references in code keep it from compiling. I've sometimes had to temporally comment out the lines that reference the resources just to get a clean compile. Then I uncomment those lines and suddenly everything is fine again.

Mixed with with linked libraries, Eclipse can get very flaky. Your solution of temporally turning library projects into non-library projects was the key for me today. Non-library + commented resource references + recompile + uncomment + re-library + recompile seems to be the magic formula.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM