Android 8.0报错,6.0上没问题,哪位晓得啊 5C

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidvideo/com.example.androidvideo.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'int android.view.IWindowManager.getStatusBarColorFromAdaptation(java.lang.String, java.lang.String)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3000)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3078)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:183)
at android.app.ActivityThread.main(ActivityThread.java:7014)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:514)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int android.view.IWindowManager.getStatusBarColorFromAdaptation(java.lang.String, java.lang.String)' on a null object reference
at com.android.internal.policy.PhoneWindow.getStatusBarColorFromAdaptation(PhoneWindow.java:4261)
at com.android.internal.policy.PhoneWindow.setWindowManager(PhoneWindow.java:376)
at android.app.Activity.attach(Activity.java:7223)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2933)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3078) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:183) 
at android.app.ActivityThread.main(ActivityThread.java:7014) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:514) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888) 


2个回答

说的是没有启动activity,在空对象 IWindowManager.getStatusBarColorFromAdaptation上引用方法失败,说明这个对象不存在,8.0和6.0获取对象的方法不一样,你可以试试这方面的。

像这种错误,很有可能是因为IWindowManager.getStatusBarColorFromAdaptation(java.lang.String, java.lang.String)这个接口的对象没有进行实例化(new)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问