java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at android.view.LayoutInflater.createView(LayoutInflater.java:647) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) ... Caused by: android.content.res.Resources$NotFoundException: Drawable com.example.myapplication:color/tab_bg with resource ID #0x7f040055 Caused by: android.content.res.Resources$NotFoundException: File res/color/tab_bg.xml from drawable resource ID #0x7f040055 at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820) at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630) at android.content.res.Resources.loadDrawable(Resources.java:886) at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:953) at android.content.res.TypedArray.getDrawable(TypedArray.java:928) ... Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #3: <item> tag requires a 'drawable' attribute or child tag defining a drawable at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:189) at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:122) at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
privatevoidinflateChildElements(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)throws XmlPullParserException, IOException { finalStateListStatestate= mStateListState; finalintinnerDepth= parser.getDepth() + 1; int type; int depth; while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) { if (type != XmlPullParser.START_TAG) { continue; }
if (depth > innerDepth || !parser.getName().equals("item")) { continue; }
// This allows state list drawable item elements to be themed at // inflation time but does NOT make them work for Zygote preload. finalTypedArraya= obtainAttributes(r, theme, attrs, R.styleable.StateListDrawableItem); Drawabledr= a.getDrawable(R.styleable.StateListDrawableItem_drawable); a.recycle();
finalint[] states = extractStateSet(attrs);
// Loading child elements modifies the state of the AttributeSet's // underlying parser, so it needs to happen after obtaining // attributes and extracting states. if (dr == null) { while ((type = parser.next()) == XmlPullParser.TEXT) { } if (type != XmlPullParser.START_TAG) { thrownewXmlPullParserException( parser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable"); } dr = Drawable.createFromXmlInner(r, parser, attrs, theme); }
@NonNull Drawable inflateFromXmlForDensity(@NonNull String name, @NonNull XmlPullParser parser, @NonNull AttributeSet attrs, int density, @Nullable Theme theme) throws XmlPullParserException, IOException { // Inner classes must be referenced as Outer$Inner, but XML tag names // can't contain $, so the <drawable> tag allows developers to specify // the class in an attribute. We'll still run it through inflateFromTag // to stay consistent with how LayoutInflater works. if (name.equals("drawable")) { name = attrs.getAttributeValue(null, "class"); if (name == null) { thrownewInflateException("<drawable> tag must specify class attribute"); } }