Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

373
Views
Al intentar componer jetpack, muestra un error: backend del compilador y el compilador anterior no puede cargarlo

La clase 'androidx.compose.ui.platform.ComposeView' es compilada por un nuevo backend del compilador de Kotlin y no puede ser cargada por el compilador anterior

Este es mi método onCreate:

 override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { return inflater.inflate(R.layout.fragment_delivered, container, false).apply { findViewById<ComposeView>(R.id.compose_view).setContent { MaterialTheme { Surface { Text("Hello") } } } } }

Componer versión:

 accompanistVersion = "0.1.9" composeVersion = '0.1.0-dev17'

aplicación.gradle

 buildFeatures { compose true dataBinding true } composeOptions { kotlinCompilerVersion rootProject.kotlinVersion kotlinCompilerExtensionVersion rootProject.composeVersion } // Compose implementation "androidx.compose.runtime:runtime:$rootProject.composeVersion" implementation "androidx.compose.ui:ui:$rootProject.composeVersion" implementation "androidx.compose.foundation:foundation:$rootProject.composeVersion" implementation "androidx.compose.foundation:foundation-layout:$rootProject.composeVersion" implementation "androidx.compose.material:material:$rootProject.composeVersion" implementation "androidx.compose.ui:ui-viewbinding:$rootProject.composeVersion" implementation "androidx.ui:ui-tooling:$rootProject.composeVersion" implementation "androidx.compose.runtime:runtime-livedata:$rootProject.composeVersion" implementation "com.google.android.material:compose-theme-adapter:$rootProject.composeVersion" implementation "dev.chrisbanes.accompanist:accompanist-coil:$rootProject.accompanistVersion"
over 4 years ago · Hanz Gallego
5 answers
Answer question

0

Seguir los pasos de la guía de configuración oficial me llevó al mismo problema.

Agregar lasdependencias/configuración necesarias para la biblioteca de redacción solucionó este problema para mí.

over 4 years ago · Hanz Gallego Report

0

Agregue esta tarea en su archivo app/build.gradle:

 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { kotlinOptions { jvmTarget = "1.8" freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"] } }
over 4 years ago · Hanz Gallego Report

0

El app/build.grade predeterminado, al crear un nuevo proyecto con una "Actividad de redacción vacía", incluye las siguientes opciones.

 android { // other options kotlinOptions { jvmTarget = '1.8' useIR = true } // more options }

Agregar estas opciones (específicamente useIR = true ) pareció solucionar el error para mí.


La opción useIR hace referencia a unnuevo backend de JVM para Kotlin para el cual la documentación establece específicamente lo siguiente.

Si habilita Jetpack Compose, automáticamente se habilitará para el nuevo backend de JVM sin necesidad de especificar la opción del compilador en kotlinOptions .

Lo cual es aparentemente incorrecto.

over 4 years ago · Hanz Gallego Report

0

versión .kts

 tasks.withType<KotlinCompile>() { kotlinOptions.jvmTarget = "1.8" kotlinOptions.freeCompilerArgs = listOf( *kotlinOptions.freeCompilerArgs.toTypedArray(), "-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check") useIR = true }
over 4 years ago · Hanz Gallego Report

0

Esta es la dependencia que causa el error respectivo en mi caso:

 androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.0.5'

Supongo que jugar con él debería ayudar.

over 4 years ago · Hanz Gallego Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!