error: <identifier> expected topLevelClass = BaseFragment<T, D>.class
See original GitHub issueHi Everybody, So I mentioned this yesterday on stackoverflow here i Have issues when try to use inject ViewModel to BaseFragment with by viewModels() extension so i used Factory to inject it when i do that my BaseFragment Have tow generic type and it show me that error
error: <identifier> expected topLevelClass = BaseFragment<T, D>.class ^error: [Hilt]
and the Generated Class is BaseFragment_GeneratedInjector :
@OriginatingElement(
topLevelClass = BaseFragment<T, D>.class
)
@GeneratedEntryPoint
@InstallIn(FragmentComponent.class)
@Generated("dagger.hilt.android.processor.internal.androidentrypoint.InjectorEntryPointGenerator")
public interface BaseFragment_GeneratedInjector {
void injectBaseFragment(BaseFragment baseFragment);
}
so i try this workgound in this issues
and it show same error and new Error says :
**``` [Hilt] Processing did not complete. See error above for details.error: [Hilt] @AndroidEntryPoint class expected to extend Hilt_ContactUsFragment. Found: BaseFragment
and my baseFragment is so simple :
`@AndroidEntryPoint
abstract class BaseFragment<T : ViewModel,D : ViewDataBinding>() : Fragment() {
lateinit var viewModel: T by viewModels()
}`
thanks in Advanced
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (1 by maintainers)
Top Results From Across the Web
<identifier> expected android Hilt - kotlin - Stack Overflow
You can fix this by moving @AndroidEntryPoint from abstract class with parameters into child class without type parameters.
Read more >How to Handle the <Identifier> Expected Error in Java - Rollbar
The expected error in Java occurs when an expression statement is written outside of a constructor/method/instance initialization block.
Read more >CS 111: Common Java Errors - CS-People by full name
1 error found: File: Test.java [line: 7] Error: Test.java:7: cannot find symbol symbol : variable my_method location: class Test
Read more >How to Fix Java Error – Identifier Expected - Hello Code
The identifier expected error is a compilation error, which means the code doesn't comply with the syntax rules of the Java language. For ......
Read more >Solutions to Exercises - Springer Link
compiler reports an error because the subclass constructor attempts to ... only appear in the upper levels of class hierarchies, where they are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @ayoubdevv,
Thanks for reporting this issue!
This is definitely a bug on our end. We shouldn’t be including the type parameters in
@OriginatingElement(topLevelClass = BaseFragment<T, D>.class)
. I’ll send out a fix.In the mean time, you should be able to work around this issue by putting the
@AndroidEntryPoint
annotation on the subclass instead. So something like this should work around the issue since the subclass doesn’t have type parameters itself.@8991hnim it’s likely that this is due to missing transitive dependencies in the classpath during compilation. Hilt has the aggregating task flag to fix these issues automatically. Can you try enabling the flag by adding the following in your application’s
build.gradle
file: