我尝试使用libgdx制作livewallpaper。
我使所有人都像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之后一切都很好。
答案 0 :(得分:0)
主要项目中的gdx.jar
未包含在Android .apk
中。 (所有com.badlogic.gdx.*
类都在此jar文件中。)
参见步骤4,5和&手动项目设置中的6:http://code.google.com/p/libgdx/wiki/ProjectSetup#Android_project_setup
你可能只是错过了将“gdx.jar”标记为“已导出”的位。右键单击该项目,选择Build Path
->
Configure Build Path ...
。选择Order and Export
标签,确保“gdx.jar”旁边有复选标记。