I am developing an app that uses fragments with the support library. The app is working and is published, but i get this error report(Only with 3.2 OS versions):
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.naviter.seeyou/com.naviter.seeyou.MenuDisplayActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
android.app.ActivityThread.access$500(ActivityThread.java:122)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:132)
android.app.ActivityThread.main(ActivityThread.java:4123)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:491)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class
android.view.LayoutInflater.createView(LayoutInflater.java:596)
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
android.view.LayoutInflater.inflate(LayoutInflater.java:479)
android.view.LayoutInflater.inflate(LayoutInflater.java:391)
com.naviter.seeyou.DisplayFragment.onCreateView(DisplayFragment.java:57)
The Exception is thrown at the last line in the onCreateView method:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState){
if (container == null)
return null;
getActivity().setTitle(R.string.Display);
return inflater.inflate(R.layout.settings_display, container, false); //here
}
and this is the xml file:
<ListView
android:id="@+id/listViewDisplay"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
</ListView>
<LinearLayout
android:id="@+id/rlAsDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/buttonDisplayOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/Ok" />
<Button
android:id="@+id/buttonDisplayCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/Cancel" />
</LinearLayout>
</LinearLayout>
I repeat, that the app is runnig well, i got this exception only on few devices with Android 3.2 OS. And i’m importing fragment from:
android.support.v4.app.Fragment;
Any suggestions?
Thanks.
I thing i solved the issue.
I was accidentally extending the class with:
instead of:
And then using a custom layout for DialogFragment. Obviously this causes problems only on Android 3.2
I also find another problem later. In the Manifest i was using the theme Theme.DeviceDefault wich was added in android api level 14 and android 3.2 obviously can’t live with this. Then i implemented a theme selector wich chooses the theme depending on the device API level.