58
votes

Jetpack compose sur Kotlin 1.5.0

J'ai mis à jour à Kotlin 1.5 la semaine dernière, et après avoir vu hier l'intention de Google de faire en sorte que Jetpack composent l'option préférée pour concevoir des UIS, je voulais faire des tests.

Le problème est qu'avoir mon projet Mis à jour vers Kotlin 1.5, lorsque vous essayez de construire le projet, j'obtiens l'erreur suivante:

java.lang.NoClassDefFoundError: org/jetbrains/kotlin/ir/descriptors/WrappedSimpleFunctionDescriptor
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.buildFunction(LiveLiteralTransformer.kt:842)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.irLiveLiteralGetter(LiveLiteralTransformer.kt:933)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitConst(LiveLiteralTransformer.kt:426)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitConst(IrElementTransformerVoid.kt:138)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitConst(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl.accept(IrConstImpl.kt:33)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1$3.invoke(LiveLiteralTransformer.kt:624)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1$3.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$enter(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1.invoke(LiveLiteralTransformer.kt:623)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitCall(LiveLiteralTransformer.kt:612)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:199)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1$3.invoke(LiveLiteralTransformer.kt:624)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1$3.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$enter(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1.invoke(LiveLiteralTransformer.kt:623)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitCall(LiveLiteralTransformer.kt:612)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:199)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitBranch$1.invoke(LiveLiteralTransformer.kt:738)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitBranch$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitBranch(LiveLiteralTransformer.kt:737)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBranch(IrElementTransformerVoid.kt:255)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBranch(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.impl.IrBranchImpl.transform(IrWhenImpl.kt:56)
    at org.jetbrains.kotlin.ir.expressions.IrWhen.transformChildren(IrWhen.kt:37)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpression(IrElementTransformerVoid.kt:131)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitWhen(IrElementTransformerVoid.kt:247)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitWhen$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitWhen$1.invoke(LiveLiteralTransformer.kt:705)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitWhen$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor$siblings$1.invoke(DurableKeyVisitor.kt:131)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:131)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.siblings(LiveLiteralTransformer.kt:192)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitWhen(LiveLiteralTransformer.kt:704)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitWhen(IrElementTransformerVoid.kt:248)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitWhen(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.IrWhen.accept(IrWhen.kt:29)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:26)
    at org.jetbrains.kotlin.ir.expressions.IrBlockBody.transformChildren(IrBody.kt:62)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBody(IrElementTransformerVoid.kt:108)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitBlockBody$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitBlockBody$1.invoke(LiveLiteralTransformer.kt:795)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitBlockBody$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.siblings(LiveLiteralTransformer.kt:193)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitBlockBody(LiveLiteralTransformer.kt:794)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:118)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBody.kt:54)
    at org.jetbrains.kotlin.ir.expressions.IrBody.transform(IrBody.kt:27)
    at org.jetbrains.kotlin.ir.declarations.IrFunction.transformChildren(IrFunction.kt:69)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:57)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFunction(IrElementTransformerVoid.kt:69)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:72)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitSimpleFunction$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitSimpleFunction$1.invoke(LiveLiteralTransformer.kt:654)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitSimpleFunction$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitSimpleFunction(LiveLiteralTransformer.kt:654)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:73)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:29)
    at org.jetbrains.kotlin.ir.IrElement$DefaultImpls.transform(IrElement.kt:32)
    at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:19)
    at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
    at org.jetbrains.kotlin.ir.declarations.IrClass.transformChildren(IrClass.kt:67)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:57)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:66)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitClass$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitClass$1.invoke(LiveLiteralTransformer.kt:450)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitClass$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor$siblings$1.invoke(DurableKeyVisitor.kt:131)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:131)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.siblings(LiveLiteralTransformer.kt:192)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitClass(LiveLiteralTransformer.kt:449)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:67)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:56)
    at org.jetbrains.kotlin.ir.IrElement$DefaultImpls.transform(IrElement.kt:32)
    at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:19)
    at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.transformChildren(IrFileImpl.kt:71)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitPackageFragment(IrElementTransformerVoid.kt:41)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:47)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitFile$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitFile$1.invoke(LiveLiteralTransformer.kt:496)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitFile$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.root(DurableKeyVisitor.kt:152)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitFile(LiveLiteralTransformer.kt:463)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:48)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.accept(IrFileImpl.kt:63)
    at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.kt:48)
    at org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl.transformChildren(IrModuleFragmentImpl.kt:45)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:330)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.lower(LiveLiteralTransformer.kt:169)
    at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:80)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$convertToIr$1.invoke(JvmIrCodegenFactory.kt:120)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$convertToIr$1.invoke(JvmIrCodegenFactory.kt:116)
    at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:91)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:140)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$default(JvmIrCodegenFactory.kt:66)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:61)
    at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:592)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:212)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:155)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:386)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:110)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:303)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:99)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:124)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:74)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1659)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 164 more

