How to avoid using AppCompat for minSDK > 16 in An

2019-09-17 15:59发布

I'm using Android Studio 1.0.2 (fresh standard install, switching from Eclipse/ADT).

When I create a new project with minSDK = 17, AS still create the project using AppCompat:

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends ActionBarActivity {

The gradle.file shows:

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "cl.agb.test2"
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

How do I configure AS to NOT generate code using AppCompat? I will run my code only in Android 4.2.2 (sdk 17) and above. Do I need to install SDK Platform for Android 4.2.2 (no SDK platform is installed for any Android version)?

1条回答
看我几分像从前
2楼-- · 2019-09-17 16:16

How do I configure AS to NOT generate code using AppCompat?

AFAICT, you don't. The stock new-project and new-activity templates are set up to use appcompat-v7.

You can minimize the amount of extraneous crap that gets generated by not having the new-project wizard create an activity for you. Then, all you need to delete is the com.android.support:appcompat-v7 line in the dependencies closure.

查看更多
登录 后发表回答