我嘗試使用libgdx製作livewallpaper。Android libgdx壁紙應用在啓動時拋出NoClassDefFoundError錯誤
我讓所有喜歡here。
我ApplicationListener:
public class GdxTestActivity implements ApplicationListener {
@Override
public void create() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void render() {
// TODO Auto-generated method stub
}
@Override
public void resize(int arg0, int arg1) {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
}
Livewallpaper.java:
public class LiveWallpaper extends AndroidLiveWallpaperService
{
@Override
public ApplicationListener createListener (boolean isPreview) {
return new GdxTestActivity();
}
@Override
public AndroidApplicationConfiguration createConfig() {
return new AndroidApplicationConfiguration();
}
@Override
public void offsetChange (ApplicationListener listener, float xOffset, float yOffset, float xOffsetStep, float yOffsetStep,
int xPixelOffset, int yPixelOffset) {
Gdx.app.log("LiveWallpaper", "offset changed: " + xOffset + ", " + yOffset);
}
爲什麼我看到這個錯誤,當我打開我的應用程序?
Link of class 'Lcom/example/gdxtest01/GdxTestActivity;' failed
Could not find class 'com.example.gdxtest01.GdxTestActivity', referenced from method com.example.gdxtest01.LiveWallpaper.createListener
VFY: unable to resolve new-instance 620 (Lcom/example/gdxtest01/GdxTestActivity;) in Lcom/example/gdxtest01/LiveWallpaper;
VFY: unable to find class referenced in signature (Lcom/badlogic/gdx/ApplicationListener;)
VFY: unable to resolve static field 726 (app) in Lcom/badlogic/gdx/Gdx;
Link of class 'Lcom/badlogic/gdx/backends/android/AndroidLiveWallpaper;' failed
Could not find class 'com.badlogic.gdx.backends.android.AndroidLiveWallpaper', referenced from method com.badlogic.gdx.backends.android.AndroidLiveWallpaperService$AndroidWallpaperEngine.onCreate
VFY: unable to resolve new-instance 520 (Lcom/badlogic/gdx/backends/android/AndroidLiveWallpaper;) in Lcom/badlogic/gdx/backends/android/AndroidLiveWallpaperService$AndroidWallpaperEngine;
VFY: unable to resolve interface method 3145: Lcom/badlogic/gdx/ApplicationListener;.dispose()V
Link of class 'Lcom/badlogic/gdx/backends/android/AndroidLiveWallpaper;' failed
...
Link of class 'Lcom/badlogic/gdx/backends/android/AndroidLiveWallpaper;' failed
VFY: unable to resolve instance field 1010
02-11 21:31:51.398: threadid=1: thread exiting with uncaught exception (group=0x4001d560)
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.badlogic.gdx.backends.android.AndroidLiveWallpaper
at com.badlogic.gdx.backends.android.AndroidLiveWallpaperService$AndroidWallpaperEngine.onCreate(AndroidLiveWallpaperService.java:108)
at android.service.wallpaper.WallpaperService$Engine.attach(WallpaperService.java:648)
at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:875)
at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
之後一些magic一切都很好。
你的主項目的'libs'目錄是什麼?奇怪的是'AndroidLiveWallpaperService'沒問題,但'AndroidLiveWallpaper'不是。在可能相關的異常之前或之後,日誌中是否還有其他內容? – 2013-02-11 14:39:20
@ P.T .:看到更新的日誌和構建路徑請參見 – Leo 2013-02-11 17:38:54