Kotlin 1.5 est-il incompatible avec Jetpack Compose? Après avoir googlé le problème, j'ai trouvé le 1.5.0-m2 Libération, qui mentionne la composition de Jetpack, mais pas d'une manière" incompatible ".

avez-vous une réponse à cela? Dois-je utiliser suppresskotlinversionCompatibilityCheck ? Dans ce cas, puis-je l'ajouter directement à Android.kotlinOptions dans le fichier build.gradle du module?

Merci d'avance.

modifier 1: J'ai trouvé que je devrais ajouter SupresskotLinversionCompatibilitéCHECK en tant que constructeur arg:

android {
    ...
    kotlinOptions {
        ...
        freeCompilerArgs += [
            "-P",
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"
        ]
        ...
    }
    ...
}

Mais il ne compila toujours pas, j'obtiens cette erreur du compilateur:

This version (1.0.0-beta07) of the Compose Compiler requires Kotlin version 1.4.32 but you appear to be using Kotlin version 1.5.0 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).


15 Réponses :


59
votes

Mise à jour :

merci @samuel luãs pour Trouver un tableau de compatibilité Composé à Kotlin https://developer.android.com/Jetpack/androidx/releases/compose-com KOTLIN


mise à jour : Androidx ..compose.comPiler: Compiler: 1.0.0-beta08 est publié (2 juin, 2021).

À partir de cette version, la version attendue de Kotlin est 1.5.10 .

dependencies {
    implementation "androidx.compose.compiler:compiler:1.0.0-beta08"
}

android {
    buildFeatures {
        compose true
    }

    composeOptions {
        kotlinCompilerVersion "1.5.10"
        kotlinCompilerExtensionVersion "1.0.0-beta08"
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }
}

Voir plus:


Composer Compiler 1.0.0-beta07 ne prend pas en charge Kotlin 1.5.0 .

et j'ai trouvé que les modifications de la prise en charge de Kotlin 1.5.0 ont fusionné, mais pas encore publié.

https://android-review.googlesource.com/c/platform/frameworks/support/+/1651538

> Pour ce moment, à mon avis, vous devez utiliser 1.4.3 et attendre la version suivante ( 1.0.0: beta08 ou 1.0.0 code>)


9 commentaires

Compose_version = '1.0.0-beta09'


Notez que kotlincompilerversion peut être supprimé en toute sécurité . Compose utilise désormais le compilateur Kotlin défini dans votre buildScript .


Comme mentionné dans une réponse ci-dessous, vous pouvez mettre à jour la version Kotlin dans votre buildScript: classpath "org.jetbrains.kotlin: Kotlin-Gradle-Plugin: 1.5.10"


Utilisez simplement KotlinCompileRextensionVersion 1.0.0


L'utilisation de KotlinCompilerVersions dans ComposeOptions a été obsolète, après quoi Compose vient d'utiliser la version Kotlin définie dans le fichier de build au niveau du projet. Maintenant, même cela semble être obsolète, car à compose 1.0.1, il n'y a pas de version Kotlin spécifiée dans le buildScript. Comment le mettre à jour maintenant? En fait, «où»? Je ne suis pas en mesure de construire un projet.


