我得到
java.lang.RuntimeException:无法启动活动 ComponentInfo {com.cygnet.monesmartstore / com.cygnet.mone.views.activities.SplashScreenActivity}: java.lang.NullPointerException:尝试调用虚拟方法'void com.cygnet.mone.views.widgets.ErrorView.setOnRetryListener(com.cygnet.mone.views.widgets.ErrorView $ RetryListener)' 空对象引用错误
我的活动课程是:
public class SplashScreenActivity extends BaseScreen implements SplashView, MyOnClick.MyOnClickListener, ErrorView.RetryListener {
private static final String TAG = SplashScreenActivity.class.getSimpleName();
private SplashPresenter mPresenter;
protected MyOnClick myOnClickListener = new MyOnClick();
@BindView(R.id.imgViewSplashLogo)
ImageView imgViewSplashLogo;
@BindView(R.id.errorViewSplash)
ErrorView errorViewSplash;
@Override
public void onCreate(Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
ButterKnife.bind(this);
errorViewSplash.setOnRetryListener(this);
mPresenter = new SplashPresenter(this);
mPresenter.registerBus();
}
我的 logcat输出是:
2018-10-30 10:41:33.964 451-451/com.cygnet.monesmartstore E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cygnet.monesmartstore, PID: 451
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cygnet.monesmartstore/com.cygnet.mone.views.activities.SplashScreenActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.cygnet.mone.views.widgets.ErrorView.setOnRetryListener(com.cygnet.mone.views.widgets.ErrorView$RetryListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.cygnet.mone.views.widgets.ErrorView.setOnRetryListener(com.cygnet.mone.views.widgets.ErrorView$RetryListener)' on a null object reference
at com.cygnet.mone.views.activities.SplashScreenActivity.onCreate(SplashScreenActivity.java:81)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
2018-10-30 10:41:33.966 451-451/com.cygnet.monesmartstore E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cygnet.monesmartstore/com.cygnet.mone.views.activities.SplashScreenActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.cygnet.mone.views.widgets.ErrorView.setOnRetryListener(com.cygnet.mone.views.widgets.ErrorView$RetryListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.cygnet.mone.views.widgets.ErrorView.setOnRetryListener(com.cygnet.mone.views.widgets.ErrorView$RetryListener)' on a null object reference
at com.cygnet.mone.views.activities.SplashScreenActivity.onCreate(SplashScreenActivity.java:81)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) '
以前它在工作,但是当我更新gradle版本和依赖项时,发生了运行时错误。我的猜测是这与 jakewarton 库
有关任何帮助将不胜感激
答案 0 :(得分:0)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
在下面添加此行
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);