我收到此错误:
java.lang.IllegalStateException: Fragment already added: MenuBottomSheetFragment{d476429 #0}
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1891)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:760)
Run Code Online (Sandbox Code Playgroud)
我的代码在打开时单击MenuBottomSheetFragment:
private void openBottomSheet() {
if (mMenuBottomSheetFragment == null)
mMenuBottomSheetFragment = new MenuBottomSheetFragment();
if (!mMenuBottomSheetFragment.isShowing())
mMenuBottomSheetFragment.show(getSupportFragmentManager(), mMenuBottomSheetFragment.getTag());
}
Run Code Online (Sandbox Code Playgroud)
我MenuBottomSheetFragment没有什么特别的。
我真的不知道为什么。大多数时候,MenuBottomSheetFragment效果很好。但是有一段时间,它抛出此异常,然后我什么也不做。
那么我的问题是什么呢?我该如何解决?
今天早上我切换到 Hilt 依赖注入。一切都完成后,我坚持了这个:
错误:找不到符号返回 DaggerMyApplication_HiltComponents_SingletonC.builder() ^ 符号:变量 DaggerMyApplication_HiltComponents_SingletonC
我确实尝试自己找到解决方案,我找到了这个解决方案,但是我已经添加了所有模块的 build.gradle 如果我做错了什么,请查看我的。
我的应用程序:
@HiltAndroidApp
class MyApplication : MultiDexApplication()
Run Code Online (Sandbox Code Playgroud)
项目摇篮:
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.34-beta'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Run Code Online (Sandbox Code Playgroud)
应用程序摇篮:
implementation 'com.google.dagger:hilt-android:2.34-beta'
kapt 'com.google.dagger:hilt-compiler:2.34-beta'
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
kapt 'androidx.hilt:hilt-compiler:1.0.0-beta01'
Run Code Online (Sandbox Code Playgroud)