I am using a library to animate ListView. As is the procedure, I added the .jar file to the lib directory. What this library also needs is another library to work named NineOldAndroids. I downloaded that .zip file, too.
The 9OldAndroids library is a project folder. So, I imported that in Eclipse, added that to my build path. Eclipse shows the packages from 9OldAndroids:
However, I get an exception when running the app on my phone:
08-08 19:36:13.050: E/dalvikvm(27827): Could not find class 'com.nineoldandroids.animation.Animator[]', referenced from method com.haarman.listviewanimations.swinginadapters.prepared.AlphaInAnimationAdapter.getAnimators
How do I solve this?
NineOldAndroids is an Android library project. You need to attach that Android library project to your main app's project. Whatever you did when you "added that to [your] build path" is probably not the right answer.
Related
I need to import this library project into my eclipse. While i am trying to use this project it have some error. Can you help me on this. https://github.com/daimajia/AndroidImageSlider
That project is created for use with Gradle for Android. Eclipse does not support that yet. It is also distributed as an AAR, which Eclipse does not support. There are recipes for converting AARs into Eclipse-friendly Android library projects that you can try. Otherwise, you will need to reorganize the project code yourself to support the classic Eclipse-style project structure. Mostly, that will involve moving the contents of library/src/main/ into a regular Eclipse Android library project:
The res/ directory and AndroidManifest.xml file would go in the library project root directory
The java/ directory would be renamed src/ and also go in the library project directory
However, you will have to repeat this process each and every time the library's author updates the library, at least for those updates that you are interested in.
You may wish to see if there is an alternative library that meets your needs but is better packaged for use with Eclipse.
Basically there are some changes to be done to eclipse project before importing it to eclipse like src folder.
The project you posted may contains many error since it have two more android project dependency.
I tired to convert above project with its dependency :
Checkout Complete Source Code
There is one more project lib u need to add LIB
I'm very confused about adding external .jar files to my project.
I downloaded https://github.com/chrisbanes/Android-PullToRefresh library project.
After importing it to Eclipse, I cleaned & built it.
After that, in the bin/ folder of the library project, there is a .jar file.
Next I copied this .jar file to the /libs directory of my project from which I want to reference it.
As far as I understood, from now on there is no need to keep the library project in my workspace, because i added the .jar file to my project.
Picture of the projects tree:
https://www.dropbox.com/s/7w4tzis8v1vv4aj/jarProblem.png
When I'm running the referencing project with the library project open : no issues.
As soon as i close the library project: NullPointerException <- seems not to find the library.
I already tried every possible combination of build path configuration but I can't get my main project to be built with the pulltorefresh project closed.
I thought it was the sense of a .jar file to distribute a library without having to attach the source files.
It should work the same as the android-support-v4.jar ... for which i don't have the source code either.
What am I missing here ? Thank you.
There's a difference between a jar file and a library project.
Jar files can contain only code, no android resources. These just need to be placed in your libs folder and linked in.
Library projects can contain Android resources. They need to be compiled as Android libraries in Eclipse, and kept around as their own project. You then tell your main project that it references this one. Its necessary to keep the library project around because it needs to build the /gen files from it for your resources to be right. It also needs to be able to grab the contents of its assets folder.
Given that this library has a res folder, its an Android library project and can not be used as a simple jar.
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
As the topic indicates I would like to create a jar library that uses some android functions (no layouts) and that will be included in an Android project.
Is that possible and how?
From the research I've made I managed to include a simple jar file that uses pure Java (JAVA SE 1.6), but
when I tried creating a jar file I encountered the following exception when I tried to run the Andoid app: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: mylib.pleasework.amen
I tried including android.jar in my library and removing the java library, so that the jar file is build against android sdk, but it didn't work.
I tried including the jar file under a /libs folder as it is said to be the correct way to import jars in android projects from ADT v17 and after, but that didn't work either.
The jar I want to create will not use any resources (xml layouts, strings.xml) just Log.d and WifiManager.I am aware of Android Library Project but my library source is sensitive and I am afraid that it won't be safe if exposed in a Android library project. I was thinking of creating a jar and using ProGuard ( http://developer.android.com/tools/help/proguard.html ) obfuscate it.
I think I mentioned everything. Any help will be appreciated.
Thanks,
Thomas
As the topic indicates I would like to create a jar library that uses some android functions (no layouts) and that will be included in an Android project. Is that possible and how?
Use the jar command, or the <jar> Ant task. I am sure that there are ways to export a JAR from Eclipse, but I personally have never used them.
For example, in this GitHub repo I have a reusable component and a sub-project that is a sample app. My build.xml for the repo contains the following custom task:
<target name="jar" depends="debug">
<jar
destfile="bin/CWAC-WakefulIntentService.jar"
basedir="bin/classes"
/>
</target>
This generates a JAR file, that other Android applications can use by adding to their libs/ directories.
I am aware of Android Library Project but my library source is sensitive and I am afraid that it won't be safe if exposed in a Android library project.
It won't be safe exposed as a JAR, then, either. You can create an Android library project for public consumption that replaces the src/ tree's contents with a compiled JAR in libs/ in the library.
The way I did it in the end was: to create an Android Library project (check isLibrary checkbox in project properties) export it through Eclipse (right click on the project->export->jar file, careful to deselect all resources - res folder, androidmanifest.xml, *.png etc) and put it in the project you want by importing it under /libs folder. I don't know if this is the best solution but it worked for me.Used ADT r20, Eclipse 3.7.1, Android api level 7
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