java - libgdx - Android 问题 - "Unfortunately [app name] has stopped"

标签 java android libgdx tween

抱歉,如果我正在做一些非常愚蠢的事情或者这是一个愚蠢的问题,但正如您可能会说的那样,我是编程新手,因此我们将不胜感激任何帮助!

我可以让我的 libgdx 游戏在桌面上运行得很好,但是当我尝试在 Android 手机或 genymotion 上运行它时,我会收到一个弹出窗口,显示“不幸的是,[应用程序名称]已停止”。

这是 LogCat 中的错误(不幸的是很长):

06-16 15:44:06.228: E/EGL_genymotion(125): Failed to establish connection with the host
06-16 15:44:06.236: E/eglCodecCommon(125): TcpStream::connect() - connect() errno=111
06-16 15:44:06.236: E/(125): Failed to connect to host (TcpStream)!!!
06-16 15:44:06.236: E/gralloc_vbox86(125): gralloc: Failed to get host connection
06-16 15:44:06.236: E/SurfaceFlinger(125): hwcomposer module not found
06-16 15:44:06.236: E/SurfaceFlinger(125): ERROR: failed to open framebuffer (I/O error), aborting
06-16 15:44:11.308: E/setdpi(194): Setting DPI to 480
06-16 15:44:11.312: E/SurfaceFlinger(184): hwcomposer module not found
06-16 15:44:11.548: E/MonoPipe(186): Failed to fetch local time frequency when constructing a MonoPipe (res = -32).  getNextWriteTimestamp calls will be non-functional
06-16 15:44:12.012: E/memtrack(185): Couldn't load memtrack module (No such file or directory)
06-16 15:44:12.012: E/android.os.Debug(185): failed to load memtrack module: -2
06-16 15:44:12.136: E/local_camera(121): We have a problem with the player connection 0 (Success)
06-16 15:44:12.720: E/EmojiFactory_jni(185): Failed to load libemoji.so: dlopen failed: library "libemoji.so" not found
06-16 15:44:14.012: E/Netd(183): exec() res=0, status=768 for /system/bin/iptables -t nat -N oem_nat_pre 
06-16 15:44:14.036: E/Netd(183): exec() res=0, status=768 for /system/bin/iptables -t nat -A PREROUTING -j oem_nat_pre 
06-16 15:44:14.120: E/Netd(183): exec() res=0, status=768 for /system/bin/iptables -t nat -N natctrl_nat_POSTROUTING 
06-16 15:44:14.140: E/Netd(183): exec() res=0, status=768 for /system/bin/iptables -t nat -A POSTROUTING -j natctrl_nat_POSTROUTING 
06-16 15:44:14.172: E/Netd(183): exec() res=0, status=768 for /system/bin/iptables -t nat -N st_nat_POSTROUTING 
06-16 15:44:14.192: E/Netd(183): exec() res=0, status=768 for /system/bin/iptables -t nat -A POSTROUTING -j st_nat_POSTROUTING 
06-16 15:44:15.900: E/ConsumerIrService(504): Can't open consumer IR HW Module, error: -2
06-16 15:44:15.904: E/libsuspend(504): Error opening /sys/power/autosleep: Permission denied
06-16 15:44:15.904: E/libsuspend(504): Error opening /sys/power/wakeup_count: Permission denied
06-16 15:44:15.904: E/libsuspend(504): failed to initialize autosuspend
06-16 15:44:15.956: E/EventHub(504): could not get driver version for /dev/input/mouse1, Not a typewriter
06-16 15:44:15.984: E/EventHub(504): could not get driver version for /dev/input/mouse0, Not a typewriter
06-16 15:44:16.016: E/EventHub(504): could not get driver version for /dev/input/mice, Not a typewriter
06-16 15:44:16.088: E/MobileDataStateTracker(504): default: Ignoring feature request because could not acquire PhoneService
06-16 15:44:16.088: E/MobileDataStateTracker(504): default: Could not enable APN type "default"
06-16 15:44:16.264: A/SystemServer(504): BOOT FAILURE making Package Manager Service ready
06-16 15:44:16.264: A/SystemServer(504): java.lang.SecurityException: Unable to find app for caller android.app.ActivityThread$ApplicationThread@529520c0 (pid=504) when registering receiver android.app.LoadedApk$ReceiverDispatcher$InnerReceiver@52906730
06-16 15:44:16.264: A/SystemServer(504): 	at com.android.server.am.ActivityManagerService.registerReceiver(ActivityManagerService.java:13021)
06-16 15:44:16.264: A/SystemServer(504): 	at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1458)
06-16 15:44:16.264: A/SystemServer(504): 	at android.app.ContextImpl.registerReceiverAsUser(ContextImpl.java:1433)
06-16 15:44:16.264: A/SystemServer(504): 	at com.android.internal.content.PackageMonitor.register(PackageMonitor.java:84)
06-16 15:44:16.264: A/SystemServer(504): 	at com.android.server.pm.UserManagerService.systemReady(UserManagerService.java:237)
06-16 15:44:16.264: A/SystemServer(504): 	at com.android.server.pm.PackageManagerService.systemReady(PackageManagerService.java:10602)
06-16 15:44:16.264: A/SystemServer(504): 	at com.android.server.ServerThread.initAndLoop(SystemServer.java:903)
06-16 15:44:16.264: A/SystemServer(504): 	at com.android.server.SystemServer.main(SystemServer.java:1189)
06-16 15:44:16.264: A/SystemServer(504): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-16 15:44:16.264: A/SystemServer(504): 	at java.lang.reflect.Method.invoke(Method.java:515)
06-16 15:44:16.264: A/SystemServer(504): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
06-16 15:44:16.264: A/SystemServer(504): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
06-16 15:44:16.264: A/SystemServer(504): 	at dalvik.system.NativeStart.main(Native Method)
06-16 15:44:16.272: E/libsuspend(504): Error opening /sys/power/autosleep: Permission denied
06-16 15:44:16.272: E/libsuspend(504): Error opening /sys/power/wakeup_count: Permission denied
06-16 15:44:16.272: E/libsuspend(504): failed to initialize autosuspend
06-16 15:44:16.388: E/EGL_genymotion(504): egl: current context mark for deletion
06-16 15:44:16.536: E/WVMExtractor(186): Failed to open libwvm.so
06-16 15:44:16.696: E/BluetoothAdapter(568): Bluetooth binder is null
06-16 15:44:16.696: E/BluetoothAdapter(568): Bluetooth binder is null
06-16 15:44:16.708: E/BluetoothAdapter(568): Bluetooth binder is null
06-16 15:44:16.740: E/BluetoothAdapter(568): Bluetooth binder is null
06-16 15:44:16.784: E/BluetoothAdapter(568): Bluetooth binder is null
06-16 15:44:16.896: E/WifiStateMachine(504): Failed to reload STA firmware java.lang.IllegalArgumentException: command '2 softap fwreload eth1 STA' failed with '501 2 SoftAP command has failed'
06-16 15:44:16.896: E/NetdConnector(504): NDC Command {1 bandwidth enable} took too long (604ms)
06-16 15:44:16.924: E/OpenGLRenderer(568): Getting MAX_TEXTURE_SIZE from GradienCache
06-16 15:44:16.932: E/OpenGLRenderer(568): MAX_TEXTURE_SIZE: 16384
06-16 15:44:16.932: E/OpenGLRenderer(568): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
06-16 15:44:16.936: E/OpenGLRenderer(568): MAX_TEXTURE_SIZE: 16384
06-16 15:44:17.036: E/WifiHW(504): Unable to open connection to supplicant on "@android:wpa_eth1": No such file or directory
06-16 15:44:17.284: E/BluetoothAdapter(648): Bluetooth binder is null
06-16 15:44:17.564: E/FlpHardwareProvider(504): Error hw_get_module 'flp': -2
06-16 15:44:17.564: E/FlpHardwareProvider(504): Error hw_get_module 'flp': -2
06-16 15:44:17.564: E/LocationManagerService(504): no geocoder provider found
06-16 15:44:17.564: E/LocationManagerService(504): No FusedProvider found.
06-16 15:44:17.564: E/LocationManagerService(504): no geofence provider found
06-16 15:44:17.568: E/BluetoothAdapter(648): Bluetooth binder is null
06-16 15:44:17.672: E/GpsLocationProvider(504): no AGPS interface in set_agps_server
06-16 15:44:18.144: E/BluetoothAdapter(648): Bluetooth binder is null
06-16 15:44:18.192: E/GpsLocationProvider(504): no AGPS interface in set_agps_server
06-16 15:44:18.296: E/BluetoothAdapter(697): Bluetooth binder is null
06-16 15:44:18.320: E/BluetoothAdapter(697): Bluetooth binder is null
06-16 15:44:18.324: E/BluetoothAdapter(697): Bluetooth binder is null
06-16 15:44:18.328: E/BluetoothAdapter(648): Bluetooth binder is null
06-16 15:44:18.592: E/memtrack(678): Couldn't load memtrack module (No such file or directory)
06-16 15:44:18.596: E/android.os.Debug(678): failed to load memtrack module: -2
06-16 15:44:18.976: E/gralloc_vbox86(184): gralloc_alloc: Mismatched usage flags: 1080 x 1920, usage b33
06-16 15:44:18.976: E/(184): GraphicBufferAlloc::createGraphicBuffer(w=1080, h=1920) failed (Invalid argument), handle=0x0
06-16 15:44:18.976: E/BufferQueue(184): [ScreenshotSurface] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed
06-16 15:44:19.192: E/BluetoothAdapter(648): Bluetooth binder is null
06-16 15:44:19.312: E/WifiConfigStore(504): Error parsing configurationjava.io.FileNotFoundException: /data/misc/wifi/ipconfig.txt: open failed: ENOENT (No such file or directory)
06-16 15:44:19.312: E/wpa_supplicant(647): Line -1: too long model_name (len=46 max_len=32)
06-16 15:44:19.312: E/wpa_supplicant(647): Line -1: failed to parse 'model_name=Samsung Galaxy S5 - 4.4.4 - API 19 - 1080x1920'.
06-16 15:44:19.312: E/WifiStateMachine(504): Failed to set model name Samsung Galaxy S5 - 4.4.4 - API 19 - 1080x1920
06-16 15:44:19.312: E/wpa_supplicant(647): Line -1: too long model_number (len=46 max_len=32)
06-16 15:44:19.312: E/wpa_supplicant(647): Line -1: failed to parse 'model_number=Samsung Galaxy S5 - 4.4.4 - API 19 - 1080x1920'.
06-16 15:44:19.312: E/WifiStateMachine(504): Failed to set model number Samsung Galaxy S5 - 4.4.4 - API 19 - 1080x1920
06-16 15:44:19.340: E/WifiStateMachine(504): Failed to set frequency band 0
06-16 15:44:19.480: E/WifiStateMachine(504): Unexpected BatchedScanResults :null
06-16 15:44:19.824: E/OpenGLRenderer(710): Getting MAX_TEXTURE_SIZE from GradienCache
06-16 15:44:19.824: E/OpenGLRenderer(710): MAX_TEXTURE_SIZE: 16384
06-16 15:44:19.836: E/OpenGLRenderer(710): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
06-16 15:44:19.836: E/OpenGLRenderer(710): MAX_TEXTURE_SIZE: 16384
06-16 15:44:21.068: E/ConnectivityService(504): Unexpected mtu value: android.net.wifi.WifiStateTracker@5294512c
06-16 15:44:21.644: E/NetdConnector(504): NDC Command {29 bandwidth setiquota eth0 9223372036854775807} took too long (601ms)
06-16 15:44:21.644: E/NetdConnector(504): NDC Command {30 resolver setifdns eth1 home 192.168.1.1} took too long (578ms)
06-16 15:44:21.824: E/ConnectivityService(504): Unexpected mtu value: android.net.wifi.WifiStateTracker@5294512c
06-16 15:44:22.016: E/BluetoothAdapter(504): Bluetooth binder is null
06-16 15:44:22.016: E/BluetoothAdapter(504): Bluetooth binder is null
06-16 15:44:25.531: E/memtrack(1206): Couldn't load memtrack module (No such file or directory)
06-16 15:44:25.535: E/android.os.Debug(1206): failed to load memtrack module: -2
06-16 15:44:26.095: E/OpenGLRenderer(1220): Getting MAX_TEXTURE_SIZE from GradienCache
06-16 15:44:26.099: E/OpenGLRenderer(1220): MAX_TEXTURE_SIZE: 16384
06-16 15:44:26.107: E/OpenGLRenderer(1220): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
06-16 15:44:26.107: E/OpenGLRenderer(1220): MAX_TEXTURE_SIZE: 16384
06-16 15:44:26.299: E/EGL_genymotion(1220): [getAttribValue] Bad attribute idx
06-16 15:44:26.299: E/EGL_genymotion(1220): tid 1235: eglGetConfigAttrib(576): error 0x3004 (EGL_BAD_ATTRIBUTE)
06-16 15:44:26.299: E/EGL_genymotion(1220): [getAttribValue] Bad attribute idx
06-16 15:44:26.299: E/EGL_genymotion(1220): tid 1235: eglGetConfigAttrib(576): error 0x3004 (EGL_BAD_ATTRIBUTE)
06-16 15:44:26.503: E/Utils(186):  Couldn't map mime type "audio/x-pcm" to a valid AudioSystem::audio_format !
06-16 15:44:26.519: A/SoftFFmpegAudio(186): external/stagefright-plugins/libstagefright/codecs/ffmpegdec/adec/SoftFFmpegAudio.cpp:1100 CHECK(isConfigured()) failed.
06-16 15:44:26.519: A/libc(186): Fatal signal 4 (SIGILL) at 0xb76e363d (code=2), thread 1242 (peg.pcm.decoder)
06-16 15:44:26.575: E/dalvikvm(1220): Could not find class 'com.kilobolt.TweenAccessors.SpriteAccessor', referenced from method com.kilobolt.screens.SplashScreen.setupTween
06-16 15:44:26.575: E/AndroidRuntime(1220): FATAL EXCEPTION: GLThread 72
06-16 15:44:26.575: E/AndroidRuntime(1220): Process: com.kilobolt.zombiebird.android, PID: 1220
06-16 15:44:26.575: E/AndroidRuntime(1220): java.lang.NoClassDefFoundError: com.kilobolt.TweenAccessors.SpriteAccessor
06-16 15:44:26.575: E/AndroidRuntime(1220): 	at com.kilobolt.screens.SplashScreen.setupTween(SplashScreen.java:47)
06-16 15:44:26.575: E/AndroidRuntime(1220): 	at com.kilobolt.screens.SplashScreen.show(SplashScreen.java:42)
06-16 15:44:26.575: E/AndroidRuntime(1220): 	at com.badlogic.gdx.Game.setScreen(Game.java:61)
06-16 15:44:26.575: E/AndroidRuntime(1220): 	at com.kilobolt.zombiebird.ZBGame.create(ZBGame.java:11)
06-16 15:44:26.575: E/AndroidRuntime(1220): 	at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:241)
06-16 15:44:26.575: E/AndroidRuntime(1220): 	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512)
06-16 15:44:26.575: E/AndroidRuntime(1220): 	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
06-16 15:44:26.827: E/local_camera(121): We have a problem with the hw connection 0 (Success)
06-16 15:44:26.827: E/local_camera(120): We have a problem with the hw connection 0 (Success)
06-16 15:44:26.831: E/SoundPool(1220): Unable to load sample: (null)
06-16 15:44:26.831: E/SoundPool(1220): Unable to load sample: (null)
06-16 15:44:26.831: E/SoundPool(1220): Unable to load sample: (null)
06-16 15:44:26.831: E/SoundPool(1220): Unable to load sample: (null)
06-16 15:44:26.831: E/AudioService(504): Media server died.
06-16 15:44:26.911: E/MonoPipe(1249): Failed to fetch local time frequency when constructing a MonoPipe (res = -32).  getNextWriteTimestamp calls will be non-functional
06-16 15:44:27.331: E/AudioService(504): Media server started.
06-16 15:44:28.911: E/BluetoothAdapter(648): Bluetooth binder is null
06-16 15:44:43.043: E/InputDispatcher(504): channel '529532ec com.kilobolt.zombiebird.android/com.kilobolt.zombiebird.android.AndroidLauncher (server)' ~ Channel is unrecoverably broken and will be disposed!
06-16 15:51:30.763: E/memtrack(1436): Couldn't load memtrack module (No such file or directory)
06-16 15:51:30.763: E/android.os.Debug(1436): failed to load memtrack module: -2
06-16 15:51:31.107: E/memtrack(1446): Couldn't load memtrack module (No such file or directory)
06-16 15:51:31.107: E/android.os.Debug(1446): failed to load memtrack module: -2
06-16 15:51:32.019: E/OpenGLRenderer(1459): Getting MAX_TEXTURE_SIZE from GradienCache
06-16 15:51:32.019: E/OpenGLRenderer(1459): MAX_TEXTURE_SIZE: 16384
06-16 15:51:32.027: E/OpenGLRenderer(1459): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
06-16 15:51:32.027: E/OpenGLRenderer(1459): MAX_TEXTURE_SIZE: 16384
06-16 15:51:32.255: E/EGL_genymotion(1459): [getAttribValue] Bad attribute idx
06-16 15:51:32.255: E/EGL_genymotion(1459): tid 1474: eglGetConfigAttrib(576): error 0x3004 (EGL_BAD_ATTRIBUTE)
06-16 15:51:32.255: E/EGL_genymotion(1459): [getAttribValue] Bad attribute idx
06-16 15:51:32.255: E/EGL_genymotion(1459): tid 1474: eglGetConfigAttrib(576): error 0x3004 (EGL_BAD_ATTRIBUTE)
06-16 15:51:32.519: E/WVMExtractor(1249): Failed to open libwvm.so
06-16 15:51:32.627: E/Utils(1249):  Couldn't map mime type "audio/x-pcm" to a valid AudioSystem::audio_format !
06-16 15:51:32.635: A/SoftFFmpegAudio(1249): external/stagefright-plugins/libstagefright/codecs/ffmpegdec/adec/SoftFFmpegAudio.cpp:1100 CHECK(isConfigured()) failed.
06-16 15:51:32.639: A/libc(1249): Fatal signal 4 (SIGILL) at 0xb76b563d (code=2), thread 1487 (peg.pcm.decoder)
06-16 15:51:32.675: E/dalvikvm(1459): Could not find class 'com.kilobolt.TweenAccessors.SpriteAccessor', referenced from method com.kilobolt.screens.SplashScreen.setupTween
06-16 15:51:32.687: E/AndroidRuntime(1459): FATAL EXCEPTION: GLThread 96
06-16 15:51:32.687: E/AndroidRuntime(1459): Process: com.kilobolt.zombiebird.android, PID: 1459
06-16 15:51:32.687: E/AndroidRuntime(1459): java.lang.NoClassDefFoundError: com.kilobolt.TweenAccessors.SpriteAccessor
06-16 15:51:32.687: E/AndroidRuntime(1459): 	at com.kilobolt.screens.SplashScreen.setupTween(SplashScreen.java:47)
06-16 15:51:32.687: E/AndroidRuntime(1459): 	at com.kilobolt.screens.SplashScreen.show(SplashScreen.java:42)
06-16 15:51:32.687: E/AndroidRuntime(1459): 	at com.badlogic.gdx.Game.setScreen(Game.java:61)
06-16 15:51:32.687: E/AndroidRuntime(1459): 	at com.kilobolt.zombiebird.ZBGame.create(ZBGame.java:11)
06-16 15:51:32.687: E/AndroidRuntime(1459): 	at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:241)
06-16 15:51:32.687: E/AndroidRuntime(1459): 	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512)
06-16 15:51:32.687: E/AndroidRuntime(1459): 	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
06-16 15:51:33.203: E/local_camera(1251): We have a problem with the hw connection 0 (Success)
06-16 15:51:33.207: E/SoundPool(1459): Unable to load sample: (null)
06-16 15:51:33.207: E/SoundPool(1459): Unable to load sample: (null)
06-16 15:51:33.207: E/SoundPool(1459): Unable to load sample: (null)
06-16 15:51:33.207: E/SoundPool(1459): Unable to load sample: (null)
06-16 15:51:33.207: E/AudioService(504): Media server died.
06-16 15:51:33.207: E/local_camera(1250): We have a problem with the hw connection 0 (Success)
06-16 15:51:33.279: E/MonoPipe(1495): Failed to fetch local time frequency when constructing a MonoPipe (res = -32).  getNextWriteTimestamp calls will be non-functional
06-16 15:51:33.707: E/AudioService(504): Media server started.
06-16 15:51:40.603: E/InputDispatcher(504): channel '529dca00 com.kilobolt.zombiebird.android/com.kilobolt.zombiebird.android.AndroidLauncher (server)' ~ Channel is unrecoverably broken and will be disposed!

正如您在我的 logcat 中看到的,它说“致命异常”位于 GLThread 96,但我不确定这有什么关系。

配置代码为

package com.kilobolt.zombiebird.android;

import android.os.Bundle;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.kilobolt.zombiebird.ZBGame;

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

ZBGame.java代码

package com.kilobolt.zombiebird;

import com.badlogic.gdx.Game;
import com.kilobolt.screens.SplashScreen;
import com.kilobolt.zbhelpers.AssetLoader;

public class ZBGame extends Game{
	@Override
	public void create() {
		 AssetLoader.load();
		 setScreen(new SplashScreen(this));
	}

    @Override
    public void dispose() {
        super.dispose();
        AssetLoader.dispose();
    }
}

这非常令人困惑,因为游戏在桌面上运行时完全按照其应有的方式运行。我也在使用 Tween,它在 logcat 中出现了一些错误,但是在查看了我的代码之后,我不认为 Tween 是它不起作用的原因,因为我的 Tween 代码看起来很完美并且没有错误。

如果我遗漏了一条重要信息,请告诉我,我会发布它,我已经尝试解决这个问题三天了,我非常想解决它。感谢您的帮助。

编辑: 看来问题出在我的程序设置上 问题似乎出在我的 gradle 上,它与预期的不同。上 https://github.com/libgdx/libgdx/wiki/Universal-Tween-Engine它指出 "找到标记为 project(":core") 的部分 在依赖项部分添加以下行:compile fileTree(dir: '../libs', include: '*.jar')"

