I am using SVN in Eclipse. I opened an android project and it shows errors. It says some jar files are missing. Initially I developed this project in ubuntu and now I am opening this in windows. So those jar files are referring from ubuntu file path. I have attached a screen shot as well.
I am using actionbar sherlock library and though I added it correctly it gives that error.(android support v4) , because it is referring from ubuntu file path. How to fix this errors?
Thanks.
You may take these support libraries from appcompat libs folder and copy those into your project libs folder and then Add To Build Path by right click and going to add to build path. This will do the trick. Similarly you can took the neede jar files and copy those into your project
Related
I am developing a native android application and using an open source library with .so file generated. Facing a strange behavior.
For the first few times, the application worked perfectly well, with the library getting loaded. But now its not able to find the library and gives -
java.lang.UnsatisfiedLinkError: Couldn't load : findLibrary
returned null
.Below are few observations: 1. when I extract the .apk file, the library (.so) is present under "lib/armeabi" folder. 2. but when I try to search the library (.so) into the devices extracted path of
/data/data//lib/
, its not present. Any suggestions as to why this strange behavior is happening and why the .so file is not getting extracted under /data/data/com.ibm.homeScreen/lib/ folder.
Thanks in advance!
If you use eclipse, check the buildpath settings:
Right click on your project --> Properties --> JavaBuildPath --> Order and Export (is a Tab) and check there if the librar has been marked (checkbox) to export.
There is also a possibility to set the native library path. You can find that option in the Library Tab --> Android Private Libraries --> EDIT Button on the right
This could also help
For eclipse project, simply put all your *.so files inside armeabi or armeabi-v7a folder, and put the folder inside /libs folder in your project. Compile, the *.so files will automatically be imported into /data/data//lib
For Android studio, the above approach didn't work for me. instead I have to place the armeabi and armeabi-v7a folders into /jniLibs instead of /libs. Note that I am using Gradle 0.10.+ though, not sure if it works on older Gradle.
You can find some further information about this problem here:
Why do some Android phones cause our app to throw an java.lang.UnsatisfiedLinkError?
https://code.google.com/p/android/issues/detail?id=59420
The stackoverflow link also contains some code with a workaround in the (currently) last answer.
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
I am working on an app which uses Commonslang.jar libraries. I was trying to setup it on a new system with newly installed Eclipse.The project is not showing any error But when I run the project it force closes with NoClassDefFoundError at each point where I use Commonslang lib.
I dont know how to fix this problem.Please help?
I think there are "lib" folder in your project directory so just change it "libs" instead of "lib" and clean project and check it..
> Note: No need to build path for any third party library
You need to create libs folder in your project and copy that jar file there. Then in eclipse, right-click on that jar file (which is in libs folder) select Build Path and then select Add to Build Path.
Remember: if you are using a jar file in your Android Library Project, and associating that library project with your regular UI
project, it won't be enough. You must need to include that jar file
(as described above) in both of your projects (Android Library and UI
project) to make it work.
Have you added the jar to the Java Build Path?
Go to the Properties for the Project and select Java Build Path -> Libraries tab then add the external jar there.
I have made an android project in eclipse. This project has a library project:
the library project (marked with "is library") has included a jar file.
this library project does a lot of stuff with the use of the jar file.
in code everything is fine.
The problem is that the reference to the jar file doesn't exist anymore when it is compiled and installed to my phone.
When i add the jarfile also to my base project. Then the program works.
However, i don't believe that this is the right solution.
So what does i do wrong?
You should add a libs folder to your project
Then, add the jar to the folder and right click on the .jar file and go to Build Path, and select Add To Path or Build To Path. This way the library will be a part of your project. This should help.
The library jar you used in your Android Library Project must be manually added to the dependent application project's build path, not the Android library project build path itself, check out API here