简体   繁体   English

jetpack compose:更新到 alpha08 后@Preview 未解决

[英]jetpack compose: @Preview is unresolved after updating to alpha08

I updated compose libraries from alpha07 to alpha08我将 compose 库从alpha07更新到alpha08

version = "1.0.0-alpha08"
androidx.compose.ui:ui:$version
androidx.ui:ui-tooling:$version

But after that androidx.ui.tooling.preview.Preview is unresoved但在那之后androidx.ui.tooling.preview.Preview未解决

Checking out the release note of alpha08 in Jetpack compose, you'll notice that ui-tooling has been moved from androidx.ui to androidx.compose.ui查看 Jetpack compose 中 alpha08 的发行说明,您会注意到ui-tooling已从androidx.ui移至androidx.compose.ui

Changes you need to make:您需要进行的更改:

dependencies {
    // New dependencies
    implementation "androidx.compose.ui:ui-tooling:1.0.0-alpha08"
    testImplementation "androidx.compose.ui:ui-test:1.0.0-alpha08"

    // Old dependencies
    implementation "androidx.ui:ui-tooling:1.0.0-alpha07"
    testImplementation "androidx.ui:ui-test:1.0.0-alpha07"
}

you mean using:你的意思是使用:

dependencies {

// New dependencies
implementation 'androidx.compose.ui:ui-tooling:1.0.0-beta02"
testImplementation "androidx.compose.ui:ui-test:1.0.0-beta02"

// Old dependencies
implementation "androidx.ui:ui-tooling:1.0.0-alpha07"
testImplementation "androidx.ui:ui-test:1.0.0-alpha07"
}

And using并使用

android {

//....

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
    useIR = true
}
buildFeatures {
    compose true
}
composeOptions {
    kotlinCompilerVersion "1.4.31"
    kotlinCompilerExtensionVersion "1.0.0-beta02"
}
}


tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach 
{
kotlinOptions {
    jvmTarget = "1.8"
}
 

but this doesn't fix the problem for me.但这并不能解决我的问题。

Top gradle:顶部 gradle:

dependencies {
    classpath "com.android.tools.build:gradle:4.2.0-alpha16"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31"
 }

i didn't find any solution for now using last compose dependencies versions.我现在没有找到任何使用最后一个组合依赖版本的解决方案。

Solved the problem by:通过以下方式解决了问题:

  • Using the latest Android Studio Artic Fox (Canary build) and not any other canary old IDE.使用最新的Android Studio Artic Fox(金丝雀版本)而不是任何其他金丝雀旧 IDE。

  • Use Android studio Artic Fox Embeded JDK (openjdk version "11.0.8") or download and replace 1.8 java by OpenJdk 11.使用 Android studio Artic Fox 嵌入式 JDK(openjdk 版本“11.0.8”)或下载并用 OpenJdk 11 替换 1.8 java。

  • Update dependencies as above.如上所述更新依赖项。

in this case all are good and all compile,在这种情况下,一切都很好并且都可以编译,

Voila,瞧,

The latest tooling dependency which worked for me is对我有用的最新工具依赖项是

 implementation "androidx.compose.ui:ui-tooling:1.2.0-alpha07"

I am using我在用

Android Studio Arctic Fox | 2020.3.1
Build #AI-203.7717.56.2031.7583922, built on July 27, 2021

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM