Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API 16 crash. Need help #46

Closed
cuongpham2110 opened this issue May 20, 2018 · 6 comments
Closed

API 16 crash. Need help #46

cuongpham2110 opened this issue May 20, 2018 · 6 comments

Comments

@cuongpham2110
Copy link

cuongpham2110 commented May 20, 2018

Hi, I have a crash when run on device support api 16. I checked closed issue #32 but it isn't helpful
It can be an error when inflating some class. Can you show me the solution to deal with it. Thanks you.

The error is:
05-20 15:32:39.929 8920-8920/vn.gofime.gofime E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{vn.gofime.gofime/vn.gofime.gofime.pagemainmap}: android.view.InflateException: Binary XML file line #0: Error inflating class net.steamcrafted.materialiconlib.MaterialIconView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class net.steamcrafted.materialiconlib.MaterialIconView
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
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 android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at vn.gofime.gofime.pagemainmap.onCreate(pagemainmap.java:355)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
at android.app.ActivityThread.access$600(ActivityThread.java:130) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4745) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
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:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
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 android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at vn.gofime.gofime.pagemainmap.onCreate(pagemainmap.java:355) 
at android.app.Activity.performCreate(Activity.java:5008) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
at android.app.ActivityThread.access$600(ActivityThread.java:130) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4745) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f08005d a=-1 r=0x7f08005d}
at android.content.res.Resources.loadDrawable(Resources.java:1897)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.(View.java:3336)
at android.widget.ImageView.(ImageView.java:114)
at android.widget.ImageView.(ImageView.java:110)
at net.steamcrafted.materialiconlib.MaterialIconView.(MaterialIconView.java:30)
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
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 android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at vn.gofime.gofime.pagemainmap.onCreate(pagemainmap.java:355) 
at android.app.Activity.performCreate(Activity.java:5008) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
at android.app.ActivityThread.access$600(ActivityThread.java:130) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4745) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
at dalvik.system.NativeStart.main(Native Method) 

@code-mc
Copy link
Owner

code-mc commented May 20, 2018

The actual issue is on this line: Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f08005d a=-1 r=0x7f08005d}

So you're most likely using a resource inside an attribute that is of an unsupported type. Can you post the contents of that layout file (just the MaterialIconView XML is enough)?

@cuongpham2110
Copy link
Author

Hi, thanks for replying me. This is the XML that contains MaterialIconView. I put it in the LinearLayout.

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <!-- nut tat activator -->
                <net.steamcrafted.materialiconlib.MaterialIconView
                    xmlns:app="http://schemas.android.com/apk/res-auto"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    app:materialIcon="arrow_left"
                    app:materialIconColor="#FFF"
                    android:layout_marginLeft="10dp"
                    app:materialIconSize="30dp"
                    android:scaleType="center"
                    android:background="#0ACDA3"
                    android:id="@+id/close_session_history"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_gravity="right"
                    />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="BẢNG THÔNG TIN LỊCH SỬ"
                    android:textSize="17dp"
                    android:layout_marginBottom="15dp"
                    android:layout_marginTop="15dp"
                    android:textColor="#FFFFFF"/>

            </LinearLayout>

@code-mc
Copy link
Owner

code-mc commented May 20, 2018

I don't really see anything unusual, so I'm going to try and run some tests with API 16 and see if I can find something myself.

EDIT: @cuongpham2110 is this crash happening on a physical device (if so which one?) or an emulator?

@cuongpham2110
Copy link
Author

I used mutilple MaterialIconView icons in my Layout and I have detected error is here:

    <net.steamcrafted.materialiconlib.MaterialIconView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="40dp"
        android:layout_height="40dp"
        app:materialIcon="chevron_up"
        app:materialIconColor="#FFFFFF"
        app:materialIconSize="30dp"
        android:scaleType="center"
        android:background="@drawable/background_for_icon_open_bottomsheet"  <!-- crash here -->
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="10dp"
        android:id="@+id/open_bottom_sheet"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:visibility="gone"
        android:layout_gravity="right"
        />

</RelativeLayout>

if I delete this line, everything turn to be good. Thank for give me the tip. I found where the problem is. But how can I set the background for this MaterialIconView ?

@code-mc
Copy link
Owner

code-mc commented May 20, 2018

What kind of drawable is this (root xml tag of the background_for_icon_open_bottomsheet)? Could be an unsupported type for the background tag.

Just to be clear, this issue is unrelated to the library as this will happen with any view you use this specific background for.

@cuongpham2110
Copy link
Author

I put background_for_icon_open_bottomsheet.xml in drawable-v21 and that was the wrong implementation. I just put it in drawable and It WORKS.
Thank you so much again.

@code-mc code-mc closed this as completed May 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants