ViewPager crashing on inflation - android

When opening the first screen of my app I'm having a crash. 150 of them actually (detected only one a single user) with Android 4.4.2 with device Samsung GT-N7100.
After trying in several devices I'm unable to replicate it...
My first clue was to search bugs in the Calligraphy lib, but according to similar bugs reported there, it is pointing to them but is a false "stack guilt line". It is probably something with the specific layout line so...
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.myapp/com.app.mymags.features.product.activities.ProductDetailActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
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 android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(SourceFile:211)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(SourceFile:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(SourceFile:302)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.app.mymags.features.product.viewbuilders.imagecarousel.ImageCarouselViewBuilder.(SourceFile:28)
at com.app.mymags.features.product.fragments.imagecarousel.ImageCarouselFragment.onCreateView(SourceFile:92)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1453)
at android.app.Activity.performStart(Activity.java:5460)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
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.createCustomViewInternal(SourceFile:211)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(SourceFile:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(SourceFile:302)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.app.mymags.features.product.viewbuilders.imagecarousel.ImageCarouselViewBuilder.(SourceFile:28)
at com.app.mymags.features.product.fragments.imagecarousel.ImageCarouselFragment.onCreateView(SourceFile:92)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1453)
at android.app.Activity.performStart(Activity.java:5460)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
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.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(BitmapFactory.java)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889)
at android.content.res.Resources.loadDrawable(Resources.java:3436)
at android.content.res.Resources.getDrawable(Resources.java:1909)
at android.support.v7.widget.TintResources.superGetDrawable(SourceFile:48)
at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(SourceFile:374)
at android.support.v7.widget.TintResources.getDrawable(SourceFile:44)
at android.widget.EdgeEffect.(EdgeEffect.java:151)
at android.support.v4.widget.EdgeEffectCompatIcs.newEdgeEffect(SourceFile:30)
at android.support.v4.widget.EdgeEffectCompat$EdgeEffectIcsImpl.newEdgeEffect(SourceFile:99)
at android.support.v4.widget.EdgeEffectCompat.(SourceFile:150)
at android.support.v4.view.ViewPager.initViewPager(SourceFile:375)
at android.support.v4.view.ViewPager.(SourceFile:360)
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.createCustomViewInternal(SourceFile:211)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(SourceFile:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(SourceFile:302)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.app.mymags.features.product.viewbuilders.imagecarousel.ImageCarouselViewBuilder.(SourceFile:28)
at com.app.mymags.features.product.fragments.imagecarousel.ImageCarouselFragment.onCreateView(SourceFile:92)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1453)
at android.app.Activity.performStart(Activity.java:5460)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
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)
The XML that it is point to is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
>
<android.support.v4.view.ViewPager
android:id="#+id/image_carousel_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="#style/AppRecycler.Light"/>
</RelativeLayout>
And the line where the error is thrown is the ViewPager one.
The style of it:
<style name="AppRecycler.Light" parent="Base.AppRecycler.Light"/>
<style name="Base.AppRecycler.Light" parent="">
<item name="android:background">#android:color/white</item>
<item name="android:theme">#style/Theme.AppRecycler.Light</item>
</style>
<style name="Base.AppRecycler.Light" parent="">
<item name="android:background">#android:color/white</item>
<item name="android:theme">#style/Theme.AppRecycler.Light</item>
</style>
Since this appears to be a device-user specific bug, does anyone has a clue how to fix it?
Or at least why it's happening in the first place?

There is a probable chance of Samsung customized their UI, default android provided some views may not work for this device. Ideally OEMs should support by default android APIs. Is samsung provided any separate SDK for this device or not check. If provides verify the problem in their sdk.

Related

Error on phone "unfortunately 'app name' has stopped" (OutOfMemoryError)

My newly made app is giving error on phone:
"unfortunately 'app name' has stopped"
below is my logcat error
07-27 19:35:58.261 7466-7466/com.example.android.happybirthday E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.happybirthday, PID: 7466
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889)
at android.content.res.Resources.loadDrawable(Resources.java:3436)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.ImageView.<init>(ImageView.java:133)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:57)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:53)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:102)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:972)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1030)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.example.android.happybirthday.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
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(Native Method)
try to put this into the application tag of your manifest:
android:largeHeap="true"

Android: got InflateException and OutOfMemoryError

