android livewallpaper设置按钮单击导致错误 - 不幸的是,动态壁纸选择器已停止

时间:2015-11-14 13:34:34

标签: java android crash libgdx live-wallpaper

我正在尝试使用libgdx库在Android中制作动态壁纸应用程序,但我有一个问题。每当在动态壁纸选择器中按下设置按钮时,应用程序崩溃并显示消息:“不幸的是,动态壁纸选择器已停止”,否则一切正常。

我一直在关注这个例子: How to create android live wallpaper

我尝试在这里寻找解决方案,例如: Live Wallpaper crash when tap on Settings

但没有什么能解决我的问题 - 我认为它在某个地方的xml文件中,但也许将libgdx与livewallpaper结合起来会有问题?

我一直试图找到解决方案,但不能,真的很感激一些帮助。

这是我的代码:

的Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mygdx.game.android"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="22" />
    <uses-permission android:name="android.permission.SET_WALLPAPER"></uses-permission>
    <uses-feature android:required="true" android:name="android.software.live_wallpaper"> </uses-feature>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <activity android:name="com.mygdx.game.android.AndroidLauncher"
            android:label="@string/app_name" 
            android:configChanges="keyboard|keyboardHidden|orientation">
             <intent-filter> 
                 <action android:name="android.intent.action.MAIN"/>
                  <category android:name="android.intent.category.LAUNCHER"/>
             </intent-filter> 
        </activity>

        <activity android:name="com.mygdx.game.android.LivewallpaperSettings"
              android:label="Livewallpaper Settings"
              android:theme="@android:style/Theme.Light.WallpaperSettings"
              android:exported="true"> 
        </activity>

        <service
             android:name="com.mygdx.game.android.LiveWallpaper"
             android:label="@string/app_name"
             android:icon="@drawable/ic_launcher"
             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/wallpaper" />
        </service>
    </application>

</manifest>

LivewallpaperSettings.java

package com.mygdx.game.android;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;

public class LivewallpaperSettings extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {

    @Override
    protected void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        getPreferenceManager().setSharedPreferencesName(LiveWallpaper.SHARED_PREFS_NAME);
        addPreferencesFromResource(R.xml.settings);
        getPreferenceManager().getSharedPreferences()
                .registerOnSharedPreferenceChangeListener(this);
    }

    @Override
    protected void onResume()
    {
        super.onResume();
    }

    @Override
    protected void onDestroy()
    {
        getPreferenceManager().getSharedPreferences()
                .unregisterOnSharedPreferenceChangeListener(this);
        super.onDestroy();
    }

    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
            String key)
    {
    }

}

wallpaper.xml

<?xml version="1.0" encoding="UTF-8"?>
<wallpaper
       xmlns:android="http://schemas.android.com/apk/res/android"  
       android:thumbnail="@drawable/ic_launcher"
       android:settingsActivity="lwp.example.android.LivewallpaperSettings"/>

的settings.xml

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    android:title="settings"
    android:key="settings">

    <ListPreference
        android:key="livewallpaper_testpattern"
        android:title="title 1"
        android:summary="do 1"
        android:entries="@array/livewallpaper_testpattern_names"
        android:entryValues="@array/livewallpaper_testpattern_prefix"/>
    <CheckBoxPreference android:key="livewallpaper_movement"
        android:title="title 2"
        android:summary="do 2"
        android:summaryOn="Moving test pattern"
        android:summaryOff="Still test pattern"/>
</PreferenceScreen>

当我收到错误时,这是​​我的logcat:

11-14 15:40:04.254: W/GL2JNIView(1654): creating OpenGL ES 2.0 context
11-14 15:40:04.265: I/AndroidGraphics(1654): OGL renderer: Adreno (TM) 320
11-14 15:40:04.265: I/AndroidGraphics(1654): OGL vendor: Qualcomm
11-14 15:40:04.265: I/AndroidGraphics(1654): OGL version: OpenGL ES 3.0 V@84.0 AU@05.00.02.006.020 (CL@)
11-14 15:40:04.265: I/AndroidGraphics(1654): OGL extensions: GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_AMD_program_binary_Z400 GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_robustness GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_NV_fence GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_depth24 GL_OES_EGL_image GL_OES_EGL_sync GL_OES_EGL_image_external GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL_OES_get_program_binary GL_OES_packed_depth_stencil GL_OES_depth_texture_cube_map GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_vertex_type_10_10_10_2 GL_OES_vertex_array_object GL_QCOM_alpha_test GL_QCOM_binning_control GL_QCOM_driver_control GL_QCOM_perfmon_global_mode GL_QCOM_extended_get GL_QCOM_extended_get2 GL_QCOM_tiled_rendering GL_QCOM_writeonly_rendering GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode GL_EXT_multisampled_render_to_texture GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_disjoint_timer_query 
11-14 15:40:04.265: W/Adreno-EGL(1654): <qeglDrvAPI_eglGetConfigAttrib:632>: EGL_BAD_ATTRIBUTE
11-14 15:40:04.265: W/Adreno-EGL(1654): <qeglDrvAPI_eglGetConfigAttrib:632>: EGL_BAD_ATTRIBUTE
11-14 15:40:04.265: I/AndroidGraphics(1654): framebuffer: (5, 6, 5, 0)
11-14 15:40:04.265: I/AndroidGraphics(1654): depthbuffer: (16)
11-14 15:40:04.265: I/AndroidGraphics(1654): stencilbuffer: (0)
11-14 15:40:04.265: I/AndroidGraphics(1654): samples: (0)
11-14 15:40:04.265: I/AndroidGraphics(1654): coverage sampling: (false)
11-14 15:40:04.333: I/Running LiquidFun version(1654): LiquidFun 1.1.0
11-14 15:40:04.333: I/720.0(1654): 1280.0
11-14 15:40:04.429: I/AndroidInput(1654): sensor listener setup
11-14 15:40:09.043: I/WallpaperService(1654): service destroyed
11-14 15:40:09.043: I/WallpaperService(1654): engine paused
11-14 15:40:09.217: E/Surface(1654): queueBuffer: error queuing buffer to SurfaceTexture, -19
11-14 15:40:09.218: W/Adreno-EGLSUB(1654): <SwapBuffers:1344>: failed to queueBuffer
11-14 15:40:09.218: W/Adreno-EGL(1654): <qeglDrvAPI_eglSwapBuffers:3798>: EGL_BAD_SURFACE
11-14 15:40:09.220: I/AndroidInput(1654): sensor listener tear down
11-14 15:40:09.236: E/Surface(1654): queueBuffer: error queuing buffer to SurfaceTexture, -19
11-14 15:40:09.236: W/Adreno-EGLSUB(1654): <SwapBuffers:1344>: failed to queueBuffer
11-14 15:40:09.236: W/Adreno-EGL(1654): <qeglDrvAPI_eglSwapBuffers:3798>: EGL_BAD_SURFACE
11-14 15:40:09.244: I/WallpaperService(1654): engine surface destroyed

1 个答案:

答案 0 :(得分:0)

我发现了问题,我错误地引用了“LivewallpaperSettings.java” “wallpaper.xml”文件中的类:

代替: 机器人:settingsActivity =“lwp.example.android.LivewallpaperSettings

它应该是: 机器人:settingsActivity = “com.mygdx.game.android.LivewallpaperSettings”

我使用了另一个项目作为参考并复制它而不将其更改为正确的路径。抱歉..浪费了我的时间和其他人:/

感谢您的帮助。