Why Does Eclipse Automatically Add Appcompat V7 Library Support Whenever I Create a New Project

Why does Eclipse automatically add appcompat v7 library support whenever I create a new project?

As stated in Android's Support Library Overview, it is considered good practice to include the support library by default because of the large diversity of devices and the fragmentation that exists between the different versions of Android (and thus, of the provided APIs).

This is the reason why Android code templates tools included in Eclipse through the Android Development Tools (ADT) integrate them by default.

I noted that you target API 15 in your sample, but the miminum required SDK for your package is API 10, for which the compatibility libraries can provide a tremendous amount of backward compatible APIs. An example would be the ability of using the Fragment API which appeard on API 11 (Android 3.0 Honeycomb) on a device that runs an older version of this system.

It is also to be noted that you can deactivate automatic inclusion of the Support Library by default.

appcompat_v7 project is created automatically after creating a new project in Eclipse

I ran into this problem last night. I was doing several things including updating the SDK manager. I had to back off the Android SDK Tools to Rev. 22.3 and Android SDK Platform-tools to 19.

opus44

How to remove support library (appcompat_v7) [Eclipse]


Why is that?

Because Google engineers added that stuff to the new-activity templates, for at least the "BlankActivity".

Why is the activity_main.xml file not preferred for activity layout directly anymore

You are certainly welcome to use activity_main.xml for whatever you want. It so happens that Google's current templates want you to use fragments. Google's templates are just templates. One can argue -- and I have, vehemently -- that a "BlankActivity" template should not be doing what it is doing. However, beyond that, it is just a template.

why appcompat library is now included in every project ?

Presumably, they wanted to start you off with a consistent action bar, even on older API levels.

I realize it has something to do with actionbar but the problem is that whenever I create a new project a red exclamation mark shows up on both project's file and appcompat_v7 file and this prevents me from compiling/running the application or even sometimes appcompat_v7 file doesn't create and the only thing I get is damaged code

I reported this issue a week or so ago.

so how can I remove this dependency

Step #1: Right-click over the project name in the Package Explorer, and choose Properties. Click on Android in the list of property categories on the left, and scroll down on the right to the bottom:

Eclipse Project Properties, Android Category

Step #2: In the list of attached library projects that you will now see in the properties dialog, you may see an entry akin to the "appcompat_v7_6" one that you see in the above screenshot. Your last digit will differ, and it may be that yours has a red X instead of a green checkmark. Regardless, if there is an entry for "appcompat_v7_NNN" in the list, click on it, then click the Remove button to the right of the list. Then, click the OK button to close up the dialog.

Step #3: In res/values/styles.xml, change the parent of AppBaseTheme from Theme.AppCompat.Light to @android:style/Theme.Light. In res/values-v11/styles.xml, change the parent of AppBaseTheme from Theme.AppCompat.Light to @android:style/Theme.Holo.Light. In rest/values-v14/styles.xml change the parent of AppBaseTheme from Theme.AppCompat.Light.DarkActionBar to @android:style/Theme.Holo.Light.DarkActionBar. Note that these values assume that you chose the default "Light theme with dark action bar" when you created the project -- you will need to make slight adjustments to those instructions for anything else.

Step #4: In res/menu/main/xml, remove xmlns:app="http://schemas.android.com/apk/res-auto" from the root <menu> element and the app:showAsAction="never" attribute from the <item> element.

Step #5: In your activity (e.g., MainActivity), change the parent class of the activity to something other than ActionBarActivity -- FragmentActivity would be a good choice, to minimize the number of other changes you will have to make immediately. Also, clean your imports (e.g., Ctrl-Shift-O).

At this point, other than perhaps cleaning your project (Project > Clean from the main menu), the appcompat stuff should be ripped out of a project created using the "BlankActivity" template and with a "Navigation Type" of "None". Other templates, or navigation options on the "BlankActivity" template, will probably require more work.

“appcompat_v7” project is contains error

go to style.xml and inside resources put

<style name="AppBaseTheme" parent="android:Theme.Light">

-->
</style>

<style name="AppTheme" parent="AppBaseTheme">

</style>


Related Topics



Leave a reply



Submit