【问题标题】:Android live wallpaper sample getting force closed , Unable to instantiate serviceAndroid 动态壁纸示例被强制关闭,无法实例化服务
【发布时间】:2012-09-29 05:47:21
【问题描述】:

我尝试为 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;
        }
    }
}

这是我的项目结构

我不知道它出了什么问题,是什么错误? 任何建议都会对我有很大帮助

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

【问题讨论】:

    标签: android opengl-es live-wallpaper


    【解决方案1】:

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

    【讨论】:

    • 谢谢 Tecigo,GLWallpaperService.jar 已经在 lib 中了
    • 然后移除你在项目结构中高亮的jar。
    • 它必须是libs 而不是lib 还是我弄错了?使用libs,您应该会在文件夹上看到一个小的a,例如resbin 有...
    【解决方案2】:

    它必须是库而不是库还是我弄错了?使用 libs,您应该会在 res 或 bin 之类的文件夹上看到一个小 a...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多