如何构建应用程序支持Android中的旧SDK版本(minSdkVersion)

Dev*_*v X 4 android gradle android-studio

当通过向导创建新项目并给出错误时,它会非常沮丧.

我只是使用MinSdk = 9创建新项目以使应用程序在姜饼上运行,这给了我以下错误:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library [com.android.support:appcompat-v7:26.0.0-alpha1] C:\Users\USER\.android\build-cache\dfb3187f39ea1ff94009f5d34353fff5cfc3daee\output\AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
Run Code Online (Sandbox Code Playgroud)

这是gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.example.com.testApp"
        minSdkVersion 9
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)

怎么解决这个问题?

小智 6

您必须使用旧版本的支持库.

compileSdkVersion 25

compile 'com.android.support:appcompat-v7:25.4.0'
Run Code Online (Sandbox Code Playgroud)

正如你可以找出在发布笔记26.0.0 这里

注意:最低SDK版本已增加到14.因此,不推荐使用仅存在API <14兼容性的许多API.这些API的客户端应迁移到其框架等效项,如每个已弃用的API的参考页中所述.