question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom Layout Crash InflateException

See original GitHub issue

Hello Chris, just wanted to start off by saying thanks for such a great library! With that in mind I’m hoping this crash report helps improve it.

I’m currently seeing a crash on a couple of Samsung devices where the apps are crashing in what seems to be a failure to inflate a xml file used in a custom layout that extends FrameLayout. Below is the stack trace I’ve collected:

android.view.InflateException: Binary XML file line #63: Error inflating class <unknown> at android.view.LayoutInflater.createView(LayoutInflater.java:626) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:162) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:146) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700) at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) at android.view.LayoutInflater.inflate(LayoutInflater.java:498) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:398) at android.view.LayoutInflater.inflate(LayoutInflater.java:354) at android.view.View.inflate(View.java:18474) at re.snapwi.ui.RetryLayout.init(RetryLayout.java:52) at re.snapwi.ui.RetryLayout.<init>(RetryLayout.java:31) at re.snapwi.ui.photo.PhotoGalleryFragment.onCreateView(PhotoGalleryFragment.java:116) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:454) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(NativeStart.java) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Constructor.java) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:600) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:162) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:146) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700) at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) at android.view.LayoutInflater.inflate(LayoutInflater.java:498) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:398) at android.view.LayoutInflater.inflate(LayoutInflater.java:354) at android.view.View.inflate(View.java:18474) at re.snapwi.ui.RetryLayout.init(RetryLayout.java:52) at re.snapwi.ui.RetryLayout.<init>(RetryLayout.java:31)

Line 52 of RetryLayout is calling inflate in the custom framelayout:

private void init(Context context) {
    setLayoutTransition(new LayoutTransition());
    inflate(context, R.layout.retry_framelayout, this); // This is LINE 52
    progressLayout = findViewById(R.id.retryProgressLayout);
    progressBarDefault = findViewById(R.id.retryProgress);
   topProgressBar = findViewById(R.id.smoothProgressBar);

   retryLayout = findViewById(R.id.retryButtonLayout);
   mainLayout = (FrameLayout) findViewById(R.id.mainContent);
   retryTextView = (TextView) findViewById(R.id.retryTextView);
   retryTextView.setTextColor(retryTextColor);
   retryButton = (Button) findViewById(R.id.retryButton);
   mShortAnimationDuration = getResources().getInteger(android.R.integer.config_longAnimTime);
 }

The inflateException then points to Binary XML file line #63 which is the beginning of a ProgressBar tag

 <ProgressBar  
    android:id="@+id/retryProgress"
    style="@style/SnapwireSpinner"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:visibility="gone" />

The crash is affecting the following Samsung models: SM N910G, GT N7100, SCH S960L

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:34 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
marcoRScommented, Feb 20, 2015

So I think I might have had a breakthrough in figuring out what the root problem is… I can create the exact same crash by making my app run out of memory.

When the app is just about to run about memory and I try to load another view the app crashes with the same stack trace which at first appears to be caused by Calligraphy library but really it was because my app had a memory leak.

At the very end of my stack trace I failed to notice:

Caused by: java.lang.OutOfMemoryError at android.graphics.BitmapFactory.nativeDecodeAsset(BitmapFactory.java) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:503) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:356) at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:379) at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:409) at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:493) at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:901)

Once I fixed this memory leak this crash went away. I hope this helps.

1reaction
chrisjenxcommented, Feb 6, 2015

@marcoRS Personally whenever I write custom classes. I only provide the two arg constructor (saves you time!)

E.g.

public RetryLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    init(context);
 }

If this works for every other device and not samsung, I would take a guess at this being an issue with your custom view and samsung devices and not calligraphy. We pass inflation off to the underling inflater. (We just get the blame for the exception).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom View Crashing Upon Inflation - android - Stack Overflow
My custom views are causing an app crash when they're inflated within ... LayoutInflater.inflate(LayoutInflater.java:518) at android.view.
Read more >
TabLayout inflation crash: Failed to resolve attribute at index 0 ...
When I inflate this layout that contains the TabLayout, TabLayout crashes: ... InflateException: Binary XML file line #9: Error inflating class ...
Read more >
App Crash caused by RuntimeException inflating ...
We've seen a couple of app crashes which seems to be caused by ... by RuntimeException inflating ConversationDetailActivity xml layout.
Read more >
Chrome Custom Tab crashing when entering any password
InflateException: Binary XML file line #6 in com.android.chrome:layout/0_resource_name_obfuscated: Binary XML file line #6 in ...
Read more >
Custom scrollview crashes with error inflating class while ...
Note that if you do this, you'll have to update your layout <CustomScrollView> tags, since they currently reference MainActivity.CustomScrollView . Ben P.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found