navasmdc / MaterialDesignLibrary

This is a library with components of Android L to you use in android 2.2
Apache License 2.0
9k stars 2.23k forks source link

Error inflating class com.gc.materialdesign.views.CheckBox in API 10 #162

Open jmvines opened 9 years ago

jmvines commented 9 years ago

Hi guys,

CheckBox works in API > 10, but in API 10 generates this crash.

android.view.InflateException: Binary XML file line #58: Error inflating class com.gc.materialdesign.views.CheckBox at android.view.LayoutInflater.createView(LayoutInflater.java:518) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570) at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) at android.view.LayoutInflater.inflate(LayoutInflater.java:408) at android.view.LayoutInflater.inflate(LayoutInflater.java:320) at android.view.LayoutInflater.inflate(LayoutInflater.java:276) at com.afollestad.materialdialogs.MaterialDialog$Builder.customView(MaterialDialog.java:1313) at com.resem.app.fragments.DetailDevelopmentAdvertFragment$2.onClick(DetailDevelopmentAdvertFragment.java:200) at android.view.View.performClick(View.java:2485) at android.view.View$PerformClick.run(View.java:9080) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 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:415) at android.view.LayoutInflater.createView(LayoutInflater.java:505)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)             at android.view.LayoutInflater.inflate(LayoutInflater.java:408)             at android.view.LayoutInflater.inflate(LayoutInflater.java:320)             at android.view.LayoutInflater.inflate(LayoutInflater.java:276)             at com.afollestad.materialdialogs.MaterialDialog$Builder.customView(MaterialDialog.java:1313)             at com.resem.app.fragments.DetailDevelopmentAdvertFragment$2.onClick(DetailDevelopmentAdvertFragment.java:200)             at android.view.View.performClick(View.java:2485)             at android.view.View$PerformClick.run(View.java:9080)             at android.os.Handler.handleCallback(Handler.java:587)             at android.os.Handler.dispatchMessage(Handler.java:92)             at android.os.Looper.loop(Looper.java:130)             at android.app.ActivityThread.main(ActivityThread.java:3683)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:507)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)             at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.gc.materialdesign.views.CheckBox.invalidate(CheckBox.java:83) at android.view.View.setBackgroundDrawable(View.java:7626) at android.view.View.(View.java:2160) at android.view.View.(View.java:1899) at android.view.ViewGroup.(ViewGroup.java:286) at android.widget.RelativeLayout.(RelativeLayout.java:173) at com.gc.materialdesign.views.CustomView.(CustomView.java:22) at com.gc.materialdesign.views.CheckBox.(CheckBox.java:32)             at java.lang.reflect.Constructor.constructNative(Native Method)             at java.lang.reflect.Constructor.newInstance(Constructor.java:415)             at android.view.LayoutInflater.createView(LayoutInflater.java:505)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)             at android.view.LayoutInflater.inflate(LayoutInflater.java:408)             at android.view.LayoutInflater.inflate(LayoutInflater.java:320)             at android.view.LayoutInflater.inflate(LayoutInflater.java:276)             at com.afollestad.materialdialogs.MaterialDialog$Builder.customView(MaterialDialog.java:1313)             at com.resem.app.fragments.DetailDevelopmentAdvertFragment$2.onClick(DetailDevelopmentAdvertFragment.java:200)             at android.view.View.performClick(View.java:2485)             at android.view.View$PerformClick.run(View.java:9080)             at android.os.Handler.handleCallback(Handler.java:587)             at android.os.Handler.dispatchMessage(Handler.java:92)             at android.os.Looper.loop(Looper.java:130)             at android.app.ActivityThread.main(ActivityThread.java:3683)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:507)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)             at dalvik.system.NativeStart.main(Native Method)

Thanks.

danielwilson1702 commented 9 years ago

+1 Surprised this hasn't been fixed, the checkbox is a little sketchy anyway, method names are slightly different for example (isCheck() or setOncheckListener()). For the moment we're probably better off sticking with the stock check box

hoangtubatu commented 9 years ago

Caused by: java.lang.NullPointerException at com.gc.materialdesign.views.CheckBox.invalidate(CheckBox.java:83)

just code check if it != null at CheckBox.java:83

lfd-gitHub commented 8 years ago

/**