How to inject a fragment from the package androidx.fragment.app.Fragment ?
I\'m using the dagger-android framework to inject my dependencies in
I had the same problem in case of HasFragmentInjector. You need to use HasSupportFragmentInjector for fragment injection. This is because, HasFragmentInjector
uses android.app.Fragment
which is not effected by jetifier
. You need to add android-dagger-support
library, jetifier
converts all the support packages to androidx in Studio 3.3 (if jetifier
is enabled).
If jetifier does not change support packages to androidx packages. You can download jetifier
tool from here and convert the android-dagger-support.aar file manually by using the following command.
./jetifier-standalone -i dagger-android-support-.aar -o
Then add the library to your project. This is the HasSupportFragment class after conversion
import androidx.fragment.app.Fragment;
import dagger.android.AndroidInjector;
public interface HasSupportFragmentInjector {
AndroidInjector supportFragmentInjector();
}
Somehow, jetifier tool was not converting libraries in AndroidStudio. I had to do it manually.