java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer SeekBarPreference.onSetInitialValue
See original GitHub issueCan you please look into this crash? From time to time I see this crash reported, but it’s a rare one.
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{.MyActivity}: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at android.app.SharedPreferencesImpl.getInt(SharedPreferencesImpl.java:242)
at android.support.v7.preference.Preference.getPersistedInt(Preference.java:1709)
at net.xpece.android.support.preference.SeekBarPreference.onSetInitialValue(SeekBarPreference.java:274)
at android.support.v7.preference.Preference.dispatchSetInitialValue(Preference.java:6517)
at android.support.v7.preference.Preference.onAttachedToHierarchy(Preference.java:1257)
at android.support.v7.preference.PreferenceGroup.addPreference(PreferenceGroup.java:194)
at android.support.v7.preference.XpPreferenceInflater.android.support.v7.preference.PreferenceGroup.addItemFromInflater(XpPreferenceInflater.java:4126)
at android.support.v7.preference.XpPreferenceInflater.rInflate(XpPreferenceInflater.java:293)
at android.support.v7.preference.XpPreferenceInflater.rInflate(XpPreferenceInflater.java:293)
at android.support.v7.preference.XpPreferenceInflater.inflate(XpPreferenceInflater.java:103)
at android.support.v7.preference.PreferenceInflater.inflate$7af30e91(PreferenceInflater.java:112)
at android.support.v7.preference.XpPreferenceManager.inflateFromResource$6154c3e6(XpPreferenceManager.java:67)
at .MyFragment.android.support.v7.preference.PreferenceFragmentCompat.addPreferencesFromResource(MyFragment.java:9432)
at android.support.v7.preference.XpPreferenceFragment.onCreatePreferences(XpPreferenceFragment.java:54)
at android.support.v7.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:224)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2329)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1377)
at android.support.v4.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1109)
at android.support.v4.app.FragmentTransition.calculateFragments(FragmentTransition.java:996)
at android.support.v4.app.FragmentTransition.startTransitions(FragmentTransition.java:99)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2364)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3221)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3171)
at android.support.v4.app.FragmentActivity.android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentActivity.java:16192)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)
at .MyActivity.onStart(MyActivity.java)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1256)
at android.app.Activity.performStart(Activity.java:6972)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2937)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Issue Analytics
- State:
- Created 6 years ago
- Comments:22 (9 by maintainers)
Top Results From Across the Web
sharedPref.getInt: java.lang.String cannot be cast to ...
So in your case, all the entry values have been defined as a string array. Therefore the class cast exception will be thrown....
Read more >Bundle | Android Developers
java.util.concurrent.atomic ... A mapping from String keys to various Parcelable values. Warning: Note that Bundle is a lazy ... This value cannot be...
Read more >[MOD][GUIDE] Statusbar Weather Text - XDA Forums
SubSettings}: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at android.app.ActivityThread.
Read more >platform/external/robolectric
ByteArrayOutputStream; +import java.io. ... final String tag, final String attribute, final Integer defaultValue) { + String valueString ...
Read more >Viewing online file analysis results for 'Corona (3).apk'
java.lang.Integer.toStri\u2026(this, checkRadix(radix)). Ansi based on Hybrid Analysis ... kotlin/ClassCastException.kotlin_metadatac```f```d.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s not XML related, it crashes because it’s trying to load the value from hard drive and it finds a String instead of the expected integer.
Did you by any chance use the same key “volume” for anything else? Or did you edit shared preferences manually? This is the only thing that comes to my mind…
Unless… “volume” is a very generic name, some library you’re using may be writing in your default shared preference file.
In that case the default value is
0
.just uninstall your app and then install it. look like you saved string on that key before. or change the key or clear app data then check