0
我正在獲取自定義DialogPreference類的ClassNotFoundExption,但僅在進行版本構建之後。我完美地調試構建。發佈版本中的ClassNotFoundException
這裏是堆棧跟蹤:
10-26 16:29:08.521: E/AndroidRuntime(20593): FATAL EXCEPTION: main
10-26 16:29:08.521: E/AndroidRuntime(20593): java.lang.RuntimeException: Unable to start activity ComponentInfo{path.to.my.app.de/path.to.my.app.preferences.Preferences}: android.view.InflateException: Binary XML file line #6: Error inflating class path.to.my.app.preferences.SeekBarPreference
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2787)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.os.Handler.dispatchMessage(Handler.java:99)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.os.Looper.loop(Looper.java:144)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.app.ActivityThread.main(ActivityThread.java:4937)
10-26 16:29:08.521: E/AndroidRuntime(20593): at java.lang.reflect.Method.invokeNative(Native Method)
10-26 16:29:08.521: E/AndroidRuntime(20593): at java.lang.reflect.Method.invoke(Method.java:521)
10-26 16:29:08.521: E/AndroidRuntime(20593): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-26 16:29:08.521: E/AndroidRuntime(20593): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-26 16:29:08.521: E/AndroidRuntime(20593): at dalvik.system.NativeStart.main(Native Method)
10-26 16:29:08.521: E/AndroidRuntime(20593): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class path.to.my.app.preferences.SeekBarPreference
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:441)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.preference.GenericInflater.inflate(GenericInflater.java:326)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.preference.GenericInflater.inflate(GenericInflater.java:263)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:254)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:268)
10-26 16:29:08.521: E/AndroidRuntime(20593): at path.to.my.app.preferences.Preferences.onCreate(Unknown Source)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
10-26 16:29:08.521: E/AndroidRuntime(20593): ... 11 more
10-26 16:29:08.521: E/AndroidRuntime(20593): Caused by: java.lang.ClassNotFoundException: path.to.my.app.preferences.SeekBarPreference in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/path.to.my.app.de-1.apk]
10-26 16:29:08.521: E/AndroidRuntime(20593): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-26 16:29:08.521: E/AndroidRuntime(20593): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-26 16:29:08.521: E/AndroidRuntime(20593): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.preference.GenericInflater.createItem(GenericInflater.java:375)
10-26 16:29:08.521: E/AndroidRuntime(20593): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:430)
10-26 16:29:08.521: E/AndroidRuntime(20593): ... 20 more
被稱爲堆棧跟蹤的XML文件是:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="screen">
<PreferenceCategory android:title="@string/pref.title" android:key="cat1" android:order="1">
<path.to.my.app.preferences.SeekBarPreference android:title="@string/perimeter.head" android:key="myapp.perimeter" android:defaultValue="30" android:text=" km" android:max="80" min="5" android:progress="0"/>
<CheckBoxPreference android:key="myapp.saveFav" android:enabled="true" android:title="@string/fav.save.title" android:summary="@string/fav.save"></CheckBoxPreference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref.personal" android:order="2">
<EditTextPreference android:title="@string/search.customerNumber" android:key="myapp.wizard" android:inputType="textCapCharacters" android:maxLength="7"></EditTextPreference>
<EditTextPreference android:title="@string/reservation.firstName" android:key="myapp.firstName" android:inputType="textCapWords|textPersonName"></EditTextPreference>
<EditTextPreference android:title="@string/reservation.lastName" android:key="myapp.lastName" android:inputType="textCapWords|textPersonName"></EditTextPreference>
<EditTextPreference android:title="@string/reservation.street" android:key="myapp.street" android:inputType="textCapWords|textPostalAddress"></EditTextPreference>
<EditTextPreference android:title="@string/reservation.zip" android:key="myapp.zip" android:inputType="textCapWords|textPostalAddress"></EditTextPreference>
<EditTextPreference android:title="@string/reservation.city" android:key="myapp.city" android:inputType="textCapWords"></EditTextPreference>
<EditTextPreference android:title="@string/reservation.phone" android:key="myapp.phone" android:inputType="phone"></EditTextPreference>
</PreferenceCategory>
<PreferenceCategory android:order="3">
<EditTextPreference android:title="@string/search.awdNumber" android:key="myapp.awd" android:inputType="textCapCharacters" android:maxLength="6"> </EditTextPreference>
<EditTextPreference android:title="@string/costControl.label" android:key="myapp.costControl" android:inputType="textCapWords" android:maxLength="15"></EditTextPreference>
</PreferenceCategory>
</PreferenceScreen>
對於我使用ProGuard的發佈版本,並已經有一行
-keep public class path.to.my.app.preferences.SeekBarPreference
在配置文件中。
任何有用的提示呢?
'com.mvolution.avis.preferences.SeekBarPreference' <>'path.to.my.app.preferences.SeekBarPreference'(你有這個在你的xml文件中) – Selvin
對不起,只是一個錯字,而不是在文件中。我已經檢查了 – AlexVogel
Proguard正在刪除SeekBarPreference正在擴展的類 – Blundell