【问题标题】:How change Android Studio project api version to 23如何将 Android Studio 项目 api 版本更改为 23
【发布时间】:2019-03-13 02:22:51
【问题描述】:

我使用 Android Studio3.2。 我创建了一个使用 api 版本 28 的项目。 现在我需要将 api 版本更改为 23。 所以我编辑 build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    defaultConfig {
        applicationId "com.example.administrator.myapplication"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags ""
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
}

我将“AppCompatActivity”更改为“Activity”

但构建失败:

Android resource linking failed
Output:  error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
.............................

【问题讨论】:

  • 嗨@Getname,为此您应该添加材料支持,例如 compile 'com.android.support:support-v4:23.x.x'
  • 我认为你还需要在gradle中降级你的依赖,比如constraintlayout等。
  • 谢谢@Varma,但是如何添加材质支持?
  • 谢谢@Yasir,但是如何降级依赖?我尝试将实现 'androidx.constraintlayout:constraintlayout:1.1.2' 更改为实现 'androidx.constraintlayout:constraintlayout:1.1.0' 这不起作用

标签: android-studio api-versioning


【解决方案1】:

尝试在您的 XML 中查找具有该错误中提到的样式类型的视图。

另外,尝试使用 File/InvalidateCaches

【讨论】:

  • Marovic,嘿,你也可以在评论中提到这一点。很抱歉,这根本不是解决方案,请阅读 stackoverflow 规则。谢谢
【解决方案2】:

compileSdkVersiontargetSdkVersion 应该匹配和分开

您必须包含以下支持库才能支持 api 23

implementation 'com.android.support:appcompat-v7:23.0.0'

然后现在同步项目并检查。

希望这会有所帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-18
    • 2013-09-30
    • 2012-01-17
    • 2018-01-22
    • 2019-02-11
    • 1970-01-01
    • 2017-01-09
    相关资源
    最近更新 更多