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

妖精的绣舞 提交于 2019-12-25 10:19:30

问题


i'm using the LibGdx framework to create a game and I'm using Eclipse 4.4 (Luna). Whilst i'm debugging my application this method is breaking.

@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);
            }
        }

inside the GLSurfaceView Android class, with the stack trace:

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

I know what a NullPointerException is, I know somewhere is passing a null value, but what I would like to know is how can I find out where?

With these types of questions, I can only assume you'll need more code but I don't know where I should be looking, I'll post code from the Java classes on request if anyone has an idea of where I should be looking.

Note: I'm not using GLSurfaceView directly anywhere in my code, I'm assuming it's a library from Libgdx. Unless it's something i'm missing?

UPDATE: Found the issue in detail.

GLSurfaceView$GLThread.class [in android.opengl [in C:\Users\me\AppData\Local\Android\android-sdk\platforms\android-8\android.jar]] does not exist

回答1:


Solution:

An AtlasRegion was being called from the renderer class without being assigned a value in the assets class hence the null Exception

What is a NullPointerException, and how do I fix it?

changing that to a field that is declared solved this problem for me on the code side.

For the solution to the backend issue:

GLSurfaceView$GLThread.class [in android.opengl [in C:\Users\me\AppData\Local\Android\android-sdk\platforms\android-8\android.jar]] does not exist

I downloaded source codes from Google, and assigned the source code inside the SDK folder, C:\Users\me\AppData\Local\Android\android-sdk\sources\, if you don't already have a source folder create one, put the sources in there and it should reload the class that was being handled. (in this case GLSurfaceView.class for API 2.2)

Another way In Eclipse 4.4 (Luna) or any other eclipse I do believe, go onto your project folder right click > properties > java build path and assign the source file for android.jar in your dependent libraries.



来源:https://stackoverflow.com/questions/29658827/libgdx-android-gl-thread-nullpointerexception-missing-class-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!