I have encountered the following problem:
1) I have a Library (“[x] Is Library” selected) created in Eclipse. It has 2 layouts (main.xml and another one) included.
2) It works very well when I use it within one Eclipse Workspace – I can easily include it in another project and use it without issues.
3) My workspace got huge recently and Eclipse even slower than earlier (and I am working on an Intel Atom “powered” netbook). So I decided to create new one.
4) I have copied the mylibrary.jar file from its bin folder, including the library.jar in new project worked well. Everything compiles, but at runtime an java.lang.NoClassDefFoundError: my.namespace.mylibrary.R$layout is raised at startup.
What I have done:
1) I tried to find solution here on stackoverflow but NoClassDefFoundError on external library project for Android is what I found but I already have the jar file added.
2) Then I have looked into the jar file (renamed to zip & unpacked) to see that the R$layout class is not included there.
How can I get layout classes included into the library.jar file?
Is this really the source of my issue or I am doing something else wrong?
Thanks for advice.
Edit: I have checked and removing xml layouts from the library (e.g. creating a dummy one in code) stops the NoClassDefFoundError. Yet looking at admob.jar file seems it is possible to include R&layout class into the jar file.
Seems the only answer to this one is to create layouts in .java file not in .xml. Tested this one and works well. No idea how admob get theirs layouts included in the .jar file.