Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception during code generation Jetpack Compose

Tags:

I just tried to load an image from my resources with val context = ambient(ContextAmbient) but when I try to run the project I get an error during the generation of the code.

java.lang.IllegalStateException: Backend Internal error: Exception during code generation

@Composable
fun MovieImage(image: Int) {
    val context = ambient(ContextAmbient)
    Container(modifier = Modifier.None, width = 24.dp, height = 24.dp) {
        DrawImage(image = imageFromResource( context.resources, image))
    }
}
like image 738
Amancaya Iriarte Negron Avatar asked Feb 10 '20 01:02

Amancaya Iriarte Negron


People also ask

What is mutableStateOf in jetpack compose?

mutableStateOf creates an observable MutableState<T> , which is an observable type integrated with the compose runtime. interface MutableState<T> : State<T> { override var value: T. } Any changes to value will schedule recomposition of any composable functions that read value .

What is LazyColumn in jetpack compose?

A LazyColumn is a vertically scrolling list that only composes and lays out the currently visible items. It's similar to a Recyclerview in the classic Android View system.

What is @preview in jetpack compose?

The preview functionality of Jetpack Compose is one of the key parts of development UI with this technology because the infrastructure for preview changes in composable code is integrated into Android Studio. However, you can often see that developers don't use all the features that the @Preview annotation provides.

Is jetpack compose reactive?

Jetpack Compose is a modern toolkit designed to simplify UI development. It combines a reactive programming model with the conciseness and ease of use of the Kotlin programming language. It is fully declarative, meaning you describe your UI by calling a series of functions that transform data into a UI hierarchy.


1 Answers

I ran in to the same problem when upgrading from 0.1.0-dev03 to 0.1.0-dev05. It was solved by adding composeOptions{ kotlinCompilerExtensionVersion "0.1.0-dev05" } to my build.gradle like this:

android {
    // ... other gradle properties

    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion "0.1.0-dev05"
    }
}
like image 84
Michiel Dral Avatar answered Sep 30 '22 18:09

Michiel Dral