【问题标题】:Dolphin IDE: This version (1.2.0-alpha05) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.6.21Dolphin IDE:此版本 (1.2.0-alpha05) 的 Compose 编译器需要 Kotlin 版本 1.6.10,但您似乎使用的是 Kotlin 版本 1.6.21
【发布时间】:2022-12-23 03:44:45
【问题描述】:

错误继续说“请修复您的配置(或suppressKotlinVersionCompatibilityCheck 但不要说我没有警告你!)。”

如何“修复”配置对我来说并不明显。我添加了建议的标志,但它无法解决并自行失败。

IDE 是 Dolphin Android Studio Dolphin | 2021.3.1

项目设置Kotlin版本:

buildscript {
    ext.kotlin_version = '1.6.10'

我之前在这里设置项目使用Kotlin 1.7.10,但是徒劳地降级了希望它能解决问题,但它没有。

我尝试添加对 androidx.compose.compiler:compiler 的显式依赖,它似乎被默默地忽略了。

我看不到 Kotlin 1.6.21 和 Compose Compiler 1.2.0-alpha05 的设置位置,因为它们都没有在构建文件中设置。

我熟悉 Android,但不熟悉 Compose。我正在使用当前稳定的 IDE 和直接从 Compose 文档中获取的依赖项声明,但项目无法构建。

我怀疑在 Dolphin 中使用 Compose 需要一些依赖版本的神奇组合,但我一直没能找到它。

我在 v1.0 尝试了 Compose 但不得不再次退出,因为有太多的问题,而且它似乎仍然具有挑战性,但也许有好心人会指出我的错误然后我会很高兴地向我们的朋友道歉在谷歌。 :-)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'androidx.navigation.safeargs'
apply plugin: 'com.google.firebase.crashlytics'

android {

    namespace "com.blah"
    
    compileSdk 33

    defaultConfig {
        applicationId "com.blah"
        minSdk 21
        targetSdk 33
        versionCode 123
        versionName "1.2.3"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    flavorDimensions "environment"
    productFlavors {
        staging {
            dimension "environment"
            applicationIdSuffix ".staging"
        }
        production {
            dimension "environment"
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.all { output ->
            outputFileName = "MyApp-${variant.versionName}-${variant.name}.apk"
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    buildFeatures {
        dataBinding true
        compose true
    }

    lint {
        disable 'RtlHardcoded'
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.2'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.2'

    // Android X Jetpack
    implementation "androidx.appcompat:appcompat:1.5.1"
    implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation "androidx.constraintlayout:constraintlayout:2.1.4"
    implementation "androidx.recyclerview:recyclerview:1.2.1"
    implementation "androidx.fragment:fragment-ktx:1.5.2"
    implementation "androidx.collection:collection-ktx:1.2.0"
    implementation "androidx.window:window:1.0.0"

    // Jetpack Compose
    implementation("androidx.compose.ui:ui:1.2.1")
    implementation("androidx.compose.ui:ui-tooling:1.2.1")
    // Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
    implementation("androidx.compose.foundation:foundation:1.2.1")
    implementation("androidx.compose.material:material:1.2.1")
    implementation("androidx.compose.material:material-icons-core:1.2.1")
    implementation("androidx.compose.material:material-icons-extended:1.2.1")
    // Integration with observables
    implementation("androidx.compose.runtime:runtime-livedata:1.2.1")
    implementation("androidx.compose.runtime:runtime-rxjava2:1.2.1")

    // Google
    implementation "com.google.android.material:material:1.6.1"
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'

    // Navigation Component
    implementation "androidx.navigation:navigation-fragment-ktx:2.5.2"
    implementation "androidx.navigation:navigation-ui-ktx:2.5.2"

    // Firebase & Crashlytics
    implementation "com.google.firebase:firebase-core:21.1.1"
    implementation "com.google.firebase:firebase-analytics:21.1.1"
    implementation "com.google.firebase:firebase-crashlytics:18.2.13"
    implementation "com.google.firebase:firebase-messaging:21.0.1"

    // Urban Airship push messaging
    implementation "com.urbanairship.android:urbanairship-fcm:13.3.5"

    // Twilio (video calling)
    implementation "com.twilio:video-android-ktx:7.1.1"
    implementation "com.twilio:audioswitch:1.1.4"

    // ExoPlayer
    implementation "com.google.android.exoplayer:exoplayer-core:2.18.1"
    implementation "com.google.android.exoplayer:exoplayer-ui:2.18.1"

    // Third-party
    implementation "com.jakewharton.timber:timber:5.0.1"
    implementation "com.jakewharton.threetenabp:threetenabp:1.4.0"
    implementation "com.squareup.retrofit2:retrofit:2.9.0"
    implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
    implementation "com.squareup.picasso:picasso:2.71828"
    implementation "net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.3.0"
    // https://github.com/square/okhttp/blob/master/CHANGELOG.md
    implementation "com.squareup.okhttp3:okhttp:4.9.3"
    implementation "com.squareup.okhttp3:logging-interceptor:4.9.3"

    // Open Source Licence List
    implementation "com.github.franmontiel:AttributionPresenter:1.0.1"

    // Shake to Send Feedback
    implementation "com.linkedin.shaky:shaky:3.0.4"
    implementation "com.jraska:falcon:2.2.0"

    // Page Indicator View
    implementation 'com.github.romandanylyk:PageIndicatorView:v.1.0.3'

    // Testing
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    testImplementation "junit:junit:4.13.2"
    testImplementation "androidx.test:core:1.4.0"
    testImplementation "org.mockito:mockito-core:4.6.0"
    androidTestImplementation "androidx.test:runner:1.4.0"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
    androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.2.1")

    apply plugin: 'com.google.gms.google-services'
}

模块构建文件:

apply plugin: "com.github.ben-manes.versions"

buildscript {

    ext.kotlin_version = '1.6.10'

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.2"
        classpath "com.google.firebase:firebase-crashlytics-gradle:2.9.2"
        classpath "com.google.gms:google-services:4.3.14"
        classpath "com.github.ben-manes:gradle-versions-plugin:0.42.0"
    }
}

allprojects {
    repositories {
        google()
        maven { url "https://jitpack.io" }
        mavenCentral()

        jcenter() {
            content {
                includeModule("com.google.android", "flexbox")
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【问题讨论】:

  • 可以搜索一下1.6.21 看看有没有用?也许在build.gradle 文件以外的地方。
  • 你可以查看兼容性图here。还有another question 已经谈到了这种兼容性以及如何配置它。
  • 发布你的 build.gradle 文件
  • @ThalesIsidoro 我检查了兼容性列表,但问题是我似乎无法设置 Compose 编译器版本或完全设置 Compose 使用的 Kotlin 版本。
  • @GabrieleMariotti 这就是解决方案。请将其添加为答案,我会接受。谢谢!

标签: android android-jetpack-compose


【解决方案1】:

app/build.gradle文件的android块中添加:

android {

   //..

   composeOptions {         
       kotlinCompilerExtensionVersion "1.3.1"     
   }
}

根据 compatibility map 使用 kotlin 1.7.10

【讨论】:

    猜你喜欢
    • 2022-07-28
    • 2023-01-16
    • 1970-01-01
    • 2022-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-29
    • 1970-01-01
    相关资源
    最近更新 更多