Specifying Android project dependencies (in Eclipse)

前端 未结 5 797
一整个雨季
一整个雨季 2020-12-25 13:38

I have two Android projects, a \'library project\' containing a custom layout, and an \'application project\' containing an application which uses the layout.

Everyt

5条回答
  •  轮回少年
    2020-12-25 13:50

    Export the project as a JAR is not the right way to link a library project to your app project through Properties -> Java Build Path -> Library. Neither it is to link the project as a required project through Properties -> Java Build Path -> Projects.

    First of all, read the Library projects topic at Android developers -> Developing -> Managing projects: http://developer.android.com/guide/developing/projects/index.html#LibraryProjects After this, read the Setting up a Library Project and Referencing a library project topics again at Android Developers -> Developing -> Managing projects -> From Eclipse With ADT

    So... the steps are:

    1. Create your Library project normally as a Android Project;
    2. Set "is library" in the project properties -> Android Create your App project normally;
    3. Add a reference to your library in the project properties -> Android -> Add.

    After this you can use all classes, components (activities, services, providers, receivers), resources etc.

    Ex.: to reference any resources in a xml layout, for example, you should use @mylib:id/my_id or @mylib:layout/my_lib_layout

    Obs.: If you use components of your library in app project, you must replicate them in your app manifest.

提交回复
热议问题