其他分享
首页 > 其他分享> > Android动态壁纸示例被强制关闭,无法实例化服务

Android动态壁纸示例被强制关闭,无法实例化服务

作者:互联网

我试图为android live墙纸运行一些教程示例,但始终收到此错误

09-28 16:13:30.729: E/AndroidRuntime(408): 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[/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;
        }
    }
}

这是我的项目结构

我无法弄清楚其中出了什么问题,这是什么错误?
任何建议对我都会有很大的帮助

在堆栈上发现了一些相关问题,但与动态壁纸无关

解决方法:

您应该在libs文件夹中包含GLWallpaperService.jar.

标签:live-wallpaper,opengl-es,android
来源: https://codeday.me/bug/20191031/1978762.html