Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after removing the EditTextPreference #3

Open
AronSchnakenbeck opened this issue Apr 8, 2021 · 0 comments
Open

Error after removing the EditTextPreference #3

AronSchnakenbeck opened this issue Apr 8, 2021 · 0 comments

Comments

@AronSchnakenbeck
Copy link

Hi there,
thank you very much for the settings-using-preferences tutorial:

https://medium.com/@bhavyakaria/step-by-step-guide-to-create-app-settings-using-preferences-in-android-part-1-fa470305b530

While trying to adjust the tutorial i figured out the app crashes after removing the EditTextPreference in settings_pref.xml.

I get the following error message when I try to open the settings activity:

2021-04-08 11:12:14.711 18526-18526/sampleapplication.parzival.com.sampleapplication E/AndroidRuntime: FATAL EXCEPTION: main
    Process: sampleapplication.parzival.com.sampleapplication, PID: 18526
    java.lang.RuntimeException: Unable to start activity ComponentInfo{sampleapplication.parzival.com.sampleapplication/sampleapplication.parzival.com.sampleapplication.SettingsActivity}: android.view.InflateException: Binary XML file line #0 in sampleapplication.parzival.com.sampleapplication:layout/activity_settings: Binary XML file line #0 in sampleapplication.parzival.com.sampleapplication:layout/activity_settings: Error inflating class fragment
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3623)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3775)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8107)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
     Caused by: android.view.InflateException: Binary XML file line #0 in sampleapplication.parzival.com.sampleapplication:layout/activity_settings: Binary XML file line #0 in sampleapplication.parzival.com.sampleapplication:layout/activity_settings: Error inflating class fragment
     Caused by: android.view.InflateException: Binary XML file line #0 in sampleapplication.parzival.com.sampleapplication:layout/activity_settings: Error inflating class fragment
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.preference.Preference.setOnPreferenceChangeListener(android.support.v7.preference.Preference$OnPreferenceChangeListener)' on a null object reference
        at sampleapplication.parzival.com.sampleapplication.SettingsFragment.onCreatePreferences(SettingsFragment.java:39)
        at android.support.v7.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:224)
        at sampleapplication.parzival.com.sampleapplication.SettingsFragment.onCreate(SettingsFragment.java:92)
        at android.support.v4.app.Fragment.performCreate(Fragment.java:2339)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1377)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1640)
        at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1896)
        at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3673)
        at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
        at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:338)
        at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
        at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:659)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
        at sampleapplication.parzival.com.sampleapplication.SettingsActivity.onCreate(SettingsActivity.java:14)
        at android.app.Activity.performCreate(Activity.java:7957)
2021-04-08 11:12:14.711 18526-18526/sampleapplication.parzival.com.sampleapplication E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:7946)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3598)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3775)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8107)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Do you know whats goning on?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant