android studio 添加项目修改gradle2.2.3

1.build.gradle(Module:app) 去除对appcompat的配置

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    sourceSets {
        main {
            manifest.srcFile 'src/main/AndroidManifest.xml'
            java.srcDir 'src/main/java'
            res.srcDir 'src/main/res'
            assets.srcDir 'assets'
            jniLibs.srcDir 'native-libs'//'src/main/libs'

        }
        androidTest.setRoot('src/androidTest/java')
    }

    defaultConfig {
        applicationId "com.hulefei.jniandroid"
        minSdkVersion 14
        targetSdkVersion 22
        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:22.0.0'
}
// most important part to include .so files into the project
task copyNativeLibs(type: Copy) {
    from(new File(getProjectDir(), 'native-libs')) { include '**/*.so' }
    into new File(buildDir, 'native-libs')
}
tasks.withType(org.gradle.api.tasks.compile.JavaCompile) {
    compileTask -> compileTask.dependsOn copyNativeLibs
}

clean.dependsOn 'cleanCopyNativeLibs'

tasks.withType(com.android.build.gradle.tasks.PackageApplication) {
    pkgTask ->
        pkgTask.jniFolders = new HashSet()
        pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
}

 2.修改res/values/style.xml

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>
</resources>

 3.修改res/menu/menu_main.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
    android:orderInCategory="100" android:showAsAction="never" />
</menu>

 4.修改MainActivity

    a)去除ActionBarActivity

    b)换成Activity

你可能感兴趣的:(android studio)