trying to update from kotlin-inject-anvil 0.0.5 to...
# kotlin-inject
j
trying to update from kotlin-inject-anvil 0.0.5 to 0.1.0 and having an issue. i have a reproducible sample but i'm not sure if its just an issue with my coding or something broken in kotlin-inject or kotlin-inject-anvil
you can see if you run
./gradlew build
you get this error
Copy code
> Task :shared:compileKotlinJvm FAILED
e: kiaerror/shared/src/commonMain/kotlin/com/example/kiaerror/AppComponent.kt:13:5 Unresolved reference 'AppComponentMerged'.

> Task :shared:verifyReleaseResources
> Task :shared:kspReleaseKotlinAndroid
> Task :shared:kspDebugKotlinAndroid

> Task :shared:compileDebugKotlinAndroid FAILED
e: kiaerror/shared/src/commonMain/kotlin/com/example/kiaerror/AppComponent.kt:13:5 Unresolved reference 'AppComponentMerged'.

> Task :shared:compileReleaseKotlinAndroid FAILED
e: kiaerror/shared/src/commonMain/kotlin/com/example/kiaerror/AppComponent.kt:13:5 Unresolved reference 'AppComponentMerged'.

FAILURE: Build completed with 3 failures.
i put in the example with the
expect interface AppComponentMerged2
as that is how i'm fixing this in
0.0.5
however in
0.1.0
it is an error not to directly implement that interface
Copy code
[ksp] kiaerror/shared/src/commonMain/kotlin/com/example/kiaerror/AppComponent.kt:11: AppComponent is annotated with @MergeComponent and @Component. It's required to add AppComponentMerged as super type to AppComponent. If you don't want to add the super manually, then you must remove the @Component annotation.
happy to file a bug on whichever project may be the problem, or could just be that i'm doing this wrong here
e
j
yes, that is the error. i'm wondering what i'm doing wrong here though cause if i don't extend
AppComponentMerged
I get that compile error but if I do my app won't compile
e
I can't download the zip now, so can you send what your AppComponent looks like
j
Copy code
@AppScope
@Component
@MergeComponent(AppScope::class)
internal abstract class AppComponent(
    @Component val clientComponent: ClientComponent,
) : AppComponentMerged
Copy code
@NetworkScope
@Component
abstract class ClientComponent {
    @NetworkScope
    @Provides
    fun provideNetworkScopeObject(): NetworkScopeObject {
        return NetworkScopeObject()
    }
}
both the
*Scope
classes are annotations with the
@Scope
annotation
e
I believe in 0.1.0 you're supposed to remove
@Component
and not extend
AppComponentMerged
. If you remove both of those do you still get an error?
j
Copy code
[ksp] kiaerror/shared/src/commonMain/kotlin/com/example/kiaerror/AppComponent.kt:10: Contributed component interfaces must be public.
so i can't have
internal
components anymore i guess?
e
Yeah I just hit that as well 🙁
j
though it also seems to have an issue even if i remove internal
Copy code
@AppScope
@MergeComponent(AppScope::class)
abstract class AppComponent(
    @Component val clientComponent: ClientComponent,
) {
    abstract val networkScopeObject: NetworkScopeObject
}
that fails to find my
NetworkScopeObject
despite
ClientComponent
being a child component
e
Looks like we're headed down the same road 😅 I was able to get it to work using
ContributesSubcomponent
Not sure if this is a bug or WAI... @ralf?
Is
ClientComponent
also a
MergeComponent
?
j
not in my use-case
e
So just a regular
@Component
?
r
so i can’t have
internal
components anymore i guess?
No, because in 99% of the cases this is the wrong thing to do.
1
I have a hard time following the issue. I suggest to file a ticket, but please don’t attach a .zip file and create a repo on Github instead.
j
r
Thanks, I responded on Github. It’s a bug.
👍 1