I have a simple Activity which shows an ImageView.
However, I sometimes receive bug report saying InflateException and OutOfMemoryError.
And those errors are pointing to the ImageView I have used.
I have made 4 different images for mdpi,hdpi,xhdpi,xxhdpi and used in ImageView.
File size of images: {6KB, 10KB, 14KB, 23KB}
Resolution of images: {192*192,288*288,384*384,576*576}
I believe the images is small enough that would not trigger OutOfMemoryError.
Does anyone know what is the problem?
xml file
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SplashActivity">
<!--Below is #21-->
<ImageView
android:id="#+id/imageView"
android:layout_width="225dp"
android:layout_height="225dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#drawable/splash" />
</RelativeLayout>
error trace
java.lang.RuntimeException: Unable to start activity ComponentInfo{SplashActivity}: android.view.InflateException: Binary XML file line #21: Error inflating class
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2328)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366)
at android.app.Activity.setContentView(Activity.java:2031)
at SplashActivity.onCreate(SplashActivity.java:60)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
... 24 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889)
at android.content.res.Resources.loadDrawable(Resources.java:3077)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.ImageView.(ImageView.java:133)
at android.widget.ImageView.(ImageView.java:123)
... 27 more
android.view.InflateException: Binary XML file line #21: Error inflating class
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366)
at android.app.Activity.setContentView(Activity.java:2031)
at SplashActivity.onCreate(SplashActivity.java:60)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
... 24 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889)
at android.content.res.Resources.loadDrawable(Resources.java:3077)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.ImageView.(ImageView.java:133)
at android.widget.ImageView.(ImageView.java:123)
... 27 more
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366)
at android.app.Activity.setContentView(Activity.java:2031)
at SplashActivity.onCreate(SplashActivity.java:60)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889)
at android.content.res.Resources.loadDrawable(Resources.java:3077)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.ImageView.(ImageView.java:133)
at android.widget.ImageView.(ImageView.java:123)
... 27 more
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889)
at android.content.res.Resources.loadDrawable(Resources.java:3077)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.ImageView.(ImageView.java:133)
at android.widget.ImageView.(ImageView.java:123)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366)
at android.app.Activity.setContentView(Activity.java:2031)
at SplashActivity.onCreate(SplashActivity.java:60)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)

Duplicate id 0x7f0a00b4, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.MapFragment

i have Navigation Activity that holds different fragments when i start home
fragment which contains two(passenger and Driver) more fragments
inside it they are working perfectly..while running passenger
fragment i start an activity from this fragment in which i perform
some background task if it execute successfully then fragment also
works fine but if somehow background task failed and then that
activity crash and when i get back to that (passenger) fragment it
also crash with following exception
java.lang.NullPointerException
at com.gol.apps.flickcar.NearByPlaces$ParserTask.onPostExecute(NearByPlaces.java:327)
at com.gol.apps.flickcar.NearByPlaces$ParserTask.onPostExecute(NearByPlaces.java:299)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5455)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:966)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:733)
at dalvik.system.NativeStart.main(Native Method)
EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gol.apps.flickcar/com.gol.apps.flickcar.NavigationActivity}: android.view.InflateException: Binary XML file line #44: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.access$600(ActivityThread.java:166)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1379)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5455)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:966)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:733)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #44: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at com.gol.apps.flickcar.fragments.PassengerFragment.onCreateView(PassengerFragment.java:176)
at android.app.Fragment.performCreateView(Fragment.java:1701)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:885)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
at android.app.BackStackRecord.run(BackStackRecord.java:694)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
at android.app.Activity.performStart(Activity.java:5220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2337)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416)
            at android.app.ActivityThread.access$600(ActivityThread.java:166)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1379)
            at android.os.Handler.dispatchMessage(Handler.java:107)
            at android.os.Looper.loop(Looper.java:194)
            at android.app.ActivityThread.main(ActivityThread.java:5455)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:966)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:733)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Binary XML file line #44: Duplicate id 0x7f0a00b4, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.MapFragment
at android.app.Activity.onCreateView(Activity.java:4829)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
            at com.gol.apps.flickcar.fragments.PassengerFragment.onCreateView(PassengerFragment.java:176)
            at android.app.Fragment.performCreateView(Fragment.java:1701)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:885)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
            at android.app.BackStackRecord.run(BackStackRecord.java:694)
            at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
            at android.app.Activity.performStart(Activity.java:5220)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2337)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416)
            at android.app.ActivityThread.access$600(ActivityThread.java:166)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1379)
            at android.os.Handler.dispatchMessage(Handler.java:107)
            at android.os.Looper.loop(Looper.java:194)
            at android.app.ActivityThread.main(ActivityThread.java:5455)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:966)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:733)
            at dalvik.system.NativeStart.main(Native Method)
