sachin003
sachin003

Reputation: 9053

Create Jar file for android project

I want to create a jar file from one android project for another android project.I want select only certain classes not all classes from project.I tried eclipse-export way to create a jar.Jar file is created and it also contains all selected class files,after adding the created jar file to the main android project it gives the error:“java.lang.NoClassDefFoundError”.Is the eclipse-export way is not valid to create jar for android project?

I also tried steps provided by this blog http://www.olivacorner.com/2011/04/create-an-android-jar-library-with-eclipse/comment-page-1/#comment-343,but not able to create a desired jar file.

Can anybody please provide the steps to create a jar file for android project.

Thanks.

Upvotes: 1

Views: 3997

Answers (2)

CSharp
CSharp

Reputation: 1583

Step 1. Create Android library project as explained here.(Same as suggested by Lukas)

Step 2. Now you need to give reference of Android Library project created in step 1 to your client application. There are two ways to do so.

  • Give reference of Android Library Project itself by client app property -> Select 'Android' on left pane -> In Libraty Section, Add Android Libraty project (This is explained at link given in Step 1 above)
  • Give the reference of .jar file of Android Library project (from Location of Android Library project -> bin -> .jar file). Client Application -> Properties -> Click 'Java Build Path' in lefe pane -> Go to 'Libraries' Tab -> Click 'Add External JARs' button and select the .jar file -> Go to 'Order and Export' tab and select the added .jar file reference and move it to top.

Hope this will help you.

Upvotes: 1

Lukas Knuth
Lukas Knuth

Reputation: 25755

So you want to create a library for Android? In this case, you can create a Library-project and then reference to it in the main-project.

See the docs.

Upvotes: 1

Related Questions