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

RuntimeException: Cannot find preference screen within search result #1781

Closed
tolot27 opened this issue Jul 14, 2021 · 6 comments · Fixed by #2114
Closed

RuntimeException: Cannot find preference screen within search result #1781

tolot27 opened this issue Jul 14, 2021 · 6 comments · Fixed by #2114
Labels
bug any kind of software error settings

Comments

@tolot27
Copy link
Collaborator

tolot27 commented Jul 14, 2021

Searching the settings for "back-fill" and clicking on the top-most hit "Back-fill data Tap to send historical data to Nightscout" (if English is the UI language) results in a java.lang.RuntimeException: Cannot find preference screen within search result.

The log shows:

jamorham PREFS
Got error trying to highlight search results:
java.lang.RuntimeException: Cannot find preference screen
within search result

Any version of xDrip is affected.

@tolot27 tolot27 added bug any kind of software error settings labels Jul 14, 2021
@tolot27
Copy link
Collaborator Author

tolot27 commented Jul 14, 2021

I've traced the bug down to the library search-preference.aar. This library is self-compiled from repository ByteHamster/SearchPreference and there are many never versions available. Unfortunately, non of these versions work with xDrip. It looks like search-preference.aar was cloned and modified around version v1.2.6.

@jamorham Do you know who modified the original library?

@tolot27
Copy link
Collaborator Author

tolot27 commented Jul 14, 2021

I've found Adapted for using in PreferenceActivity Context but this commit introduces some other changes and it will not introduce SearchConfiguration.getKeysList().

@jamorham
Copy link
Collaborator

This is easy to resolve see: 87ac6fc

@Lupum1001
Copy link
Contributor

Lupum1001 commented May 10, 2022

Opened another pull request with more fixes.
#2114

Is there a way to screen for this issue automatically, either by linting the xml or writing unit tests?

@tolot27 tolot27 linked a pull request May 10, 2022 that will close this issue
@Lupum1001
Copy link
Contributor

Lupum1001 commented May 10, 2022

#2114 (comment)
#2114 (comment)
Sorry about the relocation @tolot27; I just have a preference for discussing further fixes in the context of the issue instead of the individual pull request if that's ok.

This will also find root nodes of PreferenceScreen. I don't know whether they need an android:key attribute or not.

To my knowledge anything of the type Preference, or its subclasses will need the android:key defined. There's at least one exception which is PreferenceCategory, but PreferenceGroup may be another.
https://developer.android.com/reference/android/preference/Preference

@tolot27
Copy link
Collaborator Author

tolot27 commented May 11, 2022

Sorry about the relocation @tolot27; I just have a preference for discussing further fixes in the context of the issue instead of the individual pull request if that's ok.

I try to keep the developer related discussions separated from the user-relevant discussions to not "pollute" the issues. But this issue is more like a dev issue. Hence, I'm fine with it.

This will also find root nodes of PreferenceScreen. I don't know whether they need an android:key attribute or not.

To my knowledge anything of the type Preference, or its subclasses will need the android:key defined.

The docs do not state that the android:key attribute is required. If it is really required, we have to add it to the root nodes, too.

Android Developers > Docs > Reference states:

"This class contains a key that will be used as the key into the SharedPreferences. It is up to the subclass to decide how to store the value."

We have to verify if the addition of the missing android:key attribute changes the storage of the preferences and introduces incompatibilities during import.

jamorham added a commit that referenced this issue May 11, 2022
…_exceptions

Further fixes for #1781 (preference search exceptions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug any kind of software error settings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants