Jetpack Compose Found arabirimi rPluginContext'i kurmaya çalışırken sorun yaşanıyor

Aug 18 2020

Bu yüzden, jetpack compose'un basit bir örnekle çalıştırılmasına izin vermeye çalışıyorum, kotlin eklentimi 1.4.0'a güncelledim ve ayrıca tüm derleme gradle'ımı jetpack compose dokümantasyonuyla güncelledim, ancak bu hatayı derlerken aldım

java.lang.IncompatibleClassChangeError: Org.jetbrains.kotlin.backend.common.extensions.IrPluginContext arabirimi bulundu, ancak androidx.compose.plugins.kotlin.ComposeIrGenerationExtension.generate (ComposeIrGenerationExtension.kt: 41)

Android stüdyosunun canary versiyonunu da indirdim

build.gradle projesi

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
  ext.kotlin_version = "1.4.0-rc"
  repositories {
    google()
    jcenter()
    maven{
      url "https://dl.bintray.com/kotlin/kotlin-eap/"
    }
  }
  dependencies {
    classpath "com.android.tools.build:gradle:4.0.1"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

allprojects {
  repositories {
    google()
    jcenter()
    maven{
      url "https://dl.bintray.com/kotlin/kotlin-eap/"
    }
  }
}

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

build.gradle uygulaması

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
  compileSdkVersion 30
  buildToolsVersion "30.0.1"

  defaultConfig {
    applicationId "com.jetpackcompose"
    minSdkVersion 22
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  }

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

  buildFeatures {
    // Enables Jetpack Compose for this module
    compose true
  }

  // Set both the Java and Kotlin compilers to target Java 8.

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  kotlinOptions {
    jvmTarget = '1.8'
  }

    composeOptions {
      kotlinCompilerVersion kotlin_version
      kotlinCompilerExtensionVersion "0.1.0-dev13"
    }
  }

  dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'


    implementation 'androidx.ui:ui-core:0.1.0-dev13'
    implementation 'androidx.ui:ui-tooling:0.1.0-dev13'
    implementation 'androidx.ui:ui-layout:0.1.0-dev13'
    implementation 'androidx.ui:ui-material:0.1.0-dev13'


    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
  }


tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
  kotlinOptions {
    jvmTarget = "1.8"
    freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
  }
}

Ama uygulamayı derleyemiyorum, temel örneği çalıştırmaya çalışıyorum

class MainActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent{
        sayHello()
    }
  }

  @Preview
  @Composable
  fun sayHello(){
    Text("Hello World")
  }
}

Bu hatanın neden atıldığını bilen var mı?

Yanıtlar

DenysNykyforov Aug 18 2020 at 12:02

Compose sürümünü olarak güncellemeyi deneyin 0.1.0-dev16. Görünüşe göre 0.1.0-dev13Kotlin ile uyumlu değil1.4-rc

3 oiyio Dec 05 2020 at 21:15

1.4.20 yerine Kotlin 1.4.10 sürümünü kullanmak sorunumu çözdü.