-2

I need to use a HTC Legend which runs Android 2.2 to run
the open source nyaruka/android-sms-relay. However, this app's build target is Android 4.2.

I tried to simply change the build target from 4.2 to 2.2 but was unable to compile the app.

I got the following errors:

public **ActionProvider** getActionProvider() {
        // Noop
        return null;
    }

ActionProvider cannot be resolved to a type


@Override
protected Context getActionBarThemedContext() {
         return mActivity.**getActionBar()**.getThemedContext();
    }

The method getActionBar() is undefined for the type Activity


 ImageButton actionButton = new ImageButton(mActivity, null,
                itemId == android.R.id.**home**
                        ? R.attr.actionbarCompatItemHomeStyle
                        : R.attr.actionbarCompatItemStyle);
        actionButton.setLayoutParams(new ViewGroup.LayoutParams(
                (int) mActivity.getResources().getDimension(
                        itemId == android.R.id.**home**
                                ? R.dimen.actionbar_compat_button_home_width
                                : R.dimen.actionbar_compat_button_width),
                ViewGroup.LayoutParams.FILL_PARENT));

home cannot be resolved or is not a field

Anyone who down voted this question, please explain the reason!

4

3 回答 3

2

You are seeing this error because the ActionBar is a new concept introduced in Android 3
and is not available in 2.2

There are some Android 2.2 ActionBar samples out there,
and there is also the 'ActionBarCompat' sample in the Google SDK.

However, these might still require a few modifications to be made
in order to get your project to compile again.

Update: I just figured out you are talking about https://github.com/nyaruka/android-sms-relay If are unable to use a different ActionBar yourself, you may be able to get some help from the community behind the project (on github) to get it working on 2.2
Also... it would seem they are not using the built-in ActionBar either but this: http://actionbarsherlock.com/faq.html. I suggest you check out the documentation on that project as well.

于 2013-03-01T02:02:24.303 回答
0

You can't just downgrade the build target if you are using stuff that are new to the 2.2 API. As comented above, you must use another Action Bar as it's not available in that API. You can see here that android 2.2 is API 8 http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

于 2013-03-01T02:04:33.440 回答
0

Use android compatible library for getting Action Bar in Android 2.2 and it also works on above Android 3.0.

于 2013-03-01T05:34:06.067 回答