我已经查看了相同错误的问题,但我正在实施答案中给出的所有解决方案,但我的 logcat 中出现以下错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.overview.LoginActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.test.base.BaseActivity$ProgressDialogFragment: make sure class name exists, is public, and has an empty constructor that is public
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4950)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.mint.test.base.BaseActivity$ProgressDialogFragment: make sure class name exists, is public, and has an empty constructor that is public
at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
at android.support.v4.app.FragmentState.instantiate(Fragment.java:96)
at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1726)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:198)
at com.mint.test.base.BaseActivity.onCreate(BaseActivity.java:88)
at com.mint.test.base.BaseActivity.onCreate(BaseActivity.java:84)
at com.test.base.FlipperActivity.onCreate(FlipperActivity.java:56)
at com.test.overview.LoginActivity.onCreate(LoginActivity.java:99)
at android.app.Activity.performCreate(Activity.java:5179)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
... 11 more
Caused by: java.lang.IllegalAccessException: access to constructor not allowed
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.support.v4.app.Fragment.instantiate(Fragment.java:384)
... 21 more
在我的代码中,我有以下内容:
@SuppressLint({ "ValidFragment", "UseSparseArrays" })
public abstract class BaseActivity extends FragmentActivity {
//The class is static and public
public static class ProgressDialogFragment extends DialogFragment {
public ProgressDialogFragment() {} //Empty Constructor
}
}
有人可以帮我确定问题所在吗?
谢谢。