Dois-je réintégrer ma version Kotlin de 1.5.21 à 1.5.10 InOrder pour utiliser la dernière version stable de Jetpack Compose ?. Y a-t-il une autre meilleure solution?


@Marsk, je l'ai changé dans le fichier settings.gradle et cela fonctionne.


Oui, c'est la dernière façon de le faire. Nous devons modifier la dépendance JetBrains dans Settings.gradle Fichier. J'ai même eu une question à ce sujet, je copierai le lien et / ou l'explication en tant que réponse.


Voici une table avec la version du compilateur par version de Kotlin Developer.Android.com/jetpack/ AndroidX / Releases / Compose-Kotl‌ dans



8
votes

[mise à jour] Compose_version = '1.0.0' est désormais stable pour Kotlin 1.5.10

buildscript {
    ext {
        compose_version = '1.0.0'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
    }
}


2 commentaires

Compose_version = '1.0.0-beta09' est maintenant disponible pour Kotlin 1.5


Vous avez raison, j'ai obtenu ce kotlin 1.5.10 erreurs de compatibilité corrigées en déplaçant toutes les dépendances composées à 1.0.0 , merci!



7
votes

Cette version (1.0.0-beta07) du compilateur Compose nécessite Kotlin version 1.4.32 mais vous semblez utiliser Kotlin version 1.5.0 qui n'est pas connu pour être compatible. Veuillez corriger votre configuration (ou suppresskotLinversionCompatibilityCheck mais ne dites pas que je ne vous ai pas averti!)

Cette version (1.0.0-beta08) du compilateur Compose nécessite Kotlin version 1.5.10 mais vous semblez utiliser Kotlin version 1.4.31 qui n'est pas connu pour être compatible. Veuillez corriger votre configuration (ou suppresskotLinversionCompatibilityCheck mais ne dites pas que je ne vous ai pas averti!).

  • La version 1.0.0-beta07 nécessite Kotlin 1.4.32

  • La version 1.0.0-beta08 nécessite Kotlin 1.5.10


0 commentaires

2
votes

Mon problème résolu en rétrogradant Kotlin de 1.5.20 à 1.5.10 , et ajoutant kotlincompilerversion "1.5.10" à ComposeOptions dans build.gradle fichier. Comme ceci:

composeOptions {
    kotlinCompilerVersion "1.5.10"
    kotlinCompilerExtensionVersion '1.0.0-rc01'
}


0 commentaires

3
votes

Consultez cette même question ici où spécifier la version kotlin pour compose comme compose 1.0.1?

Depuis Compose 1.0.1, et la dernière mise à jour de Studio Bumblebee (à partir de maintenant), la version requise de Kotlin requise par Compose est 1.5.10, mais la mise à jour de Bumblebee ne contient pas la déclaration de la version Kotlin même dans le BLOCKScript Bloc. Maintenant, vous devez modifier la dépendance déclarée dans le fichier Settings.gradle , qui est également là que le studio le reprend. Maintenant, veuillez noter que même si vous avez déclaré la version correcte dans le bloc buildScript dans le fichier de build au niveau du projet, le projet ne se compilera pas car le studio va toujours récupérer la version du même endroit.

De plus, si vous avez du mal à découvrir quelle version est requise par la version respective de Compose, vous pouvez faire le projet, et lorsqu'il échoue, il y a une option à exécuter avec < Code> scan pour voir la sortie du journal complète, qui expose la même chose. Alternativement, vous pouvez simplement le modifier dans les paramètres en faire la valeur par défaut.


0 commentaires

15
votes
  • Dans le fichier build.gradle (projet):

    Modifier classpath "org.JetBrains.kotlin: Kotlin-Gradle-Plugin: 1.5.0"

    à classpath "org.jetbrains.kotlin: kotlin-gradle-Plugin: 1.5.21"

  • Dans le fichier build.gradle (app):

    composeOptions {
                kotlinCompilerExtensionVersion compose_version
                kotlinCompilerVersion kotlin_version
            }
    

1 commentaires

