2017-12-27 36 views
0

をbuild.gradleするMapbox SDKを追加した後、私はlogcatでこのエラーを取得しています:Libgdxゲームを実行することができません

12-27 17:39:51.213 3365-3365/com.mksolutions.platformerap E/AndroidRuntime: FATAL EXCEPTION: main 
Process: com.mksolutions.platformerap, PID: 3365 
java.lang.ExceptionInInitializerError 
    at java.lang.Class.newInstance(Native Method) 
    at android.app.Instrumentation.newActivity(Instrumentation.java:1079) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2781) 
    at android.app.ActivityThread.-wrap12(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1508) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:241) 
    at android.app.ActivityThread.main(ActivityThread.java:6274) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
    Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx' for target: Linux, 32-bit 
    at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:125) 
    at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:33) 
    at com.badlogic.gdx.backends.android.AndroidApplication.<clinit>(AndroidApplication.java:63) 
    at java.lang.Class.newInstance(Native Method)  
    at android.app.Instrumentation.newActivity(Instrumentation.java:1079)  
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)  
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2781)  
    at android.app.ActivityThread.-wrap12(ActivityThread.java)  
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1508)  
    at android.os.Handler.dispatchMessage(Handler.java:102)  
    at android.os.Looper.loop(Looper.java:241)  
    at android.app.ActivityThread.main(ActivityThread.java:6274)  
    at java.lang.reflect.Method.invoke(Native Method)  
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)  
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)  
    Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.mksolutions.platformerap-2/base.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.mksolutions.platformerap-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.mksolutions.platformerap-2/lib/arm64, /data/app/com.mksolutions.platformerap-2/base.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/com.mksolutions.platformerap-2/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libgdx.so" 
    at java.lang.Runtime.loadLibrary0(Runtime.java:984) 
    at java.lang.System.loadLibrary(System.java:1530) 
    at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:119) 
    at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:33)  
    at com.badlogic.gdx.backends.android.AndroidApplication.<clinit>(AndroidApplication.java:63)  
    at java.lang.Class.newInstance(Native Method)  
    at android.app.Instrumentation.newActivity(Instrumentation.java:1079)  
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)  
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2781)  
    at android.app.ActivityThread.-wrap12(ActivityThread.java)  
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1508)  
    at android.os.Handler.dispatchMessage(Handler.java:102)  
    at android.os.Looper.loop(Looper.java:241)  
    at android.app.ActivityThread.main(ActivityThread.java:6274)  
    at java.lang.reflect.Method.invoke(Native Method)  
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)  
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)  

私はMapboxの私の実装に追加した後、このエラーを取得し始めました。具体的には、私のbuild.gradleの依存関係にあるこれらの行は、エラーになります:

compile('com.mapbox.mapboxsdk:mapbox-android-sdk:[email protected]') { 
    transitive = true 
} 

アプリケーションはできるだけ早く私はゲームを起動するボタンを押すとクラッシュします。 ボタンを押した後、このコードが実行されます。

public class PlatformerLauncher extends AndroidApplication { 

@Override 
protected void onCreate (Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); 
    initialize(new GamePlatformer(), config); 
    } 
} 

GamePlatformerの内容::

public class GamePlatformer extends Game{ 
public SpriteBatch batcher; 
@Override 
public void create() { 
    Gdx.input.setCatchBackKey(true); 
    batcher = new SpriteBatch(); 
    //load assets 
    Assets.load(); 

    //draw game 
    setScreen(new PlatformerGameScreen(this)); 
} 

@Override 
public void render() 
{ 
    super.render(); 
} 
} 

そして最後にフルbuild.gradle:

順番にこのクラスを実行します

Intent intent = new Intent(getActivity(), PlatformerLauncher.class); 
getActivity().startActivity(intent); 

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.1" 
    defaultConfig { 
     applicationId "com.mksolutions.platformerap" 
     minSdkVersion 16 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    sourceSets { 
     main { 
      jniLibs.srcDir 'libs' 
     } 
    } 
} 
configurations { natives } 
dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile('com.mapbox.mapboxsdk:mapbox-android-sdk:[email protected]') { 
     transitive = true 
    } 

    compile project(':common') 
    compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" 
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" 
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi" 
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" 

    compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" 
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi" 
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a" 
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a" 
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86" 
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64" 

    compile 'com.android.support:appcompat-v7:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.android.support:design:26.+' 
    compile 'com.android.support:support-v4:26.+' 
    compile 'com.github.kenglxn.QRGen:android:2.3.0' 
    compile 'com.google.android.gms:play-services-vision:11.0.4' 
    compile 'com.google.android.gms:play-services-location:11.0.4' 
    testCompile 'junit:junit:4.12' 
} 

task copyAndroidNatives() { 
    file("libs/armeabi/").mkdirs(); 
    file("libs/armeabi-v7a/").mkdirs(); 
    file("libs/x86/").mkdirs(); 
    configurations.natives.files.each { jar -> 
     def outputDir = null 
     if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a") 
     if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi") 
     if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") 
     if (outputDir != null) { 
      copy { 
       from zipTree(jar) 
       into outputDir 
       include "*.so" 
      } 
     } 
    } 
} 

誰かが私が間違っていることに対する提案をしていますか?

答えて

0

アンドロイドデバイスがライブラリにアクセスしようとしていることがわかりましたが、そこにはありませんでした。

ソリューション:

build.gradleにdefaultConfigにこれを追加します。

defaultConfig { 
     ... 
     ndk { 
      abiFilters "armeabi-v7a", "x86", "armeabi" 
     } 
    } 

そしてgradle.properties内の次の行を追加します。

android.useDeprecatedNdk=true 

再同期のGradleを。

関連する問題