Search code examples
androiddagger-hilt

Hilt: Inherited fragment class not generated


I've the following inheritance chain:

ZipCodeFragment:

class ZipCodeFragment : BaseUserOnboardingFragment(R.layout.user_onboarding_zip_code_fragment) { 
    // code
}

BaseUserOnboardingFragment:

abstract class BaseUserOnboardingFragment(@LayoutRes layoutRes: Int = 0) : BaseFragment(layoutRes) { 
    // code
}

BaseFragment

abstract class BaseFragment : Fragment, ErrorListener { 

    constructor() : super()
    constructor(@LayoutRes layoutRes: Int) : super(layoutRes)
}

Following the steps described here, I've annotated my ZipCodeFragment as follow:

@AndroidEntryPoint(BaseUserOnboardingFragment::class)
class ZipCodeFragment : Hilt_ZipCodeFragment(R.layout.user_onboarding_zip_code_fragment) { 
    // code
}

When compiling, I got the following error as if the Hilt class is not properly generated:

error: [Hilt]
public final class ZipCodeFragment {
             ^
  @AndroidEntryPoint class expected to extend Hilt_ZipCodeFragment. Found: Object
  [Hilt] Processing did not complete. See error above for details.

What am I missing?


Solution

  • I've found the issue: abstract class BaseUserOnboardingFragment(@LayoutRes layoutRes: Int = 0) has a default constructor parameter which is not supported yet.