score:105

Accepted answer

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.

score:0

i noticed creation of 'appcompat' library while creating new android project with adt 22.6.2 version, even when the minsdk was set to 11 and targetsdk was set 19

this was happening because, in the new project template android is using some attributes that are from the support library. for instance if a new project was created with actionbar then in the menu's main.xml one could find app:showasaction="never" which is from support library.

  • if the app is targeted at android version 11 and above then one can change this attribute to android:showasaction in menu's main.xml
  • also the default theme set could be "theme.appcompat.light.darkactionbar" as shown below (styles.xml)

    <style name="appbasetheme" parent="theme.appcompat.light.darkactionbar">
           <!-- api 14 theme customizations can go here. -->
       </style> 
    

    in this case the parent theme in style.xml has to be changed to "android:style/theme.holo.light.darkactionbar"

  • in addition to this if reference to fragment,fragments manager from support library was made in the code of mainactivity.java, these have to appropriately changed to fragment, fragmentmanager of the sdk.

score:2

according to http://developer.android.com/guide/topics/ui/actionbar.html

the actionbar apis were first added in android 3.0 (api level 11) but they are also available in the support library for compatibility with android 2.1 (api level 7) and above.

in short, that auto-generated project you're seeing modularizes the process of adding the actionbar to apis 7-10.

example of actionbar on froyo

see http://hmkcode.com/add-actionbar-to-android-2-3-x/ for a simplified explanation and tutorial on the topic.

score:3

sorry with my english, when you create a new android project, you should choose api of high level, for example: from api 17 to api 21, it will not have appcompat and very easy to share project. if you did it with lower api, you just edit in android manifest to have upper api :), after that, you can delete appcompat v7.

score:4

if you are not targeting 2.x versions you can set your minimum sdk version of 4.x and then create project. appcompat v7 lib wont be created.

score:4

i'm new with android and the project appcompat_v7 always be created when i create new android application project makes me so uncomfortable.

this is just a walk around. choose project properties -> android then at library box just remove appcompat_v7_x and add appcompat_v7. now you can delete appcompat_v7_x.

uncheck create activity in create project wizard doesn't work, because when creating activity by wizard the appcompat_v7_x appear again. my adt's version is v22.6.2-1085508.
i'm sorry if my english is bad.

score:8

it's included because your minimum sdk version is set to 10. the actionbar was introduced in api 11. eclipse adds it automatically so your app can look more consistent throughout the spectrum of all android versions you are supporting.

score:18

eclipse automatically created the appcompat_v7.because of kitkat api launched itself it adds automatically appcompat_v7 and fragment_main.xml.

best ways to solve these:

  1. firstly in project,right click->properties->android.there you can see the red marked appcompat placed in reference. click that and remove it.then tick the right target name in project build target.

  2. delete fragment_main.xml and appcompat file created in your eclipse.

  3. edit and change your activity_main.xml like these:

    <?xml version="1.0" encoding="utf-8"?>
    
    <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <textview
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />
    
    </relativelayout>
    
  4. in res/values/styles.xml:

    <resources>
    
        <style name="appbasetheme" parent="android:theme.light">
    
        </style>
    
        <!-- application theme. -->
        <style name="apptheme" parent="appbasetheme">
    
        </style>
    
    </resources>
    
  5. in res/values-v11/styles.xml you have to change like these:

    <resources>
    
        <style name="appbasetheme" parent="android:theme.holo.light">
        </style>
    
    </resources>
    
  6. in res/values-v14/styles.xml you have to change like these:

      <resources>
    
        <style name="appbasetheme" parent="android:theme.light">
        </style>
    
        <style name="apptheme" parent="appbasetheme">
        </style>
    
    </resources>
    
  7. change your menu/main.xml like these:

    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
    
        <item
            android:id="@+id/action_settings"
            android:orderincategory="100"
            android:showasaction="never"
            android:title="@string/action_settings"/>
    
    </menu>
    
  8. finally change your mainactivity.java like these:

    import android.app.activity;
    import android.os.bundle;
    
    
    public class mainactivity extends activity {
    
    
        @override
        protected void oncreate(bundle savedinstancestate) {
            super.oncreate(savedinstancestate);
            setcontentview(r.layout.activity_main);
    
    }
    
    }
    

likewise you have to do it for creating a new project

score:22

why my eclipse automatically adds appcompat v7 library support whenever i create a new project

because your target sdk is set to 15, in which the action bar is on by default and your minimum supported sdk is set to 10. action bar come out in 11, so you need a support library, eclipse adds it for you. reference.

you can configure project libraries in the build path of project properties.

score:59

create a new android application project and uncheck create activity in step two (configure project).


Related Query

More Query from same tag