2016-04-09 8 views
1

私は、Windows 10、最新のEclipse Mars.2、最新のAndroid SDK、最新のlibGDXでlibGDX And​​roidアプリを開発するように設定しています。私はここからセットアップ手順を以下しています: Project Setup Gradleほとんどの基本的なlibgdxアプリがクラッシュする

、ここで:

Setting up your Development Environment (Eclipse, Intellij IDEA, NetBeans)

、ここ

Gradle and Eclipse

私は私のAndroidアプリを実行すると、それは出力でクラッシュlogcat:

04-09 02:01:56.357: E/Trace(20747): error opening trace file: No such file or directory (2) 
04-09 02:01:56.367: D/ActivityThread(20747): setTargetHeapUtilization:0.25 
04-09 02:01:56.367: D/ActivityThread(20747): setTargetHeapIdealFree:8388608 
04-09 02:01:56.367: D/ActivityThread(20747): setTargetHeapConcurrentStart:2097152 
04-09 02:01:56.548: W/dalvikvm(20747): Unable to resolve superclass of Lcom/mygdx/game/AndroidLauncher; (3) 
04-09 02:01:56.548: W/dalvikvm(20747): Link of class 'Lcom/mygdx/game/AndroidLauncher;' failed 
04-09 02:01:56.548: W/dalvikvm(20747): threadid=1: thread exiting with uncaught exception (group=0x41367438) 
04-09 02:01:56.568: E/AndroidRuntime(20747): FATAL EXCEPTION: main 
04-09 02:01:56.568: E/AndroidRuntime(20747): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mygdx.game/com.mygdx.game.AndroidLauncher}: java.lang.ClassNotFoundException: com.mygdx.game.AndroidLauncher 
04-09 02:01:56.568: E/AndroidRuntime(20747): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2005) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2106) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at android.app.ActivityThread.access$600(ActivityThread.java:138) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at android.os.Handler.dispatchMessage(Handler.java:99) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at android.os.Looper.loop(Looper.java:137) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at android.app.ActivityThread.main(ActivityThread.java:4921) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at java.lang.reflect.Method.invokeNative(Native Method) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at java.lang.reflect.Method.invoke(Method.java:511) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at dalvik.system.NativeStart.main(Native Method) 
04-09 02:01:56.568: E/AndroidRuntime(20747): Caused by: java.lang.ClassNotFoundException: com.mygdx.game.AndroidLauncher 
04-09 02:01:56.568: E/AndroidRuntime(20747): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at android.app.Instrumentation.newActivity(Instrumentation.java:1056) 
04-09 02:01:56.568: E/AndroidRuntime(20747): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1996) 
04-09 02:01:56.568: E/AndroidRuntime(20747): ... 11 more 

私が間違っていることについてのアイデアはありますか?

ここにlibGDXセットアッププロセスで変更されていないアンドロイドコードがあります。

package com.mygdx.game; 

import android.os.Bundle; 

import com.badlogic.gdx.backends.android.AndroidApplication; 
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; 
import com.mygdx.game.MyGdxGame; 

public class AndroidLauncher extends AndroidApplication { 
    @Override 
    protected void onCreate (Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); 
     initialize(new MyGdxGame(), config); 
    } 
} 

ここに私のAndroidManifest.xml(すべてであることによって、再び変わらない)

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.mygdx.game" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="23" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/GdxTheme" > 
     <activity 
      android:name="com.mygdx.game.AndroidLauncher" 
      android:label="@string/app_name" 
      android:screenOrientation="landscape" 
      android:configChanges="keyboard|keyboardHidden|orientation|screenSize"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

ここでは私によって変化も、アンドロイドのディレクトリにgradle.buildでいます。私は、デバッガでアプリケーションを実行しようと、私がしようとすると

android { 
    buildToolsVersion "23.0.3" 
    compileSdkVersion 23 
    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
      jniLibs.srcDirs = ['libs'] 
     } 

     instrumentTest.setRoot('tests') 
    } 
    defaultConfig { 
     applicationId "com.mygdx.game" 
     minSdkVersion 8 
     targetSdkVersion 23 
    } 
} 


// called every time gradle gets executed, takes the native dependencies of 
// the natives configuration, and extracts them to the proper libs/ folders 
// so they get packed with the APK. 
task copyAndroidNatives() { 
    file("libs/armeabi/").mkdirs(); 
    file("libs/armeabi-v7a/").mkdirs(); 
    file("libs/arm64-v8a/").mkdirs(); 
    file("libs/x86_64/").mkdirs(); 
    file("libs/x86/").mkdirs(); 

    configurations.natives.files.each { jar -> 
     def outputDir = null 
     if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a") 
     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_64.jar")) outputDir = file("libs/x86_64") 
     if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") 
     if(outputDir != null) { 
      copy { 
       from zipTree(jar) 
       into outputDir 
       include "*.so" 
      } 
     } 
    } 
} 

task run(type: Exec) { 
    def path 
    def localProperties = project.file("../local.properties") 
    if (localProperties.exists()) { 
     Properties properties = new Properties() 
     localProperties.withInputStream { instr -> 
      properties.load(instr) 
     } 
     def sdkDir = properties.getProperty('sdk.dir') 
     if (sdkDir) { 
      path = sdkDir 
     } else { 
      path = "$System.env.ANDROID_HOME" 
     } 
    } else { 
     path = "$System.env.ANDROID_HOME" 
    } 

    def adb = path + "/platform-tools/adb" 
    commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygdx.game/com.mygdx.game.AndroidLauncher' 
} 

// sets up the Android Eclipse project, using the old Ant based build. 
eclipse { 
    // need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin 
    // ignores any nodes added in classpath.file.withXml 
    sourceSets { 
     main { 
      java.srcDirs "src", 'gen' 
     } 
    } 

    jdt { 
     sourceCompatibility = 1.6 
     targetCompatibility = 1.6 
    } 

    classpath { 
     plusConfigurations += [ project.configurations.compile ]   
     containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'  
    } 

    project { 
     name = appName + "-android" 
     natures 'com.android.ide.eclipse.adt.AndroidNature' 
     buildCommands.clear(); 
     buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder" 
     buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder" 
     buildCommand "org.eclipse.jdt.core.javabuilder" 
     buildCommand "com.android.ide.eclipse.adt.ApkBuilder" 
    } 
} 

// sets up the Android Idea project, using the old Ant based build. 
idea { 
    module { 
     sourceDirs += file("src"); 
     scopes = [ COMPILE: [plus:[project.configurations.compile]]]   

     iml { 
      withXml { 
       def node = it.asNode() 
       def builder = NodeBuilder.newInstance(); 
       builder.current = node; 
       builder.component(name: "FacetManager") { 
        facet(type: "android", name: "Android") { 
         configuration { 
          option(name: "UPDATE_PROPERTY_FILES", value:"true") 
         } 
        } 
       } 
      } 
     } 
    } 
} 

私はすぐにlogcatにこれを取得する最初の命令以上のステップ:デフォルトでは

04-09 19:23:54.285: D/AndroidRuntime(2419): Shutting down VM 
04-09 19:23:54.286: E/AndroidRuntime(2419): FATAL EXCEPTION: main 
04-09 19:23:54.286: E/AndroidRuntime(2419): Process: com.mygdx.game, PID: 2419 
04-09 19:23:54.286: E/AndroidRuntime(2419): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mygdx.game/com.mygdx.game.AndroidLauncher}: java.lang.ClassNotFoundException: Didn't find class "com.mygdx.game.AndroidLauncher" on path: DexPathList[[zip file "/data/app/com.mygdx.game-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mygdx.game-1/lib/x86_64, /data/app/com.mygdx.game-1/base.apk!/lib/x86_64, /vendor/lib64, /system/lib64]] 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at android.app.ActivityThread.-wrap11(ActivityThread.java) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at android.os.Handler.dispatchMessage(Handler.java:102) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at android.os.Looper.loop(Looper.java:148) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at android.app.ActivityThread.main(ActivityThread.java:5417) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at java.lang.reflect.Method.invoke(Native Method) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
04-09 19:23:54.286: E/AndroidRuntime(2419): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mygdx.game.AndroidLauncher" on path: DexPathList[[zip file "/data/app/com.mygdx.game-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mygdx.game-1/lib/x86_64, /data/app/com.mygdx.game-1/base.apk!/lib/x86_64, /vendor/lib64, /system/lib64]] 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at java.lang.ClassLoader.loadClass(ClassLoader.java:469) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at android.app.Instrumentation.newActivity(Instrumentation.java:1067) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317) 
04-09 19:23:54.286: E/AndroidRuntime(2419):  ... 9 more 
04-09 19:23:54.286: E/AndroidRuntime(2419):  Suppressed: java.lang.NoClassDefFoundError: com.mygdx.game.AndroidLauncher 
04-09 19:23:54.286: E/AndroidRuntime(2419):   at dalvik.system.DexFile.defineClassNative(Native Method) 
04-09 19:23:54.286: E/AndroidRuntime(2419):   at dalvik.system.DexFile.defineClass(DexFile.java:226) 
04-09 19:23:54.286: E/AndroidRuntime(2419):   at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219) 
04-09 19:23:54.286: E/AndroidRuntime(2419):   at dalvik.system.DexPathList.findClass(DexPathList.java:338) 
04-09 19:23:54.286: E/AndroidRuntime(2419):   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54) 
04-09 19:23:54.286: E/AndroidRuntime(2419):   ... 13 more 
04-09 19:23:54.286: E/AndroidRuntime(2419):  Suppressed: java.lang.ClassNotFoundException: com.mygdx.game.AndroidLauncher 
04-09 19:23:54.286: E/AndroidRuntime(2419):   at java.lang.Class.classForName(Native Method) 
04-09 19:23:54.286: E/AndroidRuntime(2419):   at java.lang.BootClassLoader.findClass(ClassLoader.java:781) 
04-09 19:23:54.286: E/AndroidRuntime(2419):   at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) 
04-09 19:23:54.286: E/AndroidRuntime(2419):   at java.lang.ClassLoader.loadClass(ClassLoader.java:504) 
04-09 19:23:54.286: E/AndroidRuntime(2419):   ... 12 more 
04-09 19:23:54.286: E/AndroidRuntime(2419):  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available 
+0

あなたが適切な負荷テクスチャbadlogic.jpgではないか、ファイルに間違ったパスを持っているようです。いくつかのコードを投稿して、作成/初期化する場所を教えてください。 –

+0

現在のプロジェクトフォルダにアセットフォルダのファイルがあることを確認してください。 – Eames

+0

Android、Core、Desktopのプロジェクトフォルダ(「badlogicについて」を参照してください)。 jpg "btw) – Eames

答えて

0

私は持っていましたEclipseのこの問題。 Android Studioの設定手順に従うと、問題は発生しませんでした。

1

、あなたのlibgdx資産「badlogic .jpg "は" project_direcotry/android/assets "にあります。

作業ディレクトリを適切に設定していないと、アプリケーションにデータファイルが見つからないというエラーが発生します。これを修正するには、作業ディレクトリを適切に設定する必要があります。

チェックこのリンク、あなたがintelijアイデアや(アイデアをベースにしています)アンドロイドのスタジオを使用している場合: Libgdx project Exception in thread "LWJGL Application". Couldn't load file. Error log inside

チェックこの、Eclipseを使用している場合: "File not found" when running new LibGDX project

0

com.badlogic.gdx.backends.android.AndroidApplicationクラスが見つからない問題が日食で起こる、あなたはプロジェクトをチェックしなければならないと外部依存Javaのビルドで注文およびエクスポートタブでプロジェクトのプロパティのパスセクション。

プロジェクトはそれ以降、アンドロイドで動作し、実行されます。

Working example

関連する問題