Importing ActionBarSherlock - android - android

I am new to Android, and I am setting up a project which needs ActionBarSherlock. I imported the last one as module inside my project so that the error warning import com.actionbarsherlock.app.ActionBar; which was entirely red, is now getting red only on ActionBar. How can I manage this ? Do I have to put ActionBarSherlock in my project lib folder rather than imported it as a module

So you have ABS library module in hand. Now, I'll tell from starting
Start a new project. Make compile with latest (jelly bean) and Theme as None.
In project explorer, navigate to libs folder and delete supportv4 jar file.
Now, include your ABS library following properties-->Android-->library
finally, change theme as,
< application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >

a priori, I manage to do the trick, by importing ActionBarSherlock as module. Then, I stll got an error upon ActionBar in com.actionbarsherlock.app.ActionBar. In my code, I edited the help warning popup box showing optimizing imports and adding as dependecy module , and clicked on the latest, and it worked fine

Go to file-->import-->Android-existing code into workplace, Then select ActionBarSherlock's Library, After importing go to the properties of the project in which you wanna add actionBar.
Do this by right clicking on your project in package explorer -->properties--> under Android click add in the library section and choose the actionBarsherlock lilbrary listed there.
EDIT:
I would suggest you look here. Make sure that you have checked is library option. But what I think initially is that the library is added perfectly since its now recognising com.actionbarsherlock.app package. One common bug is that actionbarsherlock and your project both contains the android support package library, try deleting the android support library from your project since your project should be using the support library from actionbarsherlock. Remember to backup your code.
EDIT 2: You should be extending sherlockActivity instead of normal activity, same stands for Fragments, A fragment would be changed to sherlockFragment. These are the widgets that will come from sherlock library.
Refer this link also

Related

Can't add support library for CardView to my project

I would like to add the support library for Cardview to my project (I am using Eclipse). I found this TUTORIAL on Android website. I am doing everything according to it (I've already succesfully added AppCompat library to the project this way), but I am stuck at fourth point of adding this particular library to my project. In the window in which I should see the CardView library there is nothing:
What am I doing wrong?
The Library Project you need to import in Eclipse (via Import->Existing Android Code into Workspace) is located in your Android SDK folder: Android\android-sdk\extras\android\support\v7\cardview

Having problems with Android SDK Support Libraries

So I am just starting to learn to program with Android. Everything works great (I'm using Eclipse as IDE by the way). I only had this problem. Every time I make a new project that I chose API 8 as the Minimum required SDK, and chose a theme (Holo Light with Dark Action Bar for example), Eclipse will ALWAYS import a NEW COPY of the Android Support Library v7 (appcompat). I know this is required for the ActionBar and Fragments on old devices (API 7 - 10). But what I don't get is why Eclipse has to import a new copy of the support library all the time (well I'm just starting to learn and I am thinking that the support libraries can be and is meant to be edited, I'm not sure).
So due to this, I made my own solution. I followed what is said here from the Android Developer website. I imported the support library to my Eclipse workspace by myself. Then I created a new project. So, Eclipse (once again) imported it's own appcompat-v7 support library. I deleted it and then on the Properties of my project, I replaced the deleted appcompat-v7 library with my own-imported v7 library I added earlier.
This could have been a solution, but I encountered some problems
Eclipse added a new package in my PROJECT_FOLDER/gen named from the Support Library I imported manually, and as a result (which I don't understand why), it creates it's own R.java file (which causes a name collision-like effect). That is, when I mention something like this on my code, the R.java file that is searched was not the right R.java (but the duplicate R.java file)
EditText editText = (EditText) findViewById(R.id.edit_message); // this shows an error because the duplicate R.java file contains different fields from what the project's R.java file have
Another thing, when I create a new Activity, many errors are popping on the Eclipse Console like
[2014-04-08 14:53:49 - MyFirstApp] C:\Users\ME\Documents\Android\Android Workspace\android-support-v7-appcompat\res\values\attrs.xml:572: error: Attribute "textAllCaps" has already been defined
Additionally, the project will import AGAIN the appcompat-v7 library that it imported earlier (which I manually deleted) AND it will delete my R.java file AND will unassociate itself with the v7 library I manually created.
Is there a right way of doing this? Or the Support Library is really needed to be imported always? Thank you.
I faced the same problem when accidentally recreating the MainActivity. As a result it imported a new reference to the Appcompat libraries.
You see these errors because there has been duplicate reference to the reference to the Appcompat libraries. Do not delete anything yet.
First thing you must do is remove the duplicate reference by right clicking on your project or press Alt+Enter to show the project properties window. Then click on Android tab and go to Library.
On the list of referenced libraries, you will likely see more than one reference to the Appcompat library. Select one and click Remove then click Apply and OK.
You can then the unwanted MainActivity activity, its layout and menu XML files. But be sure to take extra care.
I hope this helps.
right click on project, go to properties, go to android, and then remove all app

How to resolve the error "No resource found that matches the given name" when adding library v7 AppCompat in Eclipse?

I have a project target to API Level 10 and i want to implement the new ActionBar support library.
After follow all the instrutions in the Support Library Setup, when adding the library to my project I came across with dozens of error messages like this:
android-support-v7-appcompat\res\values-v14\styles_base.xml:24: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.....
OK, i know that they are many answers to this question, but, after trying all the more obvious, i still could not solve the error.
I kept searching and found the cause, which is not so obvious, at least for newbies like me.
My intent is provide a full answer to help all those who are like me and do not master all the secrets of the Android development.
This is what you have to do for use the ActionBar support library correctly.
Follow the instructions in the Support Library Setup - Adding libraries with resources.
One thing that can bring some doubt is add the library to your aplicattion project:
(1) In the Project Explorer, right-click your project and select Properties.
(2) At the left pane select Android.
(3) At th bottom of the right pane click Add
(4) Select the library project android-support-v7-appcompat and click OK.
Click OK to close the properties window.
If you not get any of the errors I mentioned it´s all done.
However if you are like me, you dont´t followed the advice of Android team that suggests you always compile your source using the latest SDK, you get the error.
The error ocurrs because my Project Build Target was Android 2.3.3 and need to be at lest 3.0.
It was not immediately clear to me because of the fact that I'm specifically developing for Android 2.3.3 and I'm using support libraries.
OK, I hope this helps.
You should add that support library to your project. To add:
Right click on project, then go to :
properties > Java Build Path > Libraries
here Add External JARs...
add android-support-v7-appcompat.jar (path/to/sdk/extras\android\support\v7\appcompat\libs)
Additionally you also have to copy that jar to libs folder of your project, if it is not there automatically.
and you should use the #style/Theme.AppCompat theme for your application for support-v7 to be working
also keep one thing in mind you should change min sdk version to 11 if you want to support("android:windowActionBar")property in your project.

Error importing HoloEverywhere

First of all, I am new with Android.
I am doing an app, and I am implementing a library called HoloEverywhere.
This library use in the themes.xml the library ActionBar Sherlock. I have imported to my workspace ActionBar Sherlock and I have added it to HoloEverywhere.
Next, I have added HoloEverywhere to my project, but when I try to use it, I have an error (I tried to use a button):
The following classes could not be instantiated:
- com.WazaBe.HoloEverywhere.ButtonHolo (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse.
I put the path of the class in my layout, like this:
<com.WazaBe.HoloEverywhere.ButtonHolo
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/text" />
How I can solve this problem and use this library in my project?. Thanks :)
PS. Sorry for my english, I know it is not very good.
Follow the steps below(taken from blog here) to add ActionBarSherlock
Download the .zip/.tgz and extract it
Go to eclipse and choose File->New-> Android Project
Select Create project from existing source and then browse to the library folder inside extracted AndroidBarSherlock folder
Build Target should be the latest(14 or15), but your minSdkVersion can be less (7 or 8)
Press Finish
Right click on the newly created project and go to Properties.
Under the Android heading, you should see a section for Library with a checkbox IsLibrary. Make sure that's checked.
Right click -> Properies on the project in which you wish to add AndroidBarSherlock under the Android heading and the Library section choose Add.
You should see the ActionBarSherlock library, add this to your project
Lastly, if you were using the compatibility support , you need to delete that jar since it's included in ActionBarSherlock.
Follow the steps below to add HoloEverywhere
Download Zip from GitHub to your computer
UnZip the folder
Go to eclipse and choose File->New-> Android Project
Select Create project from existing source and then browse to the HoloEverywhereLib folder inside extracted folder
Press Finish
Right click on the newly created project and go to Properties.
Under the Android heading, you should see a section for Library with a checkbox IsLibrary. Make sure that's checked and press Add and previously added library ActionBarSherlock.
Follow these steps to add HoloEverywhere to your project
Create a new Android project
Right Click on project -> Properties -> Android -> Add, add both ActionBarSherlock and HoloEverywhere
Change the Android Manifest to following
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Holo.Theme">
Edit you main.xml to include Holo theme widgets.
Change your activity as follows
public class ChkActionBarSherlock extends SherlockActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
It seems that
android:theme="#style/Theme.HoloEverywhereDark.Sherlock"
cause an error.
change it:
android:theme="#style/Holo.Theme"
resons here:
Github
correct!
I had the same error on my project, This is what I did, right click the HoloEverywhere (properties->android->library) remove the ActionBarSherlock from the list then re-add the ActionBarSherlock project by click add, after that clean up the project and all errors will disappear.
The creator of ActionBarSherlock, Jake Wharton, announced on Google+ that further development of ActionBarSherlock has been stopped. ActionBarSherlock 4.4 is the last release and might get bug fixes – but there won’t be any new features:
While there may be a dot release or two in the coming weeks, version
4.4 is shaping up to be The Last Release™.
https://plus.google.com/+JakeWharton/posts/F3HkWY9J8fK
As i asked on holoeverywhere issues forum and answered by devs:
HoloEverywhere doesn't have any dependency with ABS since v2.0
So you should not use ABS anymore and remove the library from your project and replace it holoeverywhere directly or with ActionbarCompat from google support library.

Action bar implementation with ActionbarSherlock

I am using ActionBarSherlock to implement action bar on my Android 2.1 API 7 project. (With Eclipse IDE)
In order to use sherlock, after I imported sherlock library as a existing project on Eclipse. I did the following things on my own project:
mouse right click on my project, choose "properties"
in "Android" section, there is "Library" sub-section, I added sherlock project as library
Apply change
Then, I notice the FragmentActivity can not be resolved in my project source code.
I checked the project property again, the added sherlock project as library is not in "Library" section...weired!!! Why it suddenly disappeared even I have added sherlock as library? What am I missing?
I mean no matter how many times I added sherlock as library to my own project, the next time I check project property, the sherlock just disappear from library section...
First, after adding the project as a library, restart Eclipse - I believe this is a known bug with at least some versions of the plugin.
If that doesn't work, check that the 'default.properties' file in your project root is not read only.
Other known problems :
Your app should use the same "Uses-sdk" setting in AndroidManifest like your Sherlock addon
Minimum Java version for Sherlock: 1.6 !
In package with libraries, you also have a lot of samples with source code
ActionBar is not visible in Layouts
Few simple that i remember

Categories

Resources