1

I know that we should put the .jar library into the libs folder in the project directory and after that everything automatically should work fine. It fix errors in my code and importing classes but it throws exceptions. for example when I'm using jfeinstein10/SlidingMenu library, throws

java.lang.NoClassDefFoundError: com.slidingmenu.lib.R$styleable

as soon as encountering

SlidingMenu slidingMenu = new SlidingMenu();

at run time. Is there any problem with my library adding process?

Soheil Setayeshi
  • 2,343
  • 2
  • 31
  • 43

3 Answers3

2

https://github.com/jfeinstein10/SlidingMenu is a library project.

Import your library project sliding menu to eclipse.

Right Click on the library project. goto properties. Choose android. you should see Is Library checked.

In your Android project right click goto properties. Choose android. Click Add. browse the library project add and click ok.

http://developer.android.com/tools/projects/projects-eclipse.html

http://developer.android.com/tools/projects/index.html

Refering action bar sherlock( is also a library project) in Android project.(added snapshots). Check the link below for snap shots.

import .R cannot be resolved when I import actionbarsherlock

Follow the steps for sliding menu also.

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256
  • I tried this but after adding the library and press ok, and back to check if it work, the green sign becomes a red cross! – Soheil Setayeshi Apr 22 '13 at 12:32
  • if you follow the steps it should work alright. check the last link for snap shots – Raghunandan Apr 22 '13 at 12:34
  • You know , the library and it's example project works perfectly but when want to add it into my project , the run time error and other issues appears. – Soheil Setayeshi Apr 22 '13 at 12:41
  • still the red cross instead of green sign... why? is there anything I should consider in the manifest? – Soheil Setayeshi Apr 22 '13 at 12:50
  • 1
    http://stackoverflow.com/questions/14057367/exact-procedure-to-add-jfeinstein10-slidingmenu-in-android-project. Check this link might help you. Also you may need actionbarsherlock as well – Raghunandan Apr 22 '13 at 12:50
  • Thank you , it fixed with your links and also http://stackoverflow.com/questions/5167273/in-eclipse-unable-to-reference-an-android-library-project-in-another-android-pr The library and project should be in same directory to eclipse let us to add it as a library project. thx again – Soheil Setayeshi Apr 22 '13 at 13:09
2

In addition to Raghunandan, this is what the docs say:

You cannot export the library project to a self-contained JAR file, as you would do for a true library. Instead, you must compile the library indirectly, by referencing the library in the dependent application and building that application.

He is completely right. You cannot use the SlidingMenu as a jar file.

Ahmad
  • 69,608
  • 17
  • 111
  • 137
  • Yes you are right but after adding the library project as a dependent library and press apply/ok , the next time I want to check if it is work, the green sign become a red cross – Soheil Setayeshi Apr 22 '13 at 12:46
  • @Raghunandan thanks :) Also +1 to you, I had almost forgotten, that jars are incompatible, until reading your comment – Ahmad Apr 22 '13 at 12:46
1

May be your jar file is not available at run time ,please check that first in your javabuildpathlet me clear is it a library project or its a jar.

Abhijit Chakra
  • 3,201
  • 37
  • 66