Closed samsonho closed 8 years ago
Check your XML preferences file.
E/AndroidRuntime: FATAL EXCEPTION: main android.view.InflateException: Binary XML file line #18: Error inflating class <unknown> at android.view.LayoutInflater.createView(LayoutInflater.java:518) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
PhoneLayoutInflater.java does not match with the XML file you provided. Did you miss anything?
@samsonho Hi, unfortunately the stack is cut off where it starts to get interesting. Could you use SettingsFragment
in a simpler activity with just a toolbar and a linear layout so the view hierarchy does not bloat stack and then post stack trace again? I need to see the rest. Thank you.
@eku Line 18 is probably start of asp_preference_category.xml
. This is on my side. And since the sample app works on Android 2.3.7 it must be some sort of misconfiguration.
Make sure you're using AppCompat theme and all necessary attributes are defined, example:
<style name="Theme.MyApp" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="preferenceTheme">@style/PreferenceThemeOverlay.Material</item>
<item name="preferenceTint">?colorAccent</item>
</style>
What version of support libs are you using?
Hi @consp1racy and @eku,
Thanks for responding. I realised I have not loaded your sample onto this device 2.3.6 and I have tried it and it seems to work well. So the error is likely in my code.
I have noticed that you have specified preferenceThemeOverlay
instead of preferenceTheme
is that correct? I assume that it is ok for me to use Theme.AppCompat.Light.NoActionBar
instead of Theme.AppCompat.Light.DarkActionBar
?
In any case I will break down my problem and if I find something useful I will post it to this thread again. I will try putting my SettingsFragment with a toolbar into a simplier activity with a linear layout if I can't figure my problem soon.
Again thanks,
Hi @consp1racy,
I have discovered what my problem was. I had to remove a couple things from my project. One was from my AndroidManifest.xml.
<uses-sdk xmlns:tools="http://schemas.android.com/tools" tools:overrideLibrary="android.support.v14.preference" />
Also I noticed that I was compiling for two preference libraries.
compile 'com.android.support:preference-v7:23.3.0' compile 'com.android.support:preference-v14:23.3.0'
So the other thing I had to remove was for com.android.support:preference-v14:23.3.0
. That fixed my issue.
I hope that is helpful for those encountering the same issue when dealing with code remnants when porting from one Preference library to another.
Cheers,
Hi @samsonho,
preference-v14
probably overrides some preference-v7
layouts with ones that use attributes only available on API 14 or higher causing a crash on older devices.
Since this is an edge case easily prevented by not adding tools:override
I will not investigate further.
preferenceThemeOverlay
was a typo, thank you for pointing that out.
@samsonho it's not necessary to reference the preference-v7
libraries, if you want to use ASP you just reference 'net.xpece.android:support-preference-:0.7.0'
. Unless you are planning to use some feature of the Google libraries not covered by ASP
@JoseGD Just to clarify ASP imports preference-v7
as a dependency.
@consp1racy that's what I meant, importing ASP makes importing preference-v7
redundant
Hi,
I have been trying to use XpPreferenceFragment with great success on newer Android phones with (Samsung GT-I9100) 4.1.2 and (HTC Desire HD CyanogenMod 12.1-UNOFFICIAL) 5.1.1.
But it fails with the most basic contrived preferences xml resources file when addPreferencesFromResource(R.id.settings) is called inside onCreatePreferences2 on an Android (Samsung GT-I8510T) 2.3.6 phone.
If I include the settings.xml listed below it fails with the exception also listed below. However if I omit the CheckBoxPreference tag in the settings.xml I can see "Hello World".
Could you please help?
In my build.gradle in Android Studio 2.0 I am using the following compile directives.
Here are the contents of my SettingsFragment.java
Here are the contents of my settings.xml
Here is the callstack of the exception thrown.
Many Thanks