Closed CYF-66 closed 7 months ago
any relation with Koin?
If you initialize the AImpl() instance directly, do the same in step 5 below a.C() a.B() Everything was fine. There were no errors, Do you know why? @arnaudgiuliani Step 5
.......
private val a: A by inject()
change to
private val a = AImpl()
...... setContent { GrpcDemoTheme { a.C() a.B() } }
I would say it's about Compose here, but not sure to understand well. Please use the "code block" to help us read :)
I've described the whole process in detail here, so you can take a look @arnaudgiuliani
can you try without Koin, to declare those Composables?
Hey guys I have a issue and would like your help, thank you
When defining a method with @composeable annotations in the interface, the object is obtained by inject() or get(), but the method with the @composeable annotation cannot be found when used
Step 1
Step 2
Step 3
Step 4
Step 5
a.C()
work fine ,a.B()
will crash The following error is reported:FATAL EXCEPTION: main Process: com.freddy.sample, PID: 26329 java.lang.NoSuchMethodError: No interface method
B
(Landroidx/compose/runtime/Composer;I)V in class Lcom/freddy/sample/A
; or its super classes (declaration of 'com.freddy.sample.A
' appears in /data/data/com.freddy.sample/code_cache/.overlay/base.apk/classes8.dex)Step 6
Change the method of obtaining an object from
by inject()
to direct instantiation ofAImpl()
, and the code is as followsa.C()
work fine ,a.B()
work fine Everything was fineQuestion
This can be seen by comparing steps 5 and 6 , Is it that when an interface defines a method with a @composeable annotation, you can't get the method
by inject()
orget()
. , If you initialize the AImpl() instance directly, everything was finekoinVersion = "3.1.2"