Status Update
Comments
mm...@commonsware.com <mm...@commonsware.com> #2
And create a non-compose app will just works fine.
lu...@gmail.com <lu...@gmail.com> #3
ch...@google.com <ch...@google.com> #4
Same issue here, app crashes on start when using android-gradle 7.1.0-alpha04 and AS Canary 4
mm...@commonsware.com <mm...@commonsware.com> #5
aurimas@, are you the right person for triaging Android Studio version-specific issues? I saw you upgraded AndroidX to Bumblebee Canary 3 last week. This bug report might be specific to Bumblebee Canary 4, I'm not certain.
[Deleted User] <[Deleted User]> #6
Tested this quickly locally, it seems that the studio template creates a project that crashes out of the box. Updating compose_version to 1.0.0-rc02
and kotlin-gradle-plugin to 1.5.10
fixed the crash for me locally. We likely want to update studio template to use the latest of compose and kotlin.
cl...@google.com <cl...@google.com>
ap...@google.com <ap...@google.com> #7
Moving to studio component for triage.
This is a pretty bad user experience so ccing annachiarab@ to make sure this gets attention
Description
Android Studio 3.5 Beta 1
Build #AI-191.6707.61.35.5677133, built on June 20, 2019
JRE: 1.8.0_202-release-1483-b39-5396753 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.0.0-25-generic
(specifically the one from the Compose repo)
Version of Gradle Plugin: 3.5.0-beta05
Version of Gradle: whatever frameworks/support/ui is using -- your setup is too damn complicated...
Version of Kotlin: 1.3.41
OS: Ubuntu 19.04
Steps to Reproduce:
Step #1: Define a @Model as a top-level class:
@Model
data class AgreementViewState(var terms: Boolean, var privacy: Boolean) {
val canProceed = terms && privacy
}
Step #2: Attempt to use that @Model in a @Composable:
@Composable
private fun Agreement() {
Padding(8.dp) {
val viewState = +model { AgreementViewState(true, false) }
Column(mainAxisAlignment = MainAxisAlignment.Start, crossAxisAlignment = CrossAxisAlignment.Start) {
Row(mainAxisAlignment = MainAxisAlignment.Start) {
Checkbox(
checked = viewState.terms,
onCheckedChange = { viewState.terms = it }
)
Text(text = "I agree to the terms and conditions")
}
Row(mainAxisAlignment = MainAxisAlignment.Start) {
Checkbox(
checked = viewState.privacy,
onCheckedChange = { viewState.privacy = it }
)
Text(text = "I agree to the privacy policy")
}
Text(text = if (viewState.canProceed) "You may proceed" else "Please indicate your agreement")
}
}
}
Expected Results: No crashes
Actual Results: A crash from generated code when the @Composable is called:
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter r
at androidx.compose.frames.FramesKt._readable(Unknown Source:2)
at androidx.ui.foundation.demos.AgreementViewState.getTerms(Unknown Source:5)
at androidx.ui.foundation.demos.AgreementViewState.<init>(MainActivity.kt:230)
Note that this works:
@Model
data class AgreementViewState(var terms: Boolean, var privacy: Boolean) {
fun canProceed() = terms && privacy
}
...and this works:
@Model
data class AgreementViewState(var terms: Boolean, var privacy: Boolean) {
// fun canProceed() = terms && privacy
}
val AgreementViewState.canProceed
get() = terms && privacy
But, IMHO, the original form ought to work as well, as it seems to be the most natural form of a derived property in Kotlin.
Thanks for considering this!