但是我的 gradle 中不存在这样的部分。这是我的 gradle 文件的代码

android {
    buildToolsVersion "20.0.0"
    compileSdkVersion 20
    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')
    }
}


// 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/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"
            }
        }
    }
}

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.kilobolt.zombiebird.android/com.kilobolt.zombiebird.android.AndroidLauncher'
}

// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
    // need to specify Java source sets explicitely, 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")
                        }
                    }
                }
            }
        }
    }
}

这非常令人困惑,因为当我设置 libgdx 时,gradle 文件的代码是自动生成的,所以我无法弄清楚为什么它会出错并且不包含依赖项部分。

最佳答案

 java.lang.NoClassDefFoundError: com.kilobolt.TweenAccessors.SpriteAccessor

您的应用无法找到任何返回 TweenEngine 的类,因此这是您的项目设置而不是代码的问题。

我以前从未使用过这个库,但是快速的 Google 搜索揭示了一些关于为 Android 添加依赖项的信息? https://github.com/libgdx/libgdx/wiki/Universal-Tween-Engine

关于java - libgdx - Android 问题 - "Unfortunately [app name] has stopped",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30879213/

相关文章:

java - ListView 仅显示 ListView 第一个位置的最后一项

java - 使用多线程并行化 Java 中的 for 循环

android - 内核模块在 Android 设备上找不到固件文件;它应该在哪里?

android - 向应用小部件发送更新广播

java - 根据我的模型渲染我的世界

java - Joda DateTime 未给出预期结果

java - JPanel 中的内容不会出现

android - 调试这个的好策略?

android - libgdx 中的星空优化

java - Libgdx : Exported desktop jar file link to external path instead jar root