(1) Project import jar Package:1, in the project EC or MYEC, the external jar package is copied in a libs directory . Old Project no Lib directory, alive called LIB, will error, to change to Libs2. Right click on Project, Bulid path->configure Build Path
3. In the Set Libraies item, select the location you just added the jar package. 3. In order and export, select the external jar package. (many times, can be waived)4, clean project, recompile, then the APK package should contain an external jar. In Myec or Androidstudio, if you do not recompile, you can refresh it manually. /(2) importing the library is too simple to say.
(2)Package the project into a jar package:
to publish to a forum or GitHub, or to reference him in another project, a jar package can save you a lot of time.
here's how to package your own project into a jar package, how to package your Android project into a jar package Dahne
run into the DOS window under the bin\classes file for the project
CD Files directory
1: If your project needs to introduce data files (tablets, txt files, etc.), first put your resource files into the asset file under the project, and then put you this asset file copied to your project classes file,
2: Open your local disk, locate your project's workspace folder, and find the corresponding file name of your project, enter the bin folder of this project, we can find this classes file
3: If your project also refers to other third-party jars, you need to put this third-party jar package also into your project jar package, you need to extract the third-party jar package, and the extracted files are copied to the Classes/com file, I have this COM file because my project package name outermost is called: COM, your own is just your own project, and with the file of your project, there is a parallel,
4: Then run in DOS window: JAR-CVF Jarname.jar *, so that we can see in the Bin folder to generate a Jarname.jar file, this file is our training project after the packaging of the file
(3) package the project into a library project
Research How to make the resources and activity files into JAR file for Project call, took a lot of detours, also tried a variety of different ways, are not too ideal, and ultimately from the official Android documents found the perfect solution, here to do a summary.
This blog post is a first step in combining the translation of the Android development documentation with the specifics of the individual development process, setting up normal Android project as a library itemThe Library project is also a standard Android project, so you first create a normal Android project. This item can be any name, any package name, set other fields that need to be set, etc.
then set up the project as a library project with the following steps
- In the package Explorer , right-click the project folder and tap Properties.
- In the Properties window , select "Android" and theLibrary properties are displayed on the bottom right.
- Select the "Is Library" Radio box and click Apply.
- Click OK to close the Properties window.
at this point, the project becomes a library project.
of course, the Java project can also make it into a library project, which is very simple and performs the four steps above. Other program projects can reference the Library project.
Create a manifest filethe manifest file for a library project also declares all shared components as standard Android applications.
like in Apidemo.Tictactoelibin this example, the library project declares the activity gameactivity:
<manifest> ... <application> <activity android:name= "gameactivity"/> ... </appli Cation></manifest>The second step references the library projectIf you are developing an application that wants to include code and resources in a library project, it is very simple to refer to the following steps
- In the package Explorer , right-click the project folder and tap Properties.
- In the Properties window , select "Android" and theLibrary properties are displayed on the bottom right.
- Click Add to open the Project Selection dialog box.
- Select an item from the list of available library items and click OK.
- After the dialog box is closed, click Apply (in the Properties window).
- Click OK to close the Properties window.
By completing the six steps above, Eclipse will rebuild the project to include the contents of the Library project.
Sometimes we refer to multiple libraries
If you want to add references to multiple library projects, use up and down to set their relative precedence and merge order. When the tool merges the referenced libraries, the order is from the lower priority (below the list) to the high priority (above the list). If more than one library defines the same resource ID, the tool chooses a resource with a high priority. The application itself has the highest precedence, its own resources zthe application itself has highest priorities and its resources is always used in preference to Identi Cal resource IDs defined in libraries.
declaring components in a library in a menifest file
in the manifest file, you must increase all the components in the library project that are used in the current program. For example, you must declare any use of <activity>, <service>, <receiver>, <provider> et, <permission>, < Uses-library>, and other similar elements.
when declaring a component in a library project, you must use the full name of the class that contains the package name.
in theTictactoemainin the example, the Declaration library activity gameactivity:
<manifest> ... <application> <activity android:name= "com.example.android.tictactoe.library. Gameactivity "/> ... </application></manifest> need to know more about androidmanifest for more information seeAndroidmanifest.xml.
Android Guide Pack Import jar package, package jar package, package into library. Kankanstyle