Here is my xml layout for passanger fragment
<fragment
android:id="#+id/mapPassenger"
class="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/fragment_map" />
I am totally new to fragments.. i have also search alot for this but
m unable to solve my problem please help me on this thanks
Are you trying to inflate a fragment... inside a fragment_layout?
Note: You cannot inflate a layout into a fragment when that layout includes a <fragment>. Nested fragments are only supported when added to a fragment dynamically.
Please see this post.
Simple answer!
you check if view is already created in fragment then return else add like this
GoogleMap fragmentMap;
if(fragmentMap==null)
fragmentMap = ((com.google.android.gms.maps.MapFragment) getActivity().getFragmentManager().
findFragmentById(R.id.mapfragment)).getMap();

NPE Error inflating class fragment: NavigationDrawerFragment

When I create a new navigation drawer activity in Android Studio, the basic example runs perfectly. I've changed a few lines to integrate Material Design and v4 - v7 support, and consequently the app breaks. I also included in some lines of basic code from Firebase that does a simple auth with Google+.
Starting the app returns a runtime exception, and "error inflating class fragment" message.
I'm guessing that the NPE is coming from the view not being inflated, but I have no idea how that is happening.
Below is my logcat, my activities, and my layouts. Any help or guidance would be appreciated.
Logcat:
11-24 16:29:26.735 6127-6127/com.starkenglish E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.starkenglish, PID: 6127
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.starkenglish/com.starkenglish.MainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2212)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:343)
at android.app.Activity.setContentView(Activity.java:1929)
at com.starkenglish.MainActivity.onCreate(MainActivity.java:110)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.starkenglish.NavigationDrawerFragment.onCreateView(NavigationDrawerFragment.java:101)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:866)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1040)
at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1142)
at android.app.Activity.onCreateView(Activity.java:4786)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:343)
            at android.app.Activity.setContentView(Activity.java:1929)
            at com.starkenglish.MainActivity.onCreate(MainActivity.java:110)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)
To keep this post clean, I have posted my code as GIST on github.
MainActivity.java:
https://gist.github.com/markbratanov/a94291edaf02b0b236d3
NavigationDrawerFragment.java:
https://gist.github.com/markbratanov/92bb583f14604b68b34d
fragment_main.xml:
https://gist.github.com/markbratanov/d1bda8b3c99d47e0257c
fragment_navigation_drawer.xml:
https://gist.github.com/markbratanov/5f5e334e40e253736e49
If there is missing code / files please let me know and I'll include it immediately.
your main activity extends FragmentActivity, and in order to get an actionBar
which is listed in your NavigationDrawerFragment line 101, just like the error says
mDrawerListView.setAdapter(new ArrayAdapter<String>(
getActivity().getActionBar().getThemedContext(), <== this is the null part
android.R.layout.simple_list_item_activated_1,
android.R.id.text1,
new String[]{
getString(R.string.title_section1),
getString(R.string.title_section2),
getString(R.string.title_section3),
}));
you need to extend the ActionBarActivity from the app compat
quote from the documentation
ActionBarCompat contains one Activity class which all of your Activity
classes should extend: ActionBarActivity. This class itself extends
from FragmentActivity so you can continue to use Fragments in your
application.

Subclassing LinearLayout

