Mark Murphy writes: > You have to rewrite your [library] code to avoid using R. values, as they > will be wrong.
The resource compiler was changed in r14 so that the identifiers in a library project's R.java are no longer declared "final". This prevents the constants from being inlined into library bytecode, and instead forces these references to be resolved at runtime. In theory this should allow your library to continue to use R. values. Though, as explained in the r14 change docs, you won't be able to use resource ids in switch statements. On Jan 26, 6:57 am, Mark Murphy <[email protected]> wrote: > It is possible to create an Android library project that does not > include source code. The limitations are: > > -- You still have to ship the resources. > > -- You have to rewrite your code to avoid using R. values, as they > will be wrong. You will have to look up all resource IDs using > getResources().getIdentifier() and/or reflection. > > I have the instructions in _The Busy Coder's Guide to Advanced Android > Development_ (http://commonsware.com/AdvAndroid), though the > instructions are new enough that none of my free versions have them. > Quoting some of the instructions from the current edition: > > "You can create a binary-only library project via the following steps: > 1. Create an Android library project, with your source code and such – > this is your master project, from which you will create a version of > the library project for distribution > 2. Compile the Java source (e.g., ant compile) and turn it into a JAR file > 3. Create a distribution Android library project, with the same > resources as the master library project, but no source code > 4. Put the JAR file in the distribution Android library project's libs/ > directory > > The resulting distribution Android library project will have everything a > main project will need, just without the source code." > > Personally, I'd just wait a bit. I am hopeful that the official > support for library-projects-as-JARs will be available soonish. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android Training in DC:http://marakana.com/training/android/ -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

