java - How to create and use android libraries jar? -
I have created Simple Android Libraries Project.
I have a new Android Application Project & gt; & Gt; Uncheck "Make this project as a library" and "Create custom launcher icon" and uncheck "Create activity".
Next, I create a simple class named MyClass.java and Here's my code:
package android.external.jar; Public Class Micalos {Public String Hello World () {Return "Hello World"; }} And then, I export & gt; & Gt; Java & gt; & Gt; Jar file & gt; & Gt; Uncheck all except the Src folder (this is included with Android manifest.exml) & gt; & Gt;
I have another Android advertising project to use that JR file.
I have added this project to the external jar by right clicking on my project and GT . ; & Gt; Properties & gt; & Gt; Java Build Path & gt; & Gt; Libraries & gt; & Gt;
I have tried to use my library like this:
import android.external.jar. *; ... @ Override public wide onclick onclick (see V) {// TODO auto-generated method stub switch (v.getId ()) {case R.D. button 1: try {MyClass myClass = new MyClass (); Toast. MakeActivity (), myClass.helloWorld (), toast .LENGTH_SHORT). Show (); } Hold (exception e) {// TODO: exception toast. GetActivity (), E. Megas (), Toast .LENGTH_LONG). Show (); } break; Default: Break; }} ... but it does not work ..: (
And I get an error like this:
Does anyone know how to fix my problem?
Thank you very much ..
Firstly you have your library To libs folders and then include your library and properties -> Java build path -> order and export to check your jar file in to clean up once the project and a bar check.
Comments
Post a Comment