I get the Error
Unable to start activity ComponentInfo{de.androidbuch.activiti/de.androidbuch.activiti.task.Activity}: android.view.InflateException: Binar
If your TaskDetailsFragment
extending android.app.Fragment
, do change in onCreateView()
.
Return your view which you want to show in the Fragment or convert your Layout to view by using LayoutInflater and return it.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View mainview = inflater.inflate(R.layout.main, null);
return mainview;
}
Hope this works. :)
I was receiving this error in android studio the problem was that my fragment had a relative layout while the code on the OnCreateView function was
mDrawerListView = (ListView) inflater.inflate(
R.layout.fragment_navigation_drawer, container, false);
is your code doing the same thing?
Could you post the fragment's onCreate
and onCreateView
methods? I had exactly same exception which was caused by an exception in the fragment onCreate
method, when I fixed that problem it fixed the Error inflating class fragment.
I had a similar problem; after running the AdMob example, I tried to insert Ads in my app, causing this error:
01-02 16:48:51.269 8199-8199/it.dndc.BreathPlot E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
Caused by: android.view.InflateException: Binary XML file line #57: Error inflating class fragment
The solution is: you cannot insert the fragment for an Ad into a ListActivity. Instead, I could add it to a FragmentActivity and to an ActionBarActivity without any problem.
My suggestion is: start from the AdMob example and add into it your existing app: I would have saved a lot of time !!!
If you use obfuscation with Navigation component you need to exclude android's fragment and your args. Add these lines to your proguard-rules files:
# Exclude the fragments and argType for navigation component.
-keep class * extends androidx.fragment.app.Fragment{}
-keep class com.safetonet.presentation.features.parent.affffdevice.model.PresentableAddDeviceData
I was receiving this error for different reasons.
Steps to reproduce:
~> My issue was that I created a brand new blank application.
~> I then generated a custom fragment from the File ~> New File Menu.
~> Proceeded to customize the fragment by adding layouts and buttons etc.
~> Referenced the new custom fragment in the auto generated activity_my.xml that was generated for me when creating the application. Doing this allowed the XML to generate the objects for me.
Heres is the catch when generating the custom fragment via File ~> New File Menu it auto generates an interface function stub and places it at the bottom of the fragment class file.
This means that your MyActivity class must implement this interface. If it does not then the the above error occurs only when referencing the fragment from xml. By removing the reference for the Fragment in the XML completely, and creating the fragment through code in the MyActivity.java class file Logcat generates a more concise error explaining the issue in detail and complaining about the interface. This is demonstrated in the Project Template Activity+Fragment. Although, <~that Project Template does not generate the interface stub.