我尝试用 libgdx 制作动态壁纸。
我让一切都喜欢这里。
我的应用程序监听器:
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
}
}
动态壁纸.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)
在一些魔法之后一切都很好。