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

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

我只是使用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

这是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'
}

怎么解决这个问题?

解决方法:

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

compileSdkVersion 25

compile 'com.android.support:appcompat-v7:25.4.0'

正如您可以在26.0.0 here的发行说明中找到的那样

Note: The minimum SDK version has been increased to 14. As a result,
many APIs that existed only for API < 14 compatibility have been
deprecated. Clients of these APIs should migrate to their framework
equivalents as noted in the reference page for each deprecated API.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