Did Google update the DrawImage portion of the jetpack compose API?

  • Thread starter Thread starter greySky
  • Start date Start date
  • Tags Tags
    Google
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
greySky
Messages
4
Reaction score
2
https://developer.android.com/jetpack/compose/tutorial
in the "Add a picture" section

[CODE highlight="8"]@Composable
fun NewsStory(){
val image = +imageResource(R.drawable.header)
Column (modifier = Spacing(64.dp)){
Text("A day in shark fin cove")
Text("davenport")
Text("december 2018")
DrawImage(image)
}
}[/CODE]

Hovering over DrawImage shows: "Unresolved reference: DrawImage", There is no auto import option for this error as there was with "Column" earlier in the tutorial.

I am using Android Studio 4.0 Canary 8
Is my local setup or the linked tutorial out of date? what is the current method to add an image

PS
I actually had two problems, "R.drawable.header" had some error I cannot remember the error text for this error but applying
https://stackoverflow.com/a/49743044
fixed the issue with R.drawable.header", but the DrawImage error persisted.
 
Physics news on Phys.org
found the answer:
[CODE title="build.gradle (:app) [excerpt]" highlight="5"]dependencies {

...
implementation 'androidx.ui:ui-material:0.1.0-dev03'
implementation 'androidx.ui:ui-foundation:0.1.0-dev03'
implementation 'androidx.ui:ui-tooling:0.1.0-dev03'
...

}[/CODE]

Line 5 was missing in the default build.gradle (:app). Adding the line enables the auto-add-import-statement option (under alt-enter like most jetbrains IDEs)

I suppose adding the line for "foundation" (after searching the androidx reference for DrawImage)
https://developer.android.com/reference/kotlin/androidx/ui/foundation/package-summary
would make sense to experienced developers. However following a naive path through the existing tutorial and setup instructions does not make this obvious.
 
  • Like
Likes   Reactions: jim mcnamara