Couldn't load shared library 'gdx' for target

时光怂恿深爱的人放手 提交于 2019-12-01 17:47:39

The problem I had was that for some reason libgdx.so was not copied to any of the armeabi, armeabi-v7a or x86 folders in the android project's lib folder.

Copying these over from the libgdx distribution worked for me.

My problem was that I was trying to make my GDX app within a shared library (aka, not the thing that gets compiled into an APK), but hadn't finished setting up all the GDX-including stuff in my lib.

So I had:

MyProject
-->MyMainApp
-->-->build.gradle <-- no updates required, doesn't do anything with GDX
-->MySharedLibraryWhereMyGameEngineIs
-->-->build.gradle <-- this is where the problem was

In the shared lib's build.gradle, I hadn't included the sourceSets parameter.

Adding it fixed my problem. GDX now starts up successfully.

apply plugin: 'com.android.library'
android {
    ... config stuff ...

    sourceSets {                       // this wasn't here before
        main {                         // this wasn't here before
            jniLibs.srcDirs = ['libs'] // this wasn't here before
        }                              // this wasn't here before
        instrumentTest.setRoot('tests')// this wasn't here before
    }     

    ... a bunch of other config stuff ...
}

I found out this is pretty simple : add

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