0

I downloaded the ActionBarSherlock version 4.1.0.0, and added a the Android Project library into Eclipse 4.2 on my Win7 java 1.6 update 24 machine. I used an Eclipse Project Build Target of Android 4.1 in Project | Properties | Project Build Target. I want to incorporate the ActionBar functionality into an existing app that has minSdkVersion="7". I noted the code from the ActionBarSherlock library appears to have some deprecated methods, and an error:

Example 1: ActionBarContainer.java, ActionBarContextView.java, ScrollingTabContainerView.java - uses setBackgroundDrawable - The method setBackgroundDrawable(Drawable) from the type View is deprecated

public ActionBarContainer(Context context, AttributeSet attrs) {
    super(context, attrs);

    setBackgroundDrawable(null);

    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.SherlockActionBar);
    mBackground = a.getDrawable(R.styleable.SherlockActionBar_background);
    mStackedBackground = a.getDrawable(
            R.styleable.SherlockActionBar_backgroundStacked);

    if (getId() == R.id.abs__split_action_bar) {
        mIsSplit = true;
        mSplitBackground = a.getDrawable(
                R.styleable.SherlockActionBar_backgroundSplit);
    }
    a.recycle();

    setWillNotDraw(mIsSplit ? mSplitBackground == null :
            mBackground == null && mStackedBackground == null);
}

Quick fix shows as Add @SupressWarnings 'deprecation' for ActionBarContainer

Example 2: IcsProgressBar.java uses animationResolution which shows as deprecated, same quick fix as above

private static final int[] ProgressBar = new int[] {
    ...
    android.R.attr.animationResolution

Also, I have an error in ActivityChooserView.java:

private static class SetActivated {
    public static void invoke(View view, boolean activated) {
        view.setActivated(activated);
    }
}

Error is on SetActivated - Call requires API 11 (current min is 7). This makes sense based on the manifest:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>

Shouldn't API 7 be fine, since Action Bar Sherlock should work at at Andriod 2.x? Have others experienced this, and if so, what is the recommended action? Supress/ignore the deprecation? What about the error on SetActivated? I reviewed the readme and did some net searches but did not come up with anything on this. Thanks for any suggestions.

Thanks!

Joshua Dance
  • 8,847
  • 4
  • 67
  • 72
user1362308
  • 77
  • 1
  • 3
  • 10

2 Answers2

3

It is just fine. The code is 2.x compatible and even some methods are deprecated as of 4.x, they are still there. It also do not mean on 4.x these deprecated methods will be used. The source is 2.x-4.x so there's no other way (not to mention reflection, but that'd hurt performance, and is for now not necessary). So it is safe to just ignore this. It would probably be better to turn depreciation off for certain files but it is not there. So do not worry.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • Thanks for the reply! That's fine then, I can set it to ignore. What about the error regarding the SDK version? If I incrase the minSdkVerson to 11, won't that prevent Android 2.x clients from installing the app? Over 50% of the clients who have purchased my app are Android 2.x devices, so I was hoping that I could update my app in a way that those devices could receive my update. – user1362308 Sep 29 '12 at 23:22
  • 1
    I changed the minSdkVersion to 11, saved it, cleaned the project, and got rid of the error. I then changed the midSdkVersion back to 7, saved and cleaned the project, still no errors. I think I am looking good at this point! Thanks so much for yoru help! – user1362308 Sep 29 '12 at 23:59
0

This is doesn't really answer the question but I ran into the same issue when I had to have a minSdkVersion 9 and I wanted to have ActionBarSherlock but I was getting the same error of the actionBar requires minSdkVersion 11.

Apparently in ADT 21.1 you make a values-v11/styles.xml and put the actionBar in there.

https://code.google.com/p/android/issues/detail?id=48283

luckyreed76
  • 185
  • 2
  • 8