2012-04-09 90 views
2

我從here下載了一個GLWallpaper的例子。 我按照自述文件所述導入項目。 但是,我得到了「未找到類」異常。android class path exception

04-09 22:24:06.281: E/AndroidRuntime(31990): java.lang.RuntimeException: Unable to 
instantiate service net.markguerra.android.glwallpaperexample.MyWallpaperService: 
java.lang.ClassNotFoundException: 
net.markguerra.android.glwallpaperexample.MyWallpaperService in loader 
dalvik.system.PathClassLoader[/mnt/asec/net.markguerra.android.glwallpaperexample-1/pkg.apk] 

我現在沒有什麼問題了。清單xml已經有「MyWallpaperService」。

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="net.markguerra.android.glwallpaperexample" 
    android:versionCode="1" 
    android:versionName="1.0"> 
<application android:icon="@drawable/icon" android:label="@string/app_name"> 
    <service android:label="@string/service_label" android:name=".MyWallpaperService" 
     android:permission="android.permission.BIND_WALLPAPER"> 
     <intent-filter> 
      <action android:name="android.service.wallpaper.WallpaperService" /> 
     </intent-filter> 
     <meta-data android:name="android.service.wallpaper" 
      android:resource="@xml/myglwallpaper" /> 
    </service> 
</application> 
<uses-sdk android:minSdkVersion="7" /> 

我沒有改變從示例代碼什麼。 這裏是「MyWallpaperService」類的一部分。

package net.markguerra.android.glwallpaperexample; 

import net.rbgrn.android.glwallpaperservice.*; 

// Original code provided by Robert Green 
// http://www.rbgrn.net/content/354-glsurfaceview-adapted-3d-live-wallpapers 
public class MyWallpaperService extends GLWallpaperService { 
    public MyWallpaperService() { 
    super(); 
} 
+0

顯示您的清單文件 – Abhi 2012-04-09 14:48:44

+0

添加清單 – user1297295 2012-04-09 14:56:41

回答

0

WallpaperService應該是MyWallpaperService。 嘗試這一句清單:

<intent-filter> 
     <action android:name="android.service.wallpaper.MyWallpaperService" /> 
    </intent-filter> 
+0

同樣的錯誤。 另外,你爲什麼會建議MyWallpaperService在包android.service.wallpaper下? – user1297295 2012-04-10 01:44:12

3

問題就迎刃而解了。 在eclipse ADT17中,需要將.jar放在「libs」而不是「lib」文件夾中。

+0

你不是唯一有這個問題的人。感謝這個答案,我們更新了文檔,因爲它。 https://github.com/GLWallpaperService/GLWallpaperService/pull/6 – 2013-03-14 02:30:26