UnsatisfiedLinkError Libgdx Desktop

前端 未结 2 1621
走了就别回头了
走了就别回头了 2021-01-18 05:56

I am running into issues with LibGDX on Desktop. I keep getting the following error when trying to launch the application:

Exception in thread \"main\" java.         


        
相关标签:
2条回答
  • 2021-01-18 06:14

    Use the following main method body to launch the object:

    static public void main(String[] args) throws Exception {
    //      SkeletonViewer.args = args; 
    
        String os = System.getProperty("os.name"); 
        float dpiScale = 1;
    
        if (os.contains("Windows")) {
            dpiScale = Toolkit.getDefaultToolkit().
                    getScreenResolution() / 96f;
        }
    
        if (os.contains("OS X")) {
            Object object = Toolkit.getDefaultToolkit().getDesktopProperty(
                    "apple.awt.contentScaleFactor");
            if (object instanceof Float && ((Float) object).intValue() >= 2) {
                dpiScale = 2;
            }
        }
    
        if (dpiScale >= 2.0f) {
            uiScale = 2;
        }
    
        LwjglApplicationConfiguration.disableAudio = true;
    
        LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
        config.width = (int) (800 * uiScale);
        config.height = (int) (600 * uiScale);
        config.title = "Skeleton Viewer";
        config.allowSoftwareMode = true;
        config.samples = 2;
    
        new LwjglApplication(new SampleApplication(), config); 
    } 
    
    0 讨论(0)
  • 2021-01-18 06:36

    I'd advise you to setup your projects with this GUI. It should provide you with a valid setup for all platforms. You may also use the latest nightly builds and check if the problem still occurs. The problem might be that the native libraries do not match the other jars.

    Another problem might be that you instantiate a SpriteBatch (or something else which internally uses a SpriteBatch) too early (looked a bit like this in the stacktrace). For example statically like this:

    private static SpriteBatch batch = new SpriteBatch();
    

    This won't work, since libgdx wasn't setup correctly at this point in time. Instead, create such things in the create/show methods of your game.

    0 讨论(0)
提交回复
热议问题