Objective
Sometimes some of the open source projects we see on GitHub (from Android Studio) are not a complete Android project, but just a library Module, how do we refer to these libraries Module to our own Android module? In fact, the official website also introduced quite clear, but as a beginner really need a more complete guide, so as to avoid wasting too much time. The following is a reference to an open Source library project examples, simple translation of official documents,
Http://developer.android.com/sdk/installing/create-project.html#SettingUpLibraryModule
Steps
- 0, first we need to download the source code in Https://github.com/Manabu-GT/ExpandableTextView, can not be http://download.csdn.net/detail/leelit/8546629 in the download.
- 1. Import the Library module into project (note that project is equivalent to workspace in eclipse in as and the module is equivalent to project): File-import module- Find the appropriate library Module
- 2. Open Project View, click on our project, then find the imported library, click on Build.gradle, comment out the last line of code (otherwise, you will get an error, see
- http://stackoverflow.com/questions/28450549/ Errorno-such-property-group-for-class-org-gradle-api-publication-maven-intern), preferably also will own Android The Compilesdkversion, buildtoolsversion, and Defaultconfig of Build.gradle in module are copied here. Back to Android view you can find one more module.
- 3, File-project structure-android module (General app)-dependencies-plus-module Dependency-check-OK
- 4. If there are some components in the Android module that are used in the library module, such as activity, broadcast Receiver, service, etc., it needs to be declared in the manifest file, and the full package name is required.
Subsequent
This is where we have finished referencing library project. But we still complete this process, how to use this open source project? can refer to
Https://github.com/Manabu-GT/ExpandableTextView
In fact, many of the source code with a sample, I have the contents of the sample castrated a little. The final presentation is this:
Android Library Module: Can expand TextView