Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>behind the scenes, Eclipse creates and references a jar from the referenced library project.</p> </blockquote> <p>This is not quite accurate. Library project is referenced as a raw project dependency (source-based mechanism), not as a compiled jar dependency (compiled-code based library mechanism). Currently Android SDK does not support exporting a library project to a self-contained JAR file. The library project must always be compiled/built indirectly, by referencing the library in the dependent application and building that application. When build dependent project, the compiled source and raw resources that need to be filtered/merged from Library project are copied and properly included in the final apk file. Note that Android team had started revamping the whole Library Project design (move it from ource-based mechanism to compiled-code based library mechanism) since r14, as mentioned in <a href="http://android-developers.blogspot.co.nz/2011/10/changes-to-library-projects-in-android.html" rel="nofollow">this earlier blog post</a>.</p> <blockquote> <p>What are some of the best practices for sharing and extending common classes among Android app targets?</p> </blockquote> <p>The solution given by Android is <a href="http://developer.android.com/guide/developing/projects/index.html#LibraryProjects" rel="nofollow">Library Project</a>.<br> The solution given by Java is <a href="http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html" rel="nofollow">Inheritance</a> and <a href="http://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html" rel="nofollow">Polymorphism</a>.<br> Come together, the best practice IMO is the second option you mentioned in the question:</p> <blockquote> <p>2.Extend the particular Core class in a target project and override the base (Core) class functions as needed. Then keep a reference to the base-class object in the Core library and instantiate it with an extended class object (from Android library project - How to overwrite a class?)</p> </blockquote> <p>From my personal experience, I always use Android Library Project (Sometimes with Regular Java Project, for implementing/building common-lib.jar that contains only POJO) manage common code, for instance SuperActivity or SuperService, and extends/implements proper classes/interfaces in the dependent project for Polymorphism.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload