I'm trying to make use of Actionbar Sherlock 4, targeting sdk 15 and min sdk 8. After following the directions provided on the Usage website and the great videos posted here: http://www.youtube.com/watch?v=avcp6eD_X2k
I'm still encountering a problem. When I try to add android:theme="#style/Theme.Sherlock" to my manifest file , I get the error:
No resource found that matches the given name (at 'theme' with value
'#style/Theme.Sherlock').
I have included the actionbar Sherlock library project into my project, and the import statements are there and not coming up with any errors and I've
extends SherlockActivity implements ActionBar.TabListener
just like in the Demo code and documentation Yet still, eclipse gives me this error. Any ideas out there?
The pitfall I encountered was this: The reference to the ActionBarSherlock project needs to be in the Android->Libraries section of the project properties, while I had been adding it to the Build Path->Libraries.
I encountered a strange anomaly that might help!
Have built android project that uses ABS, running it on Gingerbread works fine, in ICS it crashes, the crash under ICS occurs due to this, check your AndroidManifest.xml (have trimmed out bits for brevity...
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:theme="#style/Theme.Sherlock">
It was the android:theme part that caused the crash under ICS, it worked fine under Gingerbread and older versions!. Solution was to remove it completely! Then from your Activity, do this:
#Override
public void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
this.setTheme(com.actionbarsherlock.R.style.Theme_Sherlock);
}
super.onCreate(savedInstanceState);
... // MORE CODE ....
}
This fixed up the crash under ICS, the theme style is not liked by ICS, but it works fine for both versions less than 2.3 and 4.0 upwards.. weird error but that I discovered by fluke!
Remember to apply the theme before calling the base class's own onCreate!
My standard procedure for including a library project on Eclipse goes like this:
Import library project
Right click on library project Properties -> Android -> Set Project Build Target (insure library and primary project are the same)
Right click on library project Android Tools -> Fix Project Properties
Select the library project then Project -> Clean...
Select primary project then Project -> Clean...
That should fix whatever ails you.
I finally find the solution:
IMPORTANT! Copy the same android-support-v4.jar in both projects: in library and your project (this is the principal problem).
Import "library" project TO YOUR WORKSPACE
Right click on library project Properties -> Android -> Check "Target Name" 4.x (any, API level 14,15 or 16). Bottom check "Is library".
In properties, go to "Java Build Path", tab "Libraries" And find "android-support-v4.jar" normally in "Android Dependencies". Ok and Close Properties.
Right click on library project Android Tools -> Fix Project Properties
in Menu Project -> Clean... and select to clean the "Library" Project.
In this place, your project "library" must to be done (without errors)
Create or import your own project. Example "MyProject"
In properties, go to "Java Build Path", tab "Libraries" And find "android-support-v4.jar" normally in "Android Dependencies".
Now go to "Projects" Tab. Add... and select "library" project.
Now in properties go to Android -> Check "Target Name" 4.x (any, API level 14,15 or 16). IMPORTANT: Must to be the same of "library" project. Bottom "Is Library" must to be UNCHECKED and in this place press Add... And select "library" project. Ok and Close properties.
Right click on "MyProject" project Android Tools -> Fix Project Properties
in Menu Project -> Clean... and select to clean the "MyProject" Project.
Already, your project must to be done. If the error persist, restart Eclipse.
I resolved this issue by the follwoing 2 steps on my projects:
Remove the "library" from "project properties"/build path and add library in "project properties"/Android/Library
Right Click on project "Android Tools" -> "Add support library"
after importing both projects i.e. library and settingActivity,first clean and build them.
Then right click on settingActivity project->properties->select second option from left menu (i.e android).
on right hand side their is library section just click on add library. prper path will automatically comes in that frame.
Thats solve my problem,i got no errors.
Related
I followed every steps in Android - ActionBar to add action bar.
I extend the activity from ActionBarActivity:
public class MainActivity extends ActionBarActivity
I need to add appcompat v7 support library as in here: In "Adding libraries with resources", eclipse section. The last steps:
"Add the library to your application project:
In the Project Explorer, right-click your project and select Properties.
In the Library pane, click Add.
Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
In the properties window, click OK. "
Step 2 is where I can't find the Library pane. How can I add the library to my project?
A picture is worth a thousand words:
Following are the steps:
Paste the android-support-v7-appcompat.jar that you have downloaded in libs folder of your project.
Right click on your project, select Build Path -> Configure build path.
Select Library Tab then Add Jar option and browse your recently added v7 jar and click OK
that's it :)
This is what worked for me:
Eclipse -> Import -> Existing Android Code into workspace.
Add ~/android/adt-bundle-mac-x86_64/sdk/extras/android/support/v7/appcompat to your Eclipse workspace.
Right click on the project in Eclipse and select properties.
Select Android -> Library -> Add.
Select appcompatv7 project and Save.
Use import android.support.v7.app.ActionBar to import Action bar in activities and fragments.
The library pane shows up if you select android first in the left hand list. It should then be at the bottom of the right hand section of the properties window, underneath the Project Build Target section.
This is the the solution I've used to solve that problem.
Make sure that you've installed already the following libraries Android Support Library, Android Support Repository and Google Repository by checking in the Extra folder by openning the Android SDK Manager in eclipse.
Create an Android Sample Project then choose the appcompact_v7 library.
Close the project you've just created, restart Eclipse and create now a new Android Application project.
Hope that it will help you.
In may case this works:
In "android-support-v7-appcompat" project:
-Delete “android-support-v7-appcompat” from Package explorer.
-Import again and check “Copy into workspace”
-In Properties -> Android -> in Project build target, uncheck Android 2.2 and check Android 4.1.2
-In Java build path, uncheck if you have any .jar library, and uncheck the Dependence
In other hand, the project that uses “android-support-v7-appcompat”
in Properties -> Android add the library, but uncheck "IsLibrary”.
-In Android -> Project build target check Android 4.0.
-In "Java Build Path" -> Order and Export -> Unchecked the .jar library
-Finally do a “Project -> Clean” both projects
following the latest(2014/5/19) document, the second step is:
In the category panel on the left side of the dialog, select Android.
then, you will see the library pane on the right side of the dialog.
Try this
Open SDK Manager
Install Android support Repository
Go to F:--\Android Setup\android-sdk-21 version\extras\android\support\v7\appcompat\libs
Copy android-support-v7-appcompat.jar
Paste this .jar in Your's Project Lib Folder
Set and change AndroidManifest.xml
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="23" />
i've been trying to run a project but there's a pop up window that says "Android library projects cannot be launched."
Now, my project needs API 7 and i've already installed it in Android SDK Manager.
In Properties -> Android -> Target build, i choose Android 4.1.2. I also added these lines to the Android Manifest:
<uses-sdk android:minSdkVersion="7"
android:targetSdkVersion="7"
android:maxSdkVersion="16"/>
yet, when i run my project, the same pop up message shows.
Anyone, please help me. Thanks!
Your project surely is configured as "library" thats why you get the message : "Android library projects cannot be launched."
right-click in your project and select Properties.
In the Properties window -> "Android" -> uncheck the option "is Library" and apply -> Click "ok" to close the properties window.
the naive and somewhat literal interpretation of the message would be that your project IS a library project; and indeed, they cannot be launched, only embedded in some main project.
Did you double check that your project is NOT a library project? There used to be a checkbox in the "create new android project" wizard...
I am trying to use jfeinstein10 / SlidingMenu http://goo.gl/PEZ9M in my android application.First I have added library project of Sliding Menu, then I added ActionBarSherlock too.Sliding Menu library is dependent to ActionBarSherlock.
Also my app is dependent to SlidingMenu app.
My question is that when I add a library project as a dependency to my main project, the R file of the main project disappears and all my R references in main project cannot be resolved.
does anyone know that R file disappearance issue after adding a library project as a dependency?
Use the Project Properties and clicking on the Android section, change the Project Build Target to Android 4.0.3 (API 15). Clean the project after changing the API Level.
Ok I just struggled through this issue for quite some time now I finally resolved it here are the steps I took.
First of all I updated the android SDK for eclipse to the latest version.
Then I updated eclipse itself by going to Help --> Check for updates
next downloaded the latest version of SlidingMenu and ActionBarSherlock and unzipped them to a folder
Then in eclipse import ActionBarSherlock by creating "New Android Project from existing source" and selecting the "library" folder in the unzipped directory
Repeat the above step for SlidingMenu
Very important at this point to make sure you don't have any errors in your both imported library projects
If you have errors in the ActionBarSherlock then right click the project goto "Android Tools" --> "Add Support libraries". This should resolve any issues you have if not then goto project --> clean and clean up the project
The sliding menu will have a target of 2.2 or 2.1 by default (sorry cant remember which one...its really late and my head feels foggy :z)
Right click on the SlidingMenu project and select properties in the window that opens select target build of Google APIs 4.0.3 select ok and do a CTRL + SHIFT + O and any issues or warnings you had should go away.
With that out of the way then once again right click on the SlidingMenu project and select properties. In the window under Android scroll all the way down and add reference to the ActionBarSherlock library. Also make sure the "Is Library" checkbox is checked. Apply and ok.
Next you have to do the same for your project. Right click on it --> Properties under Android Scroll all the way down and add SlidingMenu as a library. Make sure the "Is Library" checkbox is NOT checked.
At this point I encountered Dependency errors. The problem is that in your projects "libs: folder you will have the files: "android-support-v13.jar" and "android-support-v4.jar" causing a conflict.
What I did was delete the v4 and copy pasted the v13.jar file into the libs folder of all 3 projects, my project, SlidingMeny and ActionBarSherlock.
This resolved the above issue and it worked!
Hope this helps someone so they can go to sleep at sane hours of the night! :)
I just ran into this problem and I didn't need to change my build target. What I had to do it make sure my app and any library that implemented the support Library was using the same support Library version. The easiest way to do this:
Right click on each project and library that is in question and select Android Tools -> Add Support Library... *
I am having problems getting start with the ActionBarSherlock. I downloaded the 4.1.0 version and followed the following tutorial for installing it.
http://www.youtube.com/watch?v=4GJ6yY1lNNY
The Problem I am facing is whenever I make a new project and add the library project of ActionbarSherlock to it. I get the following error.
Description Resource Path Location Type
The container 'Android Dependencies' references non existing library 'C:\Work\JakeWharton-ActionBarSherlock-4.1.0-0-g9598f2b\JakeWharton-ActionBarSherlock-88fc341\library\bin\com_actionbarsherlock.jar' myapp Build path Build Path Problem
Please anybody help me with it.
I just had the same problem: A .jar file is requested, but non-existing. Also, it is okay that the file doesn't exist, because we want to use a Android-Library Project and not an included jar-library.
The steps described by Aqif Hamid are perfectly fine, if the missing import (.jar or library project) would be the root of the problem. But i figured out that the reason for this error is that you have to set both projects (AndroidBar Sherlock and your own Android project) to Java Compliance Level 1.6
To do so go into Project Properties => Java Compiler and set the level to 1.6
Of course, you have to install JDK 1.6 on your computer...
Hope this helps you too!
The only thing that it works for me was selecting at Properties at Java Compiler Tab Compilance Level --> 1.7 (It was 1.6).
After that Android Tools, Fix Project Properties
DO the followings:
just like you have bin, res folders. right click on your project and
add a folder named 'libs' (if libs folder is not already there).
Then copy paste your com_actionbarsherlock.jar file in this libs folder.
Right-click on your com_actionbarsherlock.jar file and click Add to Build Path.
Now clean and build your project. You should be good to go.
Edit:
To add project as a library do this:
Make sure you have your library project in your projects list and it
is open.
Right click on your project in which you want to add your library
project and select Porperties.
Click Android in properties windows, now scroll down, you will see
library section at the bottom. There press Add button.
Now a window will open in which you will see list of library
porjects. Select your required project and press Ok. Now that library
project must be there with a green tick mark.
Press Apply and Ok button.
You should be good to go now.
regards,
Aqif Hamid
I am of the understanding that you cannot include ActionBarSherlock into your project by adding a jar to your lib directory (or just including the jar at all). You will have to create an android project for ActionBarSherlock then link to it as a library:
Create ActionBarSherlock project in Eclipse
Right-click your project and go to Properties
Select Android in the left pane
Then in the right pane, towards the bottom you can Add... the ActionBarSherlock project you created in step 1.
If you are curious why the jar approach doesn't work, I give you Jake's reply in this thread
(although that's a month and a half old at this point).
1 - create a libs folder (parallel to manifest) and put the jar in that
Your Project -> right click -> Properties -> Java Build Path -> Libraries -> Add Jar ->
yourjar.jar
This video might be useful in case you are having some issues.
http://mobile.tutsplus.com/tutorials/android/jar-for-android/
Clean your actionbarsherlock project. It will generate the .jar file for you when it re-builds.
Using the Android Tools option to Add compatible libraries fixed the problem for me.
Hi i have the project developed in eclipse environment is working fine, and i want to use that project as resource or add as jar file to another project.if possible can please let me know how to do this one. will help lot for me.
You can do it via Android Library project.
Refer this LINK.
Describes how to set up a project as a library project. Quoted from its content
================= quoted =================== Next, set the project's Properties to indicate that it is a library project:
1) In the Package Explorer, right-click the library project and select Properties.
2) In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
3) Select the "is Library" checkbox and click Apply.
4) Click OK to close the Properties window.
=============== unquoted =============================
So, you open your project properties and "unselect" "is Library" checkbox and click Apply to make your project a normal Android project (not a library project).
In theory you can as #Agarwal described.
however the adt-tools are not ready to do it yet
My last failed try was adt-tools version R17 documented at how-to-consume-reusable-gui-element-widget-with-resources-in-android
According to user #CommonsWare R18 and R19 still cannot do it (see comment in replace-android-library-project-by-jar-library )