I am having issues getting my project that references an Android Library to compile. I have exactly followed the instructions in the documentation here: http://developer.android.com/tools/projects/projects-eclipse.html
My android library is is marked as a library correctly, and I can see the jar file and all my .class files in my project. But the classes are not found when I try to reference them in my new project and it will not compile. What am I doing wrong?
Here is a screenshot (SoundGraphingLibrary is my library project and SoundGraphingLibrary is the project I need to use the library in):
Make sure that the project and the library project are in the same folder..
First, run Project->Clean on the library, then your project as #iagreen suggests. Then go ahead and close and reopen eclipse. Wait for everything to build.
Assuming nothing is better at this point, click on the library and do Project->Properties->Android. Confirm that Is Library is checked. Now, delete any instance of the library *.jar in your project. Do Project->Properties->Android on your project. Click Add... and click on the library you want, OK, Apply, OK.
That should do it. Also, fire lemurs.
Not sure if this helps but i did the following
Remove and adding the library by going to Project->Properties->Android.
Clear the project by going to Project->Clean
Restart Eclipse and tata it works.
Related
I'm trying to get ActionBarSherlock and the ViewPagerIndicator libraries set up for my projects, but I seem to be running into a few issues. I sent Jake Wharton (The developer) a few messages earlier about it, and got a few replies but couldn't get anywhere - and I think he got busy with a few other things.
What my issue is, For both VPI and ABS
Both libraries open up without any errors, and I'm using compiler version 1.6 for all as is required.
The funny thing is, if I load in the samples that are provided - they work fine and link to his library; but when I go to add the library to my project - the above happens.
Where to store the actual library project does not matter, as long as you use a relative link to reference it. Check out the Library Projects - Development considerations:
Library project storage location
There are no specific requirements on where you should store a library project, relative to a dependent application project, as long as the application project can reference the library project by a relative link. What is important is that the main project can reference the library project through a relative link.
You should always use the Eclipse ADT plugin to select and set up Library Project Reference, i.e. right-click project -> Properties -> Android -> Add, then in the opened Project Selection window, select the Library Project list here (of cause you should import them in the same Eclipse workspace as your Main Project). This will add a android.library.reference using relative path into project.properties as well as show relative path in the Android preference window:
android.library.reference.2=../../../../../Documents and Settings/yorkw/Desktop/JakeWharton-Android-ViewPagerIndicator-f09acb0/library
If you directly alter it using absolute path from project.properties as below:
android.library.reference.1=C:\\Documents and Settings\\yorkw\\Desktop\\JakeWharton-Android-ViewPagerIndicator-f09acb0\\library
Then after Eclipse refresh your project, you get the exact error described in your question, see my screenshot below:
Hope this helps.
While importing the libraries, make sure that you tick the "Copy projects int workspace" check box. The library projects need to be in the same workspace for them to work.
delete and import the project and lib again. build the lib project , add lib to project, still error shows.. rename the lib project. this worked for me ....
I am working with Android API 17 on eclipse Indigo. I have cloned the faccebook sdk from github and done the facebook library project set up using the source project provided in the fb sdk.
Now I'm trying to include this library project in my android demo project. I have added it under Project properties->Android->Library section. Im seeing green color tick mark infront of the added library.
Also, i have added the same in the Project properties->Java build path->Projects.
build is successful. but when i try to install on my AVD, im getting the error, E/AndroidRuntime(748): java.lang.NoClassDefFoundError: com.facebook.android.Facebook
Can anybody plz help me how to fix this issue.
---- EDIT ------
One more thing I have observed is, when i opened Project properties->Android window, the green tick mark is not displaying under Library section, instead I'm seeing red cross mark.
Any ideas?
Thanks,
Venkat Papana
Same thing happen for me also.. try below .. it will work..
A Best way to add External Jars to your Android Project or any Java project is:
Create a folder called libs into you project root folder
Copy your Jar files to the libs folder
Now right click on the Jar file and then select Build Path > Add to Build Path, this will create a folder called Refrenced Library into you project, and your are done
By do doing like this, whenever you transfer you project to other Computer, you will not miss your libraries which are being referenced to some space on your Hard drive.
(The facebooksdk.jar can be found at the facebook-sdk directory: <facebook-sdk>\facebook\bin)
i know this question is old But I thought that may be it can help someone.
Move the library project and the application on the same drive. Usually this is a bug in Eclipse.
I solved my problem by moving them in same drive on my computer.
You can Give it a try.
You need to make both project in same dictionary then include it using Project Properties -> Android-> Library.
This works fine.
You do not have to add this to the library project as this is not the library.
https://github.com/facebook/facebook-android-sdk is the help of the project ad the sample code for the including the project in our code. Just you need to create the app ID for the facebook by registering your api with it.
Hope this will help you in your project.
Resolved by copying the com.facebook.android source code to my project source.
I am using Eclipse to develop Android apps. I am importing one example to the Eclipse Workspace. But I am not able to run that project as it does not load the Android library to that project.
Please see this screen shot:
In SlidingDrawer there is Android 2.2 library is added but in SlidingDrawer_Original i am not able to load the android library.
I have cleaned the project and also built the workspace but still the problem is not solved.
if I open the Java file from the SlidingDrawer_Original then it seems like below image:
So What should I have to do to load the Android Library ?
Right click Project properties >Select Android > Select your target AVD
There will be a file called .classpath , just check the Attribute of this file, It must be in read only mode, Change it to Archive Mode and the Clean the Project and set Proper Project Build and try again.
I dont know why it is Happen, But as i come to know, Eclipse always required its properties file. In Some Eclipse it is named as default.properties and in some eclipse it is as project.properties.
I have simply copy paste the default.Properties file and put it in to that project.
Then create the copy of that project in the same Workspace and remove the previous one project.
It solve my Issue. Hope it will also helpful to you.
Enjoy. :)
I'm creating a new app and I want to use some libraries like this:
https://github.com/JakeWharton/Android-ViewPagerIndicator
I had downloaded this library, added it to my workspace using New Android Project -> Create from existig source.
Went to properties > android, and checked Is Library.
Then I went to properties > android in my app project, and clicked add on the Libraries section, and chose the library, and It show me the library with a green V near it.
I've clicked ok, but couldn't use the library so I've opened the properties > android again, and there was a red cross near the library, and '?' under the "Project" column.
I can't understand why it's happening! It's really annoying, happened to me when I tried to add facebook API to my app, and I just gave up and copied the source to my project.
Thanks, Elad!
Copy every Library manually inside Eclipse Workspace, before importing it, as Eclipse seems to be silly if the Library lays somewhere else. Also symlinking a Library will not work.
For me, I just restart the eclipse and the added library works fine.
I mean first time it showing red marks after adding the library project.
Though eclipse main project and library project are in same workspace folder and no resources files are in outside of the project folder.
So, you can try with to restart your eclipse. Happy coding....
As I was writing up this question I managed to solve it so repeat it here for the benefit of others. Here is the initial problem:
I have created a very simple library project which I want to reference in another project. I have done this previously with no problems so not really sure why it is not working this time. I have:
Flagged the library project via project properties. The default.properties file has this set : android.library=true
In my other project added reference to my library project via project properties. The default.properties file has the reference added as expected ie android.library.reference.1=K:/android_test_ws/applicationRegistrar
The green tick against the referenced library project starts off green and then changes to a red cross.
This implies that there must be something wrong / missing from the library project but I don't know what. My library project on this occasion is MUCH simpler than the previous one I created.
OK Here is the solution which I found when I was looking for the default.properies file of the referencing project (not the library) in my file system. Although the referencing project was in the same eclipse workspace as the library project, the actual files were somewhere else in the file system ie they were'nt in the same parent folder of the library project. As soon as I placed the referencing project in the same physical folder as the library project it all went fine.
I guess that this must be something to do with android using ant underneath the covers.
Edit: The project name needs match the folder name on the file system. What you are seeing in the Project Properties->Android->Library Reference is a relative file system path.
Make Sure both the projects are present in same work space.
To Do it, while importing the projects make sure "copy project into work space" check box is checked.
the same problem will occur if your library project is in different partition from your current workspace. I have the same problem just now. My git source is in C: and I just move my workspace to D: and everything start to collapse.
Simplest way to get the library paths paths correct is to use the GUI from Eclipse to add the library as shown in the following screenshot and let Eclipse take care of putting the correct relative paths in project.properties. Its a common setup to have your library projects hosted at directories vastly different than your main projects that uses the library. This method will work if the "libary project" and the project using it are in the same eclipse "workspace" (they "need not" be in same parent folder):
Please ensure that the library project is marked as "Is Library" - right click on the library project - properties - Android - mark the "Is Library" checkbox - in project.properties of the library project you should have a new entry:"android.library=true. Now add it into the project you want as described in the post below.(the post with image integrated - from Nilesh Pawar).
This bug is referenced several times here 27199, 35786, 36460 & 38052
Maybe by voting for them, it will be fixed one day...
Yet another observation on the same issue.
For me the two projects where on the same parent folder, and were both local inside the workspace. Even then the issue was still happening.
The I edited the "project.properties" file and put the absolute path(with forward slashes '/' for seperator) of the library project. Saved and closed it. Then went to the project properties dialog, removed the library(which was still showing the cross icon but with abs path) and added it back as usual.
Surprisingly the issue is resolved, and the project compiles and runs.
This is really strange and must be a bug with the ADT.
I am using ADT version 20.0.2
when developer referencing the facebook or any other library project then first of all clean the project from eclipse->project->clean project.
that want allow the error of red cross in referencing screen.
For me, I just restart the eclipse and the added library works fine.
I mean first time it showing red marks after adding the library project.
Though eclipse main project and library project are in same workspace folder and no resources files are in outside of the project folder.
So, you can try with to restart your eclipse. Happy coding....
Workaround for me was to
Create a new workspace
Import Library Project in that workspace
Import The desired project in that workspace
Having both project and library project the same target Android OS version
Reference library project in my project
solved my problem
i had the same problem there when i try to change my workspace so this my solution:
import and copy all project data including library project into workspace
delete the old project reference by Right-click on the project-->Properties-->Android-->Library, and select corrupted library(so that waht i call it) and choose Remove
clean project first (to refresh ur project properties)
go to library project Properties-->Android-->Library and check the is library if it does'nt click Apply then OK
if the library project is library is already checked, first Unchecked it then Clean the library project after that do the Step 4 again
go to project that u want the library are in then Right-click on the project-->Properties-->Android-->Library, Add then choose the library project (it should be there) and click Apply then OK
if still doesn't appear clean the project once more time and that should do
Just restart your eclipse. It's solve my problem
When you have a look at the reference-path before and after, it comes from i.e. "C:/workspace/mylib" and goes to "../../mylib" when copied to the correct location, quite interesting.
FYI,
What worked for me was to delete the 'library' projects (the actual projects) from my workspace (without deleting the files), and then re-importing them using the wizard (import existing android project from source code).
Thanks for posting the question.
I had exactly the same problem while integrating Facebook with my Android application. I fixed the issue by moving my development project to the same Windows drive in which library project was located. Somehow Eclipse is unable to read the library project's location properly from default.properties file if it is in a different drive.
Similar to Sufi Khan's post I also solved this issue with a reboot. My case differed in that when I first accessed Properties->Android and added the library I got a lovely green checkmark. When I closed the dialog Eclipse was still showing class-not-found type errors. When I checked the properties again I saw the red X. But Mr. Kahn's solution (delete the bad lib, restart Eclipse, add the lib again) worked fine.
I'm using the 0702 version of the ADT bundle (starts with "cluster", rhymes with "duck").
I followed the accepted answer but also had to make sure my "project.properties" file was readable.
If the file is readonly (checked into source control) eclipse will not edit it. Adding the library reference will succeed, but the change won't be persisted after hitting OK.
If closing the preferences window and reopening in again removes the library you just added, this may be your solution.
In case your library project still doesn't show up try adding library flag in your library project properties
Add android.library=true
project.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library=true