Create library for Android development?

后端 未结 3 1351
暖寄归人
暖寄归人 2021-01-01 05:21

I\'m pretty new to Android development, but I have some experience with Java and Eclipse. I\'m looking for ways to create re-usable libraries (controls, helpers, \"standard

相关标签:
3条回答
  • 2021-01-01 05:51

    Brave new world of dependency management:

    http://tools.android.com/recent/dealingwithdependenciesinandroidprojects

    0 讨论(0)
  • 2021-01-01 05:58

    Thanx for your solution. From what I understand, you still can not access the resources private to the library from within the libary code. So assume your library has a string resource named "my_lib_resource" under res/values in the library. You bundle this in the jar along with the source code. Can you access this resource from the library source code using something like:

    int id = res.getIdentifier("com.example.mylib:string/my_lib_resource",null,null) 
    

    assuming your library package name is com.example.mylib.

    For me this does not work.

    0 讨论(0)
  • 2021-01-01 06:08

    I've read about Android Library Projects, but as the documentation states they can not be packaged into a JAR, but will be compiled along with the project that references the library project. This means I also have to distribute the source code.

    Not true. It does require a bit of extra packaging work, but you can compile your code to a JAR and distribute the JAR in the library project's libs/ directory.

    So: Is there a way of compiling and packaging a set of classes and other files (including XML layouts, resources and stuff) and distribute only that package without any source codes so that it can be "referenced" and used like a JAR file by any other developer?

    Use an Android library project. I have some stuff written up here that describes a bit more of the packaging options, plus pointers to some "parcels" that follow the conventions described therein.

    0 讨论(0)
提交回复
热议问题