我下载了andengine live wallpaper example但是有问题。它显示了这些错误:
08-18 04:38:52.606: E/AndroidRuntime(3063): FATAL EXCEPTION: main
08-18 04:38:52.606: E/AndroidRuntime(3063): java.lang.RuntimeException: Unable to instantiate service org.anddev.wallpaper.live.cigarette.LiveWallpaperService: java.lang.ClassNotFoundException: org.anddev.wallpaper.live.cigarette.LiveWallpaperService in loader dalvik.system.PathClassLoader[/data/app/org.anddev.wallpaper.live.cigarette-1.apk]
08-18 04:38:52.606: E/AndroidRuntime(3063): at android.app.ActivityThread.handleCreateService(ActivityThread.java:1950)
08-18 04:38:52.606: E/AndroidRuntime(3063): at android.app.ActivityThread.access$2500(ActivityThread.java:121)
08-18 04:38:52.606: E/AndroidRuntime(3063): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:997)
08-18 04:38:52.606: E/AndroidRuntime(3063): at android.os.Handler.dispatchMessage(Handler.java:99)
08-18 04:38:52.606: E/AndroidRuntime(3063): at android.os.Looper.loop(Looper.java:130)
08-18 04:38:52.606: E/AndroidRuntime(3063): at android.app.ActivityThread.main(ActivityThread.java:3701)
08-18 04:38:52.606: E/AndroidRuntime(3063): at java.lang.reflect.Method.invokeNative(Native Method)
08-18 04:38:52.606: E/AndroidRuntime(3063): at java.lang.reflect.Method.invoke(Method.java:507)
08-18 04:38:52.606: E/AndroidRuntime(3063): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
08-18 04:38:52.606: E/AndroidRuntime(3063): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
08-18 04:38:52.606: E/AndroidRuntime(3063): at dalvik.system.NativeStart.main(Native Method)
08-18 04:38:52.606: E/AndroidRuntime(3063): Caused by: java.lang.ClassNotFoundException: org.anddev.wallpaper.live.cigarette.LiveWallpaperService in loader dalvik.system.PathClassLoader[/data/app/org.anddev.wallpaper.live.cigarette-1.apk]
08-18 04:38:52.606: E/AndroidRuntime(3063): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-18 04:38:52.606: E/AndroidRuntime(3063): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-18 04:38:52.606: E/AndroidRuntime(3063): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-18 04:38:52.606: E/AndroidRuntime(3063): at android.app.ActivityThread.handleCreateService(ActivityThread.java:1947)
08-18 04:38:52.606: E/AndroidRuntime(3063): ... 10 more
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.anddev.wallpaper.live.cigarette"
android:versionCode="4"
android:versionName="1.0.3">
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<service
android:name="LiveWallpaperService"
android:enabled="true"
android:icon="@drawable/icon"
android:label="@string/service_name"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter android:priority="1" >
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper" />
</service>
</application>
</manifest>
我不知道这个错误意味着什么。我希望有人可以帮助我来运行这件事..谢谢..
答案 0 :(得分:5)
您的错误是ClassNotFoundException
,它与您的动态壁纸(org.anddev.wallpaper.live.cigarette
)有关。所以我猜您在manifest
中的动态壁纸声明不正确(例如,它可能是不在申请标签中,...)
您可以在这些页面中查看有关在清单中声明服务的更多详细信息:
developer.android.com/guide/components/services.html
developer.android.com/reference/android/app/Service.html
修改强>:
我看到了你的清单。看来你的项目没有Main/Launcher Activity
。如果你的项目没有Main / Launcher Activity,你的服务就无法注册,所以当你尝试使用它们时,你得到ClassNotFoundException
。
另外,请确保完全限定的服务名称为android.service.wallpaper.WallpaperService
。
答案 1 :(得分:3)
在我的情况下,我只需要在构建路径中按顺序/导出检查andengine.jar和andenginelivewallpapersupport.jar。 (我也使用完全合格的)