gpt4 book ai didi

android - 无法使用 Kotlin Jetpack Compose 从一开始就在 Android Studio 中运行任何应用程序

转载 作者:行者123 更新时间:2023-12-05 00:02:24 24 4
gpt4 key购买 nike

我开始使用 Jetpack compose 学习 Kotlin,因为 UI 构建看起来很容易进入,因为我之前做过 Flutter。但我无法开始我的开发。我从一开始就一直遇到同样的错误。错误在下面提到。

One or more issues found when checking AAR metadata values:

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.activity:activity-compose:1.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/17c0065263b1ac8274468d1f294bb3f1/transformed/jetified-activity-compose-1.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.activity:activity-ktx:1.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/f6dca3ff903d8b71dc31289976e22565/transformed/jetified-activity-ktx-1.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-runtime-ktx:2.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/7d4cb7a963f721e0466a4f4713a2cbb9/transformed/jetified-lifecycle-runtime-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.core:core-ktx:1.7.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/89719b86a3bdb3906dcc70f7ccde2945/transformed/jetified-core-ktx-1.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.activity:activity:1.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/73d6a039b3ae7c3afc83ef08e89d1421/transformed/jetified-activity-1.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.core:core:1.7.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/acb209d88ce91ed7fb4d20f7c42190d1/transformed/core-1.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-runtime:2.4.0.
AAR metadata file: /Users/enigma/.gradle/caches/transforms-3/112ed6ed65dc4f7ca288781673eb239c/transformed/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
我的gradle看起来像这样
plugins {
id 'com.android.application'
id 'kotlin-android'
}

android {
compileSdk 30

defaultConfig {
applicationId "com.example.kotlinbegginner"
minSdk 26
targetSdk 30
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'
useIR = true
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.5.21'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
implementation 'androidx.activity:activity-compose:1.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
}
谁能解释为什么会发生这种情况以及如何解决?任何帮助将不胜感激!提前致谢 :)

最佳答案

在您的 gradle 文件中更改此行:

composeOptions {
kotlinCompilerExtensionVersion compose_version

---> kotlinCompilerVersion '1.5.21' <---

}
对此:
kotlinCompilerVersion '1.5.31'
在你的 build.gradle (Project)
改变这一行:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
对此:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"

关于android - 无法使用 Kotlin Jetpack Compose 从一开始就在 Android Studio 中运行任何应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69972744/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com