Aad*_*ain 3 android android-studio build.gradle android-jetpack-compose
我目前正在使用Android studio(2021.2.1补丁2)。在选择空撰写活动时,所使用的撰写版本是1.1.0-beta01。我如何将其升级到,1.2.0-beta01因为早期版本在使用 LazyVerticalGrid 时出现错误?我是安卓初学者。任何帮助将不胜感激。
这是项目的app/ build.gradle文件:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.courses"
minSdk 21
targetSdk 32
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 compose_version
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.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.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
testImplementation 'junit:junit:4.13.2'
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"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
Run Code Online (Sandbox Code Playgroud)
顶级build.gradle文件:
buildscript {
ext {
compose_version = '1.1.0-beta01'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
我尝试将顶级 build.gradle 文件中的 compose 版本更改为,1.2.0-beta01但项目的构建失败。
如果您需要更多信息,请在评论中注明。谢谢
如果没有看到编译错误消息,我只能猜测可能的原因。但我发现有一些事情可能会给您带来问题。
Compose 编译器需要1.2.0-beta01Kotlin 插件版本1.6.21请参阅Compose Kotlin 兼容性图
此外,从版本1.2.0开始,他们为 Compose 编译器引入了与其他 Compose 库无关的独立版本控制,这意味着kotlinCompilerExtensionVersion需要指向不同的版本。截至目前最新的编译器版本是1.3.1需要 kotlin 插件版本1.7.10。
尝试这些改变。
ext {
compose_version = '1.3.0-beta02' // or 1.2.1 if you want the latest stable version
}
Run Code Online (Sandbox Code Playgroud)
composeOptions {
kotlinCompilerExtensionVersion "1.3.1"
}
Run Code Online (Sandbox Code Playgroud)
plugins {
// others omitted
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4206 次 |
| 最近记录: |