Libgdx Android - GL Thread (NullPointerException) & Missing Class File



我正在使用LibGdx框架来创建游戏,并且正在使用Eclipse 4.4(Luna)。当我调试我的应用程序时,此方法正在中断。

@Override
        public void run() {
            setName("GLThread " + getId());
            if (LOG_THREADS) {
                Log.i("GLThread", "starting tid=" + getId());
            }
            try {
                guardedRun();
            } catch (InterruptedException e) {
                // fall thru and exit normally
            } finally {
                sGLThreadManager.threadExiting(this);
            }
        }

GLSurfaceView Android 类中,带有堆栈跟踪:

Thread [GLThread 232] (Suspended (exception NullPointerException))  
    GLSurfaceView$GLThread.run() line: 1243 

我知道什么是 NullPointerException,我知道某处正在传递一个空值,但我想知道的是我如何找到在哪里?

对于这些类型的问题,我只能假设您将需要更多的代码,但我不知道我应该在哪里查找,如果有人知道我应该在哪里查找,我将根据请求发布 Java 类中的代码。

注意:我没有在我的代码中的任何位置直接使用 GLSurfaceView,我假设它是来自 Libgdx 的库。除非是我错过了什么?

更新:详细发现了问题。

GLSurfaceView$GLThread.class [in android.opengl [in C:UsersmeAppDataLocalAndroidandroid-sdkplatformsandroid-8android.jar]] does not exist

解决方案:

renderer 类调用AtlasRegion,而没有在assets class中分配值,因此

空异常

什么是 NullPointerException,我该如何修复它?

将其更改为声明的字段在代码端为我解决了这个问题。

对于后端问题的解决方案:

GLSurfaceView$GLThread.class [in android.opengl [in C:UsersmeAppDataLocalAndroidandroid-sdkplatformsandroid-8android.jar]] does not exist

我从Google下载了源代码,并在SDK文件夹中分配了源代码,C:UsersmeAppDataLocalAndroidandroid-sdksources,如果您还没有源文件夹创建一个,请将源代码放在那里,它应该重新加载正在处理的类。(在本例中GLSurfaceView.class API 2.2)

另一种方式 在Eclipse 4.4(Luna)或任何其他我相信的eclipse中,请转到项目文件夹,右键单击> properties > java build path并为依赖库中的android.jar分配源文件。

相关内容

最新更新