gradle编译错误问题,Android Studio Flamingo版本编译错误,如何解决呢?

1.使用的AS版本:

2.gradle配置:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}
 
android {
    namespace 'com.bill'
    compileSdk 33
 
    defaultConfig {
        applicationId "com.bill"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"
 
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }
 
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.3.2'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}
 
dependencies {
 
    implementation "androidx.constraintlayout:constraintlayout:2.2.0-alpha07"
 
    implementation 'androidx.core:core-ktx:1.8.0'
    implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.5.1'
    implementation platform('androidx.compose:compose-bom:2022.10.00')
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-graphics'
    implementation 'androidx.compose.ui:ui-tooling-preview'
    implementation 'androidx.compose.material3:material3'
    implementation 'androidx.core:core-ktx:+'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
    debugImplementation 'androidx.compose.ui:ui-tooling'
    debugImplementation 'androidx.compose.ui:ui-test-manifest'
}

3.错误信息

2 issues were found when checking AAR metadata:
 
  1.  Dependency 'androidx.core:core:1.12.0-alpha05' requires libraries and applications that
      depend on it to compile against version 34 or later of the
      Android APIs.
 
      :app is currently compiled against android-33.
 
      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 8.0.2 is 33.
 
      Recommended action: Update this project's version of the Android Gradle
      plugin to one that supports 34, then update this project to use
      compileSdk of at least 34.
 
      Note that updating a library or application's compileSdk (which
      allows newer APIs to be used) can be done separately from updating
      targetSdk (which opts the app in to new runtime behavior) and
      minSdk (which determines which devices the app can be installed
      on).
 
  2.  Dependency 'androidx.core:core-ktx:1.12.0-alpha05' requires libraries and applications that
      depend on it to compile against version 34 or later of the
      Android APIs.
 
      :app is currently compiled against android-33.
 
      Also, the maximum recommended compile SDK version for Android Gradle
      plugin 8.0.2 is 33.
 
      Recommended action: Update this project's version of the Android Gradle
      plugin to one that supports 34, then update this project to use
      compileSdk of at least 34.
 
      Note that updating a library or application's compileSdk (which
      allows newer APIs to be used) can be done separately from updating
      targetSdk (which opts the app in to new runtime behavior) and
      minSdk (which determines which devices the app can be installed
      on).
阅读 4.8k
1 个回答

升级 一下Android Gradle 插件和 compileSdk 版本

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题