安卓动态壁纸示例出现强制关闭,无法实例化服务。

3

我正在尝试运行一些Android动态壁纸教程示例,但总是出现以下错误:

09-28 16:13:30.729: E/AndroidRuntime(408): java.lang.RuntimeException: 无法实例化服务 net.markguerra.android.glwallpaperexample.MyWallpaperService: java.lang.ClassNotFoundException: net.markguerra.android.glwallpaperexample.MyWallpaperService在加载器中不存在 dalvik.system.PathClassLoader[/data/app/net.markguerra.android.glwallpaperexample-1.apk]

这是我的清单文件:

<?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" />

</manifest> 

我创建的壁纸服务

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();
    }

    public Engine onCreateEngine() {
        MyEngine engine = new MyEngine();
        return engine;
    }

    class MyEngine extends GLEngine {
        MyRenderer renderer;
        public MyEngine() {
            super();
            // handle prefs, other initialization
            renderer = new MyRenderer();
            setRenderer(renderer);
            setRenderMode(RENDERMODE_CONTINUOUSLY);
        }

        public void onDestroy() {
            super.onDestroy();
            if (renderer != null) {
                renderer.release();
            }
            renderer = null;
        }
    }
}

这是我的项目结构:

enter image description here

我无法确定其中的问题,出现了什么错误?任何建议都将对我有很大帮助。

在堆栈上找到了一些相关问题,但与动态壁纸无关。

2个回答

3
你应该将GLWallpaperService.jar放入libs文件夹中。

谢谢Tecigo,GLWallpaperService.jar已经在库中了。 - Renjith K N
然后在项目结构中取消选中你所突出显示的jar。 - ALiGOTec
3
必须是“libs”而不是“lib”,不然我错了吗?如果是“libs”,你应该在文件夹上看到一个小的“a”,就像“res”或“bin”一样... - WarrenFaith

2

必须使用libs而不是lib,我是否错了?使用libs时,您应该在文件夹上看到一个小a,就像res或bin一样...


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接