I am trying to include a library into my android project using IntelliJ IDEA v10.0.3. The .jar library is, however, corrupt, so I want to include the bin directory into the project.
What I am doing: I go to File - Project Structure - Modules - Dependencies - Add - Library - New Library. In the dialog that appears, I give the library a name, then click Attach Classes..., then choose the bin directory. I then click ok.
The library appears to be working fine. I get code completion and use the classes as desired. However, when I run the project, I get the following error:
Error! C:[Path-to-library-project]\bin is a directory. Directory libraries are not supported
What can I do to fix this problem?
Make a valid jar from the required classes and use standard jar library. It's Android specific limitation.
Related
I'm trying to use an external jar file in my Android project, I follwed this step for including it:
I put the jar file in libs.
I configured the build path and now I can see the jar file in the Referenced Libraries section of the project.
I use the import to bring the class that I need inside the program.
But I always get NoClassDefFoundError. This jar already works with a classic java program.
Make sure that the jar is being built with the app. In eclipse,
right click on project --> build path --> configure build path.
Make sure the library is checked in the Order and Export tab.
Since Android SDK 17 there is not even necessary to manually add the jar files to buildpath, because they are added automatically, as stated here. Then I would suggest to:
remove the library from buildpath
clean the project
make sure the jar file is located in a folder called libs (not lib) located in the root folder of your project
refresh the project
run the project
The solution found was recompile the library with the version 6 of java and using the jar fail obtained
I tried everything I found posted on Stack Overflow and yet I'm still getting the annoying NoClassDefFoundException when I try to test on the emulator:
I copied the jar to the "libs" directory of the android project
I added the jar to the build path using Add Jar NOT add external jar
I ticked the jar in the export tab
I even tried to compile the jar once with JDK 1.6; still the same annoying exception. The jar I'm referring to just contains a few entity objects I created for another project, and would like to re-use with my Android project.
By the way, I also tried to add the jar as an external jar, but didn't work either.
You need to add it to the assets/ directory along with adding it to build path in that location for it to work. Do remember to pick the same jar when adding external library.
See this thread
NoClassDefFound Error comes in java, when some class is not available on runtime, while it was available at compile time, please check what is source of this error, you can use following blog to get assistance:
http://javarevisited.blogspot.in/2011/06/noclassdeffounderror-exception-in.html
Do the following ::
Go to the project properties >> Java Build Path add jar file as external jar.
Select order and export option >> select the libraries and jars of the project.
If not working change the order of jar make sure its above android dependencies .
I would like to include this plist parser module in my Android application, ideally without just copying the entire module source into my source tree (if that would even work).
I have successfully added the module as a project into Eclipse (3.7.0) and resolved errors by fixing the build path to include Android 2.1, which is what I am using. However, now I'm stuck. All of the information on using external libraries with your Android project I can find expect you to have a JAR of the library, but I only have this source code. I can run the plist parser module as an Android application, which appears to compile an .apk, but that doesn't actually do anything because it's not a standalone application. Any options to just build the module without running it are greyed out in the Eclipse interface.
How can I either build this module into a .jar for inclusion, or include it in some other way?
Edit: In order to clear the errors in the module after I added it to Eclipse, I followed the instructions in this answer.
You can either convert the whole thing to a library project or simply include the source code in your app's project. To create a library project, you can import the project from github, and after you get it compile, remove any activities, go to the project's Properties->Android and check the 'Is a library' check box. Then add it as a dependency to your own project.
I am trying to use phonegap inside an android library project. The library project compiles just fine but when i try to start an activity that extends DroidGap, i get this error
01-02 10:12:17.575: W/dalvikvm(316): Unable to resolve superclass of Lcom/***/***.
I think this is because the phonegap.jar file is not included in the compiled jar file of the android library project. I have tried using ant to build but it doesn't seem to work.
Edit: I am building a android library that can be used in other android projects. I am using the standard android library project but activities in this lib project that extended DroidGap class in phonegap.jar are crashing with the above error.
I´m afraid that is not possible yet. The result jar file will contain all classes and resources defined in the android library project, but will not include external jar files added to the build path. You will have to add those to your final Android Projects using that library. You can also find similar questions in SO like this one
create one folder 'lib' in your project. put your .jar file in lib folder. select your .jar file right clicked on ,select buid path --->'add to build'. will add your .jar file. now you can use this .jar file classes.
I would suggest not making the 'lib' folder manually.
Instead:
Right click Project --> Properties --
Select Java Build Path
Make sure Libraries is the tab selected at the top
Click Add External JARs
Then find your JAR...
Basically, the same way you may have added the PhoneGap.jar
The ADT (Android Development Tool Eclipse plug-in) has built-in support for the creation and reference of library projects. See the example in section 5 of this tutorial.
Try changing the name of the folder to libs instead of lib.
have you added required permission in manifest file..
see the below links
http://docs.phonegap.com/en/1.4.0/guide_getting-started_android_index.md.html
I'm having this problem since I installed the new SDKs. I've read about this happening when I try to link the same class to the build twice.
But here is the peculiar thing about it:
I have an Android library project that includes a class folder on the build path.
I have this library project included in one of my regular Android projects.
I have to include the class folder in this regular project as well to make it build.
This when the error occurs.
But when I do either of the following:
Remove the class folder from the library project: The library project won't build, so the regular project won't either.
Remove the class folder from the regular project: The library project builds, but the regular project won't because it misses the class files (?!).
I seem to be stuck in some unsolvable paradigm here.
Maybe there are build rules to circumvent this?
Any help would be greatly appreciated!
Apparently the way Android library projects are linked has changed.
Before, the library's source folder would be linked to the build path.
With the new solution the library is apparently built to a jar file in its own 'bin' folder.
This is then linked as an external jar to the build path of the project using the library.
To make the conflict dissappear, do two things:
Remove the source folder link in Project properties->Java Build Path->Source
Clean the project. Perhaps clear your projects 'bin' folder manually.
Now it should work again! :)