ClassNotFoundException 搜索栏首选项
我正在尝试在我的动态壁纸设置中实现搜索栏首选项。问题是我不断收到 ClassNotFoundException
。
我创建了一个子类(可以在此处查看)来创建搜索栏然后将以下内容添加到我的 wall_settings.xml
<custom.android.mypackage.SeekBarPreference
android:title="XXXXXXXXX"
android:summary="XXXXXXXXXXX"
android:key="duration"
android:dialogMessage="Something duration"
android:defaultValue="5"
android:text=" minutes"
android:max="100"
/>
我的 SeekBarPreference.java 类与我的主 Activity 位于同一包中。我需要在清单文件中添加一些内容吗?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="custom.android.mypackage"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-feature android:name="android.software.live_wallpaper" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<service
android:name=".MainActivity"
android:enabled="true"
android:icon="@drawable/icon"
android:label="@string/service_name"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter android:priority="1" >
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper" />
</service>
<activity android:exported="true"
android:label="@string/wallpaper_settings"
android:name=".WallpaperSettings"/>
<activity
android:name=".SeekBarPreference"
android:label="@string/wallpaper_settings" />
</application>
11-11 12:32:37.308: ERROR/AndroidRuntime(8419):
Caused by:java.lang.ClassNotFoundException: custom.android.mypackage.SeekBarPreference in loader dalvik.system.PathClassLoader[/data/app/custom.android.mypackage-2.apk]
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at android.preference.GenericInflater.createItem(GenericInflater.java:375)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:430)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): ... 20 more
I'm trying to implement a seek bar preference into my live wallpaper settings. The problem is that I keep getting a ClassNotFoundException
.
I created a subclass (which can be viewed here) to create the seekbar then added the following to my wallpaper_settings.xml
<custom.android.mypackage.SeekBarPreference
android:title="XXXXXXXXX"
android:summary="XXXXXXXXXXX"
android:key="duration"
android:dialogMessage="Something duration"
android:defaultValue="5"
android:text=" minutes"
android:max="100"
/>
My SeekBarPreference.java class is in the same package as my main Activity. Is there something I need to add to my manifest file?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="custom.android.mypackage"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-feature android:name="android.software.live_wallpaper" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<service
android:name=".MainActivity"
android:enabled="true"
android:icon="@drawable/icon"
android:label="@string/service_name"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter android:priority="1" >
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper" />
</service>
<activity android:exported="true"
android:label="@string/wallpaper_settings"
android:name=".WallpaperSettings"/>
<activity
android:name=".SeekBarPreference"
android:label="@string/wallpaper_settings" />
</application>
11-11 12:32:37.308: ERROR/AndroidRuntime(8419):
Caused by:java.lang.ClassNotFoundException: custom.android.mypackage.SeekBarPreference in loader dalvik.system.PathClassLoader[/data/app/custom.android.mypackage-2.apk]
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at android.preference.GenericInflater.createItem(GenericInflater.java:375)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:430)
11-11 12:32:37.308: ERROR/AndroidRuntime(8419): ... 20 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SeekBarPreference 是 customView 而不是 Activity 。所以
找不到它。将其从菜单中删除
SeekBarPreference is customView not activity . so
can not find it . remove it from menifest