如何在Android-studio 3.4.1上使用api 9编写Android应用程序?

时间:2019-05-30 09:16:15

标签: android sdk

我想为运行Android 2.3及更高版本的设备编写Android应用程序。但这有一些问题。

起初,我的“ build.gradle”是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "#.#.#"
        minSdkVersion 9
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

但是在构建时,我收到此错误消息:

ERROR: Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library [com.android.support:appcompat-v7:28.0.0] /home/#/.gradle/caches/transforms-2/files-2.1/2f2898e7868f192ee52215913109e968/AndroidManifest.xml as the library might be using APIs not available in 9
    Suggestion: use a compatible library with a minSdk of at most 9,
        or increase this project's minSdk version to at least 14,
        or use tools:overrideLibrary="android.support.v7.appcompat" to force usage (may lead to runtime failures)

我无法更改'targetSdkVersion'和'compileSdkVersion',因为会发生此错误:

Google Play requires that apps target API level 26 or higher.

您能告诉我该怎么办吗?

1 个答案:

答案 0 :(得分:0)

问题与您使用的支持库有关,所有支持库软件包的最低SDK版本至少为API级别14。link

Android API级别低于10的分布低于0.1%,我建议您使用更高的最低API。android version distributions