Comments (5)
Hmm, I'm not able to reproduce this following the instructions in your README:
DaggerAndroidKspError-main bcorso$ ./gradlew :app:assembleDebug
BUILD SUCCESSFUL in 1s
And the generated code looks fine:
package com.example.daggerandroid;
import dagger.internal.DaggerGenerated;
import dagger.internal.Factory;
import dagger.internal.Preconditions;
import dagger.internal.QualifierMetadata;
import dagger.internal.ScopeMetadata;
import javax.annotation.processing.Generated;
@ScopeMetadata
@QualifierMetadata
@DaggerGenerated
@Generated(
value = "dagger.internal.codegen.ComponentProcessor",
comments = "https://dagger.dev"
)
@SuppressWarnings({
"unchecked",
"rawtypes",
"KotlinInternal",
"KotlinInternalInJava"
})
public final class ExampleModule_ProvideString$app_debugFactory implements Factory<String> {
private final ExampleModule module;
public ExampleModule_ProvideString$app_debugFactory(ExampleModule module) {
this.module = module;
}
@Override
public String get() {
return provideString$app_debug(module);
}
public static ExampleModule_ProvideString$app_debugFactory create(ExampleModule module) {
return new ExampleModule_ProvideString$app_debugFactory(module);
}
public static String provideString$app_debug(ExampleModule instance) {
return Preconditions.checkNotNullFromProvides(instance.provideString$app_debug());
}
}
Do you have any special configuration for your KSP setup? I think when using internal
the appended string is the JPMS module name and it looks like in your case KSP is using app.debug.ksp
rather than app.debug
.
from dagger.
You helped me resolve it. I had set kotlin.incremental.useClasspathSnapshot=false
in my local gradle.properties
file while trying out Anvil. Removing this solves the issue. That being said, I would expect the output to be the same regardless of this flag
from dagger.
Fwiw, the jvm method name is not something we control in Dagger, it's given to us by KSP's APIs so if you think it's not working correctly with your flag you could ask the KSP team.
from dagger.
@bcorso after removing this flag I ran into another issue related to internal
methods when using KSP. Basically referencing a dagger Module in a @ContributesAndroidInjector()
annotation in different gradle module will fail. I updated the reproducer project to reflect this.
I'm wondering if this is just a behavior change with KSP since it probably can't see internal
methods across gradle modules because it's respecting kotlin method visibility. Please let me know if this is expected behavior or if I should open a different issue.
e: [ksp] ComponentProcessingStep was unable to process 'com.example.daggerandroid.ExampleModule_ContributeAppClass$app_debug.AppClassSubcomponent' because '<error>' could not be resolved.
Dependency trace:
=> element (CLASS): com.example.mylibrary.LibraryModule_ContributeLibraryClass$mylibrary_debug
=> annotation type: dagger.Module
=> annotation: @dagger.Module(includes={}, subcomponents={<error>})
=> annotation value (TYPE_ARRAY): subcomponents={<error>}
=> annotation value (TYPE): subcomponents=<error>
If type '<error>' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type '<error>' is on your classpath.
e: Error occurred in KSP, check log for detail
from dagger.
Yeah, that is a different issue so might be best to just file a separate bug and keep this one closed.
The latest issue your seeing seems to be a bug in KSP (or XProcessing) where it doesn't seem to be able to handle class names that contain $
when referenced from annotations. In this case it affects the class Dagger generates from the @ContributesAndroidInjector
annotation:
@Generated
@Module(subcomponents = LibraryModule_ContributeLibraryClass$mylibrary_debug.LibraryClassSubcomponent.class)
public abstract class LibraryModule_ContributeLibraryClass$mylibrary_debug {
...
}
In particular, the LibraryModule_ContributeLibraryClass$mylibrary_debug.LibraryClassSubcomponent
type within the annotation is showing up as error
type, hence the error message you're seeing.
I can work on filing a bug to KSP, but in the meantime I think the best workaround is to just remove internal
from your @ContributesAndroidInjector
methods.
from dagger.
Related Issues (20)
- Transitive vulnerability from symbol-processing-api HOT 1
- java.lang.IllegalArgumentException: CreationExtras must have a value by `SAVED_STATE_REGISTRY_OWNER_KEY` HOT 4
- Update of different dependency: Error "package javax.annotation.processing is not visible" HOT 4
- Compile time error with KSP with Generics HOT 4
- java.lang.IllegalArgumentException: Multiple entries with same key HOT 4
- Execution failed for task ':app:kaptDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction > java.lang.reflect.InvocationTargetException (no error message) HOT 2
- Stackoverflow when exposing parents of Subcomponents HOT 7
- Hilt not working with android testFixtures? HOT 2
- Hilt 2.44.2 - Class not found when use @AndroidEntryPoint at WidgetReceiver HOT 1
- Does Dagger 2.51 support JDK17 and JDK21? HOT 1
- [KSP] Intersection type bounds are not ordered correctly in generated factories HOT 1
- [KSP] KSP mode does not check for `@Provides` on interface methods HOT 1
- [KSP] Multibinding example from developer docs does not compile under Kotlin + KSP HOT 1
- [KSP] How to pass compiler argument to KSP? HOT 4
- The lack of sprite in the Friday Night Funkin character
- Subcomponent MembersInjector error in 2.51 HOT 1
- Does Hilt always execute app module during instrumented test? HOT 3
- [KSP] Dagger-KSP does not see typealiased dagger annotations HOT 3
- Cannot invoke getAnnotationValue because "annotation" is null HOT 13
- Creator-less subcomponents are not visible to modules HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dagger.