NiftyGuiDemo not working on my android nexus 7 tab

Hello everyone,
I tried to execute NiftyGuiDemo available from http://files.seapegasus.org/NiftyGuiDemo.zip on my android nexus 7 tab but it yielded this exception:

java.lang.NoClassDefFoundError:org.lwjgl.opengl.Display
Exception thrown in Thread[GLThread 3501,5,main]
java.lang.NoClassDefFoundError:org.lwjgl.opengl.Display
at
mygame.JmeControlsDemoScreenController.fillResolutionDropDown(JmeControlsDemoScreenController.java:248)
at
mygame.JmeControlsDemoScreenController.bind(JmeControlsDemoScreenController.java:114)
at de.lessvoid.nifty.screen.Screen.startScreen(Screen.java:210)
at de.lessvoid.nifty.Nifty.gotoScreenInternal(Nifty.java:678)
at de.lessvoid.nifty.Nifty.access$400(Nifty.java:77)
at de.lessvoid.nifty.Nifty$1.perform(Nifty.java:635)
at
de.lessvoid.nifty.elements.EndOfFrameElementsAction.perform(EndOfFrameElementsAction.java:22)
at
de.lessvoid.nifty.Nifty.executeEndOfFrameElementsActions(Nifty.java:439)
at
de.lessvoid.nifty.Nifty.handleDynamicsElements(Nifty.java:358)
at de.lessvoid.nifty.Nifty.update(Nifty.java:293)
at
com.jme3.niftygui.inputSystemJme.endInput(InputSystemJme.java:113)
at
com.jme3.input.InputManageer.processQueue(InputManager.java:819)
at
com.jme3.input.InputManager.update(InputManager.java:883)
at com.jme3.app.Application.update(Application.java:604)
at
com.jme3.app.Simple.Applicaiton.update(SimpleApplication.java:231)
at
com.jme3.app.AndroidHarness.update(AndroidHarness.java:46)
at
com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:349)
at
android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523)
at
android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

The demo was working successfully on my pc(with windows 64bit, HD graphics 4000, 8GB Ram) but things got messed up when i tried it on android.

Well, it seems like one of your game classes is directly accessing a class that doesn’t exist on Android. (lwjgl does not exist in android builds of JME)

How can i fix this?

Don’t call lwjgl classes directly.

I am not an expert in JME3 so a little more help will be useful :slight_smile:

right now i am calling classes in JmeControlsDemoScreenController class like this

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;

how can i indirectly call these classes in my android main activity class that is:

package com.mycompany.mygame;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.Log;
import com.jme3.app.AndroidHarness;
import com.jme3.system.android.AndroidConfigChooser.ConfigType;
import java.util.logging.Level;
import java.util.logging.LogManager;

public class MainActivity extends AndroidHarness{
   
   
    public MainActivity(){
        
        // Set the application class to run
        appClass = "mygame.SimpleDemo";
        // Try ConfigType.FASTEST; or ConfigType.LEGACY if you have problems
        eglConfigType = ConfigType.BEST;
        // Exit Dialog title & message
        exitDialogTitle = "Exit?";
        exitDialogMessage = "Press Yes";
        // Enable verbose logging
        eglConfigVerboseLogging = false;
        // Choose screen orientation
        screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        // Enable MouseEvents being generated from TouchEvents (default = true)
        mouseEventsEnabled = true;
        // Set the default logging level (default=Level.INFO, Level.ALL=All Debug Info)
        LogManager.getLogManager().getLogger("").setLevel(Level.INFO);

    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
//        MainMenuClass mainMenuClass = new MainMenuClass();
//        mainMenuClass.mainActivity = this;
//        app.getStateManager().attach(mainMenuClass); 

    }

	@Override
    public void onResume() {
            super.onResume();
           
    }
	
	@Override
    public void onStop() {
            super.onStop();
            
    }
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		Log.i("Sensor", "Service  distroy");
		
	}
       


 
}

?

I can’t see anywhere that the class is even using those… so I don’t know. The pasted class doesn’t even have those imports… and I guess isn’t even the one showing up in the stack trace.

This is the code where the issue is:
mygame.JmeControlsDemoScreenController.fillResolutionDropDown

…which I guess you will have to modify to work with android because if it’s really the code calling LWJGL directlythen it’s only setup to work on desktop. (Probably unnecessarily based on the method name.)