2012-04-09 87 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