I have a problem with actionbarsherlock that it drives me crazy!
I have a new workspace, I imported my project and the library projects. There is also actionbarsherlock library project.
My project doesn't generate R file, I suppose because there isn't actionbarsherlock in library path.
image 1
I import the library project and fix the path...
image 2
I clean project but if I return to project properties in the android section I SHOW LIKE IMAGE 1!!!!! It seems like eclipse doesn't save project's changes..
I try:
Change project Build Target to 4.2.2 (In my project and in actionbarsherlock).
Change in java compiler the 1.6 java compiler compliance level (checked "enable project specific settings").
Change in manifest.xml android:minSdkVersion="8".
Add android support libraries.
Refresh & clean projects...
What am I doing wrong?????
I post 2 other images and the eclipse problems..
image 3: my project
image 4: actionbarsherlock project: I change android 4.3 to 4.2.2 after screen capture..
Eclipse problems
Error retrieving parent for item: No resource found that matches the given name '#style/Theme.Sherlock'.
Cannot cast from Activity to MainActivity.
Error retrieving parent for item: No resource found that matches the given name '#style/Widget.Sherlock.ActionBar.Solid'.
Menu cannot be resolved to a type.
etc etc...
Thak you very much.
Actually you have only one problem. ie, ABS library import. If it is fixed, second problem will vanish.
The problem is your library location(you fade out it in pics;)). Try this,
1.Delete the library from project explorer(be careful, don't delete original files from disc).
2.Go to your original workspace folder and make sure that the library ABS(actionbar sherlock) is out of all other folders( the folder
contains only that library). If not, cut&past it out( or you can paste
it inside your project folder).
3.Import the library from new location.
Now, add the library to your project and see if the problem resolved.
After some time, to fix them I did some things:
Delete all my project in eclipse (not from disk).
Close eclipse.
New Workspace (3rd).
change directory of actionbarsherlock and my project
import in eclipse all actionbarlibrary (with sample project, actionbarsherlock-i18n, etc..).
import my project
fix library
close another time eclipse
now it seems to work...
Thanks to all for your answers.
Related
I want to be able to use the action bar in my android project (2.3), so I am trying to import the actionbarsherlock library. However, I am having problems....
I've imported the library, edited the build path of my android project to include the library, and also deleted the android-support-v4 jar from the ABS /libs directory and copied my project's android-support-v4 into the ABS /libs directory to solve the jar mismatch. However, now that I've done all those things, my project can't resolve myproject.R anywhere. I import myproject.R in almost all of my .java files, and they all have the same error ("The import com.myproject.R cannot be resolved"). In addition, when I clean my project, I get a lot of errors in the console window:
They all go along the lines of:
error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.
To my knowledge, R is where all of the layout information is stored, so I have no idea why this is even a problem...
I've been working on this error for days, and I'm extremely frustrated and finally decided to take it to stack overflow. Thanks guys for the help!
ActionBarSherlock is a library project.
So import the library project in your eclipse
Its a library project. To check Right Click on your library project. goto Properties.
Choose android. You will see a Is Library checked as shown in the below pic.
Add your library project to your Android project.
Right click on your Android project. Goto Properties . Choose android . Click add button add the library to your project. You can see a green tick in the below pic.
Make sure you have one copy of andorid-suuport-v4.jar in your libs folder.
Do not import R.*;
You will see two R.java one for the library project and one for your android project.
Clean and build.
edited the build path of my android project to include the library
Never manually modify the build path of an Android project.
ActionBarSherlock is an Android library project. You need to add a reference to ActionBarSherlock's library project from your main application project and undo the manual change to the build path.
UPDATE
The second half of your problem was that your build target was set too low. The build target controls what version of the Android classes, resources, etc. is available to your app, and if you use ActionBarSherlock, you need this to be API Level 14 or higher.
if I make my project build target 4.0, can I still run it on an emulator/phone running Android 2.3?
Yes. Set your android:minSdkVersion to be 10 or lower. Eclipse (via Lint) will yell at you if you accidentally try using classes, methods, and such that are higher than your minSdkVersion, even though they are legal due to your build target.
I found that
if minSDKVersion in AndroidManifest.xml of the Project is lower than library,
it also make the Project to be error to build R.java
I'm developing an app currently which shall use ActionBarSherlock and HoloEverywhere however whenever I try to import the HoloEverywhere library into eclipse I get the following error:
Build path contains duplicate entry: 'src' in project 'library'
I have checked the library folder and there is no duplicate in it but it still complains.
Thank you in advance.
This is how mine solved:
property->resource->Android, tick an Android build target then click OK
Had the same issue,
try this:
Just import it with the duplicate src error, then right click on the HoloeEverywhere library project and select properties. In properties select Android (on the left) and under Project Build Target check if the Target Name Android 4.2 (or whatever yours is) is checked. Mine wasn't. If you check it, it should fix the problem.
Both projects "HoloEverywhere" and "ActionBarSherlock" has name "library". So, you probably should rename them. Then import both projects (ignore HoloEverywhere error). Choose "Android option" in "HoloEverywhere" project properties. Remove all bad references and add new reference to "ActionBarSherlock" project library.
To fix this you have to right click on the project name on the left hand side and choose properties, then choose Android and add a tick to the Build target e.g Android 4.0, don't forget to apply and click ok afterwards.
Right Click on the HoloEverywhere project, go to Android, in the Library section, removes the selected and them select the ActionBarSherlock library that already is in your workspace.
No obvious duplications in path and after hours of trying various suggestions, I change the target (in both the project properties and manifest) from 15 to 17 to solve this issue.
To fix it, open .classpath file in your project home directory and comment out any one of the following two lines
< classpathentrykind="src"path="onePath"/>
< classpathentrykind="src"path="anotherpath"/>
here one and another Paths are the paths that are referencing your library.
Then, right click the Project->Android Tools-> Fix Project Properties. Then clean and build your project.
I am trying to run a project but there is a red exclamation mark over the project name. When checked in Problems, its throwing an error "project is missing required library". The library is pointed to android.jar located in some path. When checked in package explorer, I found the android.jar in Android 2.3.1 folder structure of project in package explorer. The android.jar located in Android 2.3.1 folder is pointing to some other path. Is the build error occurring due to the difference in paths for android.jar files? I have imported the project.So, how should I modify the path which is shown in the problems window? I am newbie to android and so pls help me.
Thanks!!!
The easiest way to resolve this common problem is to re-associate your project with an SDK version. You do this by opening project properties, clicking on Android, select a different SDK version to that which is currently selected (if one is selected at all), click okay, and then repeat the process to switch back to the desired SDK version, if desired.
I tried Phillip's answer and it didn't work in my case. Another place to look is opening project properties and clicking on "Java Build Path" -- if your project used some external JARs, check to make sure the links haven't been broken. If they have, reimport them again and remove the missing ones.
Import your library through the option: File/ Import... / Android / Existing Android Code Into Workspace, and not by creating a New Project and referencing the other (if you did this way).
I had this same problem and solved that way. As example, there is a PDF which demonstrates how to import other projects [Look at the page 28] (The material are in Portuguese)
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 ....
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