"Android Library projects contain shareable Android source code and resources that you can reference in Android projects. This is useful when you have common code that you want to reuse. Library projects cannot be installed onto a device, however, they are pulled into the
.apk
file at build time."
When creating a new Android project you can mark a project as ‘Library’ project. This will create a project that can be shared/used in multiple projects. You cannot run/install the library project stand alone instead you have to reuse it in Android project.
How to mark a project as library:
Create a new Android project that will use the library
project. Library
project can be added as reference as follows:
- Android Project > Properties > Android (left option) > Library (bottom right pane) > Add
Click
‘Apply’ > ‘OK’
- To use the library class activities in android project, 'import' the library references where ever you are using library files.
- To launch the library activity you should have that activity listed in your Android project 'AndroidManifest.xml'.
- Don’t make files (Layouts, Classes, XML’s) with the same name in main and library projects. This can cause problems at run time. What I have noticed is that if you have same name layouts in both projects the library layout got overridden and parent layout will be used.
rizzz86
No comments:
Post a Comment