NullPointerException View.buildDrawingCache

最近的项目中,测试说熄屏后再进入界面会出现闪退,将日志拿来看了下,

java.lang.NullPointerException

at android.view.View.buildDrawingCache(View.java:13204)

at android.view.View.getDrawingCache(View.java:13051)

at android.view.View.draw(View.java:13716)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.widget.ListView.drawChild(ListView.java:3306)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.widget.AbsListView.dispatchDraw(AbsListView.java:2579)

at android.widget.ListView.dispatchDraw(ListView.java:3301)

at android.view.View.draw(View.java:14049)

at android.widget.AbsListView.draw(AbsListView.java:4140)

at android.view.View.draw(View.java:13916)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:14049)

at android.view.View.draw(View.java:13916)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)
at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:14049)

at android.view.View.draw(View.java:13916)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:13911)

at android.view.ViewGroup.drawChild(ViewGroup.java:3154)

at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3018)

at android.view.View.draw(View.java:14049)

at android.widget.FrameLayout.draw(FrameLayout.java:467)

at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2333)

at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2698)

at android.view.ViewRootImpl.draw(ViewRootImpl.java:2589)

at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2452)

at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2254)

at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)

at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5014)

at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)

at android.view.Choreographer.doCallbacks(Choreographer.java:579)

at android.view.Choreographer.doFrame(Choreographer.java:548)

at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)

at android.os.Handler.handleCallback(Handler.java:800)

at android.os.Handler.dispatchMessage(Handler.java:100)

at android.os.Looper.loop(Looper.java:194)

at android.app.ActivityThread.main(ActivityThread.java:5400)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:525)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

at dalvik.system.NativeStart.main(Native Method)

报出了空指针的问题,在网上找了很久,相关的都是在做截图操作的时候会出现这种问题,我们的项目中没有截图的操作. 于是进入到源码查看,

NullPointerException View.buildDrawingCache_第1张图片

在上面的注释中可以看到与硬件加速有关,正好我们再代码中将硬件加速关闭了,android:hardwareAccelerated=”false” 使用的这个,

又在网上研究了硬件加速的一些问题,最后发现了这个
NullPointerException View.buildDrawingCache_第2张图片

应该是这个问题,最后将android:hardwareAccelerated=”false”删除了.

你可能感兴趣的:(移动android开发,buildDraw,DrawingCac,nullpoint,硬件加速)