I have a problem trying to create a subclass of LinearLayout. I have a simple fragment with this layout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/map_container"
>
<!-- Map view -->
<org.osmdroid.views.MapView
android:id="#+id/fragment_map_map_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"/>
<!-- Record description -->
<com.example.SmallRecordDetailsWidget
android:id="#+id/fragment_map_record_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
The SmallRecordDetailsWidget is a subclass of LinearLayout.
My problem is that I can't find the right way to instantiate/inflate it.
Here's what my SmallRecordDetailsWidget looks like now
public class SmallRecordDetailsWidget extends LinearLayout {
private final int layoutID = R.layout.small_record_details;
public SmallRecordDetailsWidget(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(this.layoutID, this, true) ;
}
}
Then in fragment's onCreateView I'm doing:
#Override
public View onCreateView(
LayoutInflater inflater, ViewGroup containter, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_map, containter, false) ;
this.mapView = (MapView)( view.findViewById(R.id.fragment_map_map_view) );
this.recordDetailsWidget = (SmallRecordDetailsWidget)( view.findViewById(R.id.fragment_map_record_detail) ) ;
return view;
}
But this codes brakes on View view = inflater.inflate(...) with
android.view.InflateException: Binary XML file line #18: Error inflating class com.lexues.android.hari_prototype.views.SmallRecordDetailsWidget
which I can track to being thrown on
LayoutInflater.from(context).inflate(this.layoutID, this, true) ;
line from SmallRecordDetailsWidget's constructor. Inflater fails even on dead simple layout, like this one
<?xml version="1.0" encoding="utf-8"?>
<!-- A widget with details of selected point of interest. This will be placed at the bottom of the map widget -->
<com.lexues.android.hari_prototype.views.SmallRecordDetailsWidget xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/small_record_details_layout"
android:layout_width="match_parent"
android:layout_height="82dp">
</com.lexues.android.hari_prototype.views.SmallRecordDetailsWidget>
Now, I've stripped my problem to smallest case that reproduces the issue, so it looks like I'm not doing anything useful here, but the goal is for SmallRecordDetailsWidget to have a few simple member widgets and then do a bit of work with them. If I understand correctly as long as they would be defined within layout file that SmallRecordDetailsWidget's constructor inflates (as children of the root element) then they should also get inflated, so that I can later on get hold of them with findViewById(...).
Edit - added stack trace and a bit of extra details
The stack trace is:
09-01 09:24:18.661 6330-6330/com.lexues.android.hari_prototype E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.lexues.android.hari_prototype, PID: 6330
android.view.InflateException: Binary XML file line #18: Error inflating class com.lexues.android.hari_prototype.views.SmallRecordDetailsWidget
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at com.lexues.android.hari_prototype.controllers.fragments.MapFragment.onCreateView(MapFragment.java:87)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:478)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
at android.view.View.measure(View.java:17396)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5365)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:17396)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5365)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:382)
at android.view.View.measure(View.java:17396)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5365)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2505)
at android.view.View.measure(View.java:17396)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2175)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1316)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1513)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            at com.lexues.android.hari_prototype.controllers.fragments.MapFragment.onCreateView(MapFragment.java:87)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
            at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:478)
            at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
            at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
            at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
            at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
            at android.view.View.measure(View.java:17396)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5365)
            at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            at android.view.View.measure(View.java:17396)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5365)
            at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:382)
            at android.view.View.measure(View.java:17396)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5365)
            at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2505)
            at android.view.View.measure(View.java:17396)
            at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2175)
            at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1316)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1513)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
            at android.view.Choreographer.doCallbacks(Choreographer.java:603)
            at android.view.Choreographer.doFrame(Choreographer.java:573)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5335)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.inflate(LayoutInflater.java:470)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at com.lexues.android.hari_prototype.views.SmallRecor
09-01 09:24:19.381 882-6350/? E/android.os.Debug﹕ !#Dumpstate > sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error
09-01 09:24:20.361 267-267/? E/SMD﹕ DCD ON
As noted in the code I posted, in the constructor of SmallRecordDetailsWidget I inflate layout R.layout.small_record_details, where small_record_details.xml is the xml that defines the widget (while com.lexues.android.hari_prototype.views.SmallRecordDetailsWidget is the name of its root tag).
And just to make my goals clear - I want to create a widget that contains a few others. I hope to define all of them in the xml for that 'compound widget', then in costructor get references to child widgets, so that client can do things like SmallRecordDetailsWidget.titleTextWidget.setText(...), etc.
Reading your question it seems your are inflating the wrong layout in SmallRecordDetailsWidget's constructor.
There, you should NOT use the tag
<com.lexues.android.hari_prototype.views.SmallRecordDetailsWidget>
You use that tag when you are inflating/instatiating the custom layout from your fragment, but NOT when you are inflating a small view hierarchy and attach it to your custom layout. The view hierarchy should not contain that tag, try putting something like a TextView in layout/small_record_details.xml
So after more digging with better keyword (googling for custom View instead of extending ViewGroup), this article helped me:
http://www.tiemenschut.com/how-to-create-compound-controls-for-android/
My problem was that I used com.lexues.android.hari_prototype.views.SmallRecordDetailsWidget as the name of the root element of the layout which defined my custom widget. I should had simply used LinearLayout or any other layout as desired. Which makes sense come to think of it, otherwise I'm referencing the element before finishing defining it. Silly me.

Categories

Resources