"ComposeOptions.kotlinCompilerVersion est obsolète. Compose utilise désormais le compilateur Kotlin défini dans votre buildScript."



0
votes

J'obtiens l'erreur comme celle-ci

E: Cette version (1.0.0) du compilateur Compose nécessite Kotlin Version 1.5.10 Mais vous semblez utiliser Kotlin version 1.5.20 qui n'est pas connu pour être compatible. Veuillez corriger votre configuration (ou suppresskotlinversionCompatibilitéCheck mais ne dites pas que je n'ai pas averti vous!).

puis j'ouvre le build.gradle (projet) et change

classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10' 

à ce

classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'          
N'oubliez pas de synchroniser et d'exécuter le projet. J'espère que cela fonctionne aussi en vous!


0 commentaires

1
votes

J'ai eu ce problème en essayant de migrer l'ancien projet à composer. Pour moi, la solution était de créer une activité de composition. Cela peut être fait à la main ou vous pouvez créer une activité de composition vide de la galerie.


0 commentaires

36
votes

C'est ce que j'ai fait avec la dernière version Compose comme jusqu'à ce que j'écrive aujourd'hui.

Compose_version = '1.2.0-alpha01'

1) Supprimer la ligne suivante si vous existe, vous n'en avez pas besoin: Entrez la description de l'image ici

2) Mettez à jour votre version Kotlin avec la version finale si nécessaire comment le faire -> Cliquez ce lien

3) Enfin dans build.gradle (: project) Mettre à jour la version Compose:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"

et gradle plugin:

ext {
    compose_version = '1.2.0-alpha01'
}

Vous ne devriez pas avoir d'avertissements avec la dernière version.


2 commentaires

Fonctionne pour moi merci mec!


Si vous ne souhaitez pas utiliser une version alpha de la bibliothèque 1.1.1 est également compatible avec Kotlin 1.6.10. Vous pouvez consulter la carte de compatibilité complète de Kotlin ici: développeur.android.com/ jetpack / androidx / releases / compose-kotl‌ dans



-2
votes

Faire tout (supérieur de cette page) https://stackoverflow.com/a/69508800/13432944 et voyez principalement ces lignes

composeOptions {
    kotlinCompilerExtensionVersion "1.0.4"
}

capture d'écran du studio Android


1 commentaires

Comme il est actuellement écrit, votre réponse n'est pas claire. S'il vous plaît modifier pour ajouter des détails supplémentaires qui aideront les autres à comprendre comment cela répond à la question posée. Vous pouvez trouver plus d'informations sur la façon d'écrire de bonnes réponses dans le centre d'aide .



0
votes

a fait face à ce problème lors de l'ajout d'un nouveau module. Le correctif a ajouté ce qui suit au nouveau module:

buildFeatures {
  compose true
}

composeOptions {
  kotlinCompilerExtensionVersion compose_version
}

1.0.0-beta07 semble être ce qu'il choisit lorsqu'aucune version n'est sélectionnée.


0 commentaires

0
votes

a fait face à ce problème tout en mettant à jour la version Kotlin de 1.6.10 à 1.6.20

et a corrigé la mise à jour compose_version de 1.1.1 à 1.2.0-alpha08


0 commentaires

1
votes

Pour moi, la modification du niveau du projet build.gradle avec la version requise de Kotlin (qui est mentionnée dans le message d'erreur) a résolu le problème.

par exemple: Mon message d'erreur se lisait:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"

J'ai donc modifié la version kotlin à 1.6.10 comme ci-dessous:

This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.5.21 which is not known to be compatible. Please fix your configuration

et Mon problème a été résolu


0 commentaires

0
votes

Les travaux avec le plugin Kotlin 1.6.21 :

composeOptions {
    kotlinCompilerExtensionVersion "1.2.0-rc01"
    kotlinCompilerVersion "1.6.21"
}


0 commentaires

1
votes

Pour moi, j'ai raté l'ajout des lignes ci-dessous.

composeOptions {
    kotlinCompilerExtensionVersion compose_version
}


0 commentaires