微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android java.lang.IllegalArgumentException

这可能是一个简单的答案,但我似乎无法正确,并认为我会问.
我收到了 java.lang.IllegalArgumentException和java.lang.NullPointerException

这是错误日志

03-20 13:13:22.872: E/SurfaceTextureClient(565): dequeueBuffer Failed (No such device)
 03-20 13:13:22.879: E/BaseSurfaceHolder(565): Exception locking surface
 03-20 13:13:22.879: E/BaseSurfaceHolder(565): java.lang.IllegalArgumentException
 03-20 13:13:22.879: E/BaseSurfaceHolder(565): at android.view.Surface.lockCanvasNative(Native Method)
 03-20 13:13:22.879: E/BaseSurfaceHolder(565):  at android.view.Surface.lockCanvas(Surface.java:76)
 03-20 13:13:22.879: E/BaseSurfaceHolder(565):  at com.android.internal.view.BaseSurfaceHolder.internalLockCanvas(BaseSurfaceHolder.java:184)
 03-20 13:13:22.879: E/BaseSurfaceHolder(565):  at com.android.internal.view.BaseSurfaceHolder.lockCanvas(BaseSurfaceHolder.java:161)
 03-20 13:13:22.879: E/BaseSurfaceHolder(565):  at ca.watercity.CityActivity$Blimp.render(CityActivity.java:235)
 03-20 13:13:22.879: E/BaseSurfaceHolder(565):  at ca.city.CityActivity$CityThread.run(CityActivity.java:580)
 03-20 13:13:22.879: W/dalvikvm(565): threadid=11: thread exiting with uncaught exception (group=0x409c01f8)
 03-20 13:13:22.889: E/AndroidRuntime(565): FATAL EXCEPTION: Thread-79
 03-20 13:13:22.889: E/AndroidRuntime(565): java.lang.NullPointerException
 03-20 13:13:22.889: E/AndroidRuntime(565):     at ca.city.CityActivity$Blimp.render(CityActivity.java:237)
 03-20 13:13:22.889: E/AndroidRuntime(565):     at ca.city.CityActivity$CityThread.run(CityActivity.java:580)


 03-20 13:26:12.633: E/AndroidRuntime(564): java.lang.NullPointerException

这是它影响的两行代码.

public void render(){
            Canvas canvas = null;
            try{
                // line 235
                canvas = this._surfaceHolder.lockCanvas(null);
                synchronized (this._surfaceHolder) {
                    canvas.save();
                    this.onDraw(canvas);
                    canvas.restore();
                }
            }finally{
                if(canvas != null){
                    this._surfaceHolder.unlockCanvasAndPost(canvas);
                }
            }   
        }

这些代码行.

@Override
        public void run() {
            while(this._running){
                this._blimp.render();
            }
        } // line 580

任何帮助都将非常感谢.
先感谢您.

解决方法

您将null传递给SurfaceHolder.lockCanvas.您希望使用lockCanvas()的无参数版本,假设您没有想要被视为脏的矩形.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