https://kotlinlang.org logo
#compose
Title
# compose
a

Android75

07/28/2022, 1:03 PM
I ' am tryng to use compose in a old project.. i ’ am using: Koltin 1.7.10
Copy code
kotlinOptions.jvmTarget = "11"
Copy code
buildFeatures {
    compose = true
}
composeOptions {
    kotlinCompilerExtensionVersion =  "1.3.0-rc01"
}
Copy code
"androidx.compose.ui:ui:1.2.0"
"androidx.compose.material:material:1.2.0"
"androidx.compose.ui:ui-tooling-preview:1.2.0"
"androidx.activity:activity-compose"1.3.1"
here my actiivy
Copy code
class MyActivityCompose : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            Greeting("Android")
        }
    }

 }

 @Composable
 fun Greeting(name: String) {
    Text(text = "Hello $name!")
}
ad i have this error java.lang.NoSuchMethodError: No static method setContent$default(Landroidx/activity/ComponentActivity;Landroidx/compose/runtime/CompositionContext;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V in class Landroidx/activity/compose/ComponentActivityKt; or its super classes (declaration of ‘androidx.activity.compose.ComponentActivityKt’ appears in /data/app/~~Ft9dSkXEHEzaK6HUxVW0Mw==/com.xxx.xxx.preprod-G6wAmGkpV4l7HVqxZrBhrg==/base.apk)
c

Colton Idle

07/29/2022, 4:16 AM
Does this old project use buildSrc?
s

svenjacobs

07/29/2022, 6:32 AM
activity-compose:1.3.1
is very old. Try to use
1.5.1
which is the current stable version.
c

Colton Idle

07/29/2022, 7:41 AM
error message seems similar to what i reported a while back. its likely a buildsrc/gradle issue. see here for a solution: https://issuetracker.google.com/issues/176079157
86 Views