Hello All, Facing an error while trying to use co...
# compose
g
Hello All, Facing an error while trying to use compose 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/~~BzN_IRidzKvmf62uFiBXDw==/com.graymatrix.did-sS4KMabqpUrHzNaHQrYCaA==/base.apk) at com.zee5.ComposeActivity.onCreate(ComposeActivity.kt:13) at android.app.Activity.performCreate(Activity.java:8006) at android.app.Activity.performCreate(Activity.java:7990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3584) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3775) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2246) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:233) at android.app.ActivityThread.main(ActivityThread.java:8010) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978) ******************************************************************************************** build.gradle
Copy code
buildFeatures {
    compose = true
    buildConfig = true
    viewBinding = true
}

compileOptions {
    isCoreLibraryDesugaringEnabled = true
    sourceCompatibility = Versions.java
    targetCompatibility = Versions.java
}

kotlinOptions {
    jvmTarget = Versions.java.name
}
composeOptions {
    kotlinCompilerExtensionVersion = Versions.kotlinCompilerExtension
    kotlinCompilerVersion = Kotlin.version
}
kotlin version 1.5.20 compose version 1.0.0-rc02
🧵 5
l
are you sure all of your
implementations
use the correct compose version? Have had a similar issue recently, fixed by changing some compose imports to use the same version
g
@Lukasz Burcon Yes I am using same version for all compose libraries
any idea on how to fix this?
l
Make sure your activity extends
ComponentActivity
?
g
Yes, I did extended my activity from ComponentActivity. Even below sample Does not work.
l
No idea then ;_; Try generating a new sample project and see if anything changes
g
On Sample Project it works perfectly fine
l
show me your build.gradle
or compare it with your working sample 😛
d
Are you using gradle buildSrc by any chance?
g
Yes @Daniel Rampelt. I am using buildSrc
d
I ran into the same issue, you need to have the kotlin gradle plugin in the buildSrc build.gradle file for Compose to work https://kotlinlang.slack.com/archives/CJLTWPH7S/p1623270940306300 https://issuetracker.google.com/issues/176079157#comment11
g
Thanks @Daniel Rampelt. Resolved this issue, However, now it is asking me to add ViewTreeLifecycleOwner on activity’s parent layout. I am trying to add ComposeView to the Fragments.
y
Waow... thanks, just lost 1 hour on this ... Still happening with updated dependencies