You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started getting this error after updating Hilt from 2.32-alpha to 2.33-beta. The error occurs because of i use function in BaseActivity named init
I think the problem is Hilt is already using a function named initt and this function conflicts with my function. The problem is fixed after changing the name of the init function. But i don't wanna change it's name.
Note: This problem is not happening in Fragments.
Base Activity.
abstract class BaseActivity<DB : ViewDataBinding, VM : BaseViewModel> : AppCompatActivity() {
@get:LayoutRes
protected abstract val layoutResourceId: Int
protected abstract val classTypeOfViewModel: Class<VM>
lateinit var binding: DB
lateinit var viewModel: VM
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewModel = ViewModelProvider(this).get(classTypeOfViewModel)
binding = DataBindingUtil.setContentView(this, layoutResourceId)
binding.lifecycleOwner = this
init()
...
}
open fun init() {}
...
Activity which uses Hilt and extends Base Activity.
@AndroidEntryPoint
class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
override val layoutResourceId: Int = R.layout.activity_main
override val classTypeOfViewModel: Class<MainViewModel> = MainViewModel::class.java
override fun init() {
binding.mainVm = viewModel
binding.navView.setupWithNavController(navController)
}
...
This is the class which gives the error
public abstract class Hilt_MainActivity<DB extends ViewDataBinding, VM extends BaseViewModel> extends BaseActivity<DB, VM> implements GeneratedComponentManagerHolder {
private volatile ActivityComponentManager componentManager;
private final Object componentManagerLock = new Object();
private boolean injected = false;
Hilt_MainActivity() {
super();
init();
}
// I'M GETTING THE ERROR IN THIS FUNCTION
private void init() {
addOnContextAvailableListener(new OnContextAvailableListener() {
@Override
public void onContextAvailable(Context context) {
inject();
}
});
}
The text was updated successfully, but these errors were encountered:
Sorry about that! Yeah, this is related to the Activity injection timing changes mentioned in the 2.33 release notes, so it only affects Hilt activities.
I think you're right, we should rename our init method something like hiltInit to avoid conflicts with common user method names.
…r method of same name.
Fixes#2456
RELNOTES="Fix#2456: Rename init() method in generated Activity to avoid conflict with user method of same name."
PiperOrigin-RevId: 361156462
I started getting this error after updating Hilt from 2.32-alpha to 2.33-beta. The error occurs because of i use function in BaseActivity named init
I think the problem is Hilt is already using a function named initt and this function conflicts with my function. The problem is fixed after changing the name of the init function. But i don't wanna change it's name.
Note: This problem is not happening in Fragments.
Base Activity.
Activity which uses Hilt and extends Base Activity.
This is the class which gives the error
The text was updated successfully, but these errors were encountered: