I encountered this error in android studio while learning it:
08-20 11:56:52.192 9815-9815/com.example.android.courtcountee1 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.courtcountee1, PID: 9815
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.courtcountee1/com.example.android.courtcountee1.MainActivity}: android.view.InflateException: Binary XML file line #66: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #66: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.android.courtcountee1.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.android.courtcountee1.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
The XML
i THINK THE VIEW TAG IS CAUSING THE PROBLEM AS REMOVING IT RESOLVED THIS
<?xml version="1.0" encoding="utf-8"?>
<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"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:layout_weight="1"
android:orientation="vertical"
tools:context="com.example.android.courtcounter.MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="Team A" />
<TextView
android:id="#+id/team_a_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:fontFamily="sans-serif-light"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="0"
android:textColor="#000000"
android:textSize="56dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="threePoints"
android:text="+3 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="twoPoints"
android:text="+2 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="freeThrow"
android:text="Free Throw" />
</LinearLayout>
<!--<view
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:background="#android:color/darker_gray">
</view>-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="24dp"
android:layout_weight="1"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="Team B"
android:textColor="#616161"
android:textSize="14sp" />
<TextView
android:id="#+id/team_b_score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:fontFamily="sans-serif-light"
android:gravity="center_horizontal"
android:padding="4dp"
android:text="0"
android:textColor="#000000"
android:textSize="56dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="threePointsB"
android:text="+3 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="twoPointsB"
android:text="+2 POINTS" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="freeThrowB"
android:text="Free Throw" />
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="32dp"
android:onClick="reset"
android:text="RESET" />
</RelativeLayout>
View tag must start with the capital letter, like this:
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:background="#android:color/darker_gray">
</View>
In fact,Every xml View tag will through the LayoutInflater class construct a real View class. About LayoutInflater, It will combine the xml tag with the View class in package android.view.、android.widget、android.webkit、android.app. About you use the view tag, you should use like this.
<view
android:id="#+id/test"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
class="androidx.constraintlayout.utils.widget.ImageFilterView"
android:background="#color/colorAccent"
/>
you must appoint the target class. because the LayoutInflater tell us should do.
View createViewFromTag(View parent, String name, Context context, AttributeSet attrs,
boolean ignoreThemeAttr) {
if (name.equals("view")) {
name = attrs.getAttributeValue(null, "class");
}
// Apply a theme wrapper, if allowed and one is specified.
if (!ignoreThemeAttr) {
final TypedArray ta = context.obtainStyledAttributes(attrs, ATTRS_THEME);
final int themeResId = ta.getResourceId(0, 0);
if (themeResId != 0) {
context = new ContextThemeWrapper(context, themeResId);
}
ta.recycle();
}
if (name.equals(TAG_1995)) {
// Let's party like it's 1995!
return new BlinkLayout(context, attrs);
}
...
because you not appoint the class.It can not find the real class about it,So It cause the exception.
Related
I'm trying to start this fragment but I'm taking the error below. From what I read, this seems to have a possible large image, but I didn't identify it, after all in this part it calls maps. If anyone has experienced this error, I am grateful for the contribution!`
2021-06-14 12:42:10.327 26833-26833/com.helpcars.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.helpcars.app, PID: 26833
android.view.InflateException: Binary XML file line #133: Binary XML file line #133: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #133: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.helpcars.app.Fragments.HomeFragment.onCreateView(HomeFragment.java:308)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.content.res.Resources$NotFoundException: Drawable android:color/primary_text_dark with resource ID #0x1060001
Caused by: android.content.res.Resources$NotFoundException: File res/color/primary_text_dark.xml from drawable resource ID #0x1060001
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:847)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:631)
at android.content.res.Resources.loadDrawable(Resources.java:897)
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:955)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.view.View.<init>(View.java:5010)
at android.view.ViewGroup.<init>(ViewGroup.java:659)
at android.widget.LinearLayout.<init>(LinearLayout.java:244)
at android.widget.LinearLayout.<init>(LinearLayout.java:240)
at android.widget.LinearLayout.<init>(LinearLayout.java:236)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
2021-06-14 12:42:10.331 26833-26833/com.helpcars.app E/AndroidRuntime: at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.helpcars.app.Fragments.HomeFragment.onCreateView(HomeFragment.java:308)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #18: <item> tag requires a 'drawable' attribute or child tag defining a drawable
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:190)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:122)
at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:833)
... 42 more
This is the XML of the layout I'm trying to "Inflate".
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Map frame -->
<LinearLayout
android:id="#+id/mapLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/provider_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!--Project Flow-->
<!--Request to providers-->
<LinearLayout
android:id="#+id/lnrRequestProviders"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#android:color/white"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rcvServiceTypes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_marginTop="#dimen/_5sdp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/view_bg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_10sdp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="#+id/imgPaymentType"
android:layout_width="#dimen/_20sdp"
android:layout_height="#dimen/_20sdp"
app:srcCompat="#drawable/money1" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblPaymentType"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/selected_payment_mode"
android:textColor="#android:color/black"
android:textSize="16sp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblPaymentChange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="#string/change"
android:textColor="#android:color/holo_blue_dark"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<com.helpcars.app.Utils.MyButton
android:id="#+id/btnRequestRides"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="#dimen/_10sdp"
android:layout_marginLeft="#dimen/_20sdp"
android:layout_marginRight="#dimen/_20sdp"
android:layout_marginTop="#dimen/_10sdp"
android:background="#drawable/rounded_button"
android:text="#string/estimate"
android:textColor="#color/button_text_color" />
</LinearLayout>
<!-- Provider popup Layout-->
<LinearLayout
android:id="#+id/lnrProviderPopup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:id="#+id/lnrHidePopup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/transparent_black"
android:orientation="vertical"
android:visibility="gone">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#android:color/primary_text_dark"
android:gravity="center"
android:orientation="vertical"
android:padding="#dimen/_10sdp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imgProviderPopup"
android:layout_width="#dimen/_60sdp"
android:layout_height="#dimen/_60sdp"
android:layout_marginTop="#dimen/_5sdp"
android:src="#drawable/pickup_drop_icon" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblServiceName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_10sdp"
android:gravity="center"
android:maxLines="1"
android:text=""
android:textColor="#color/text_color_black"
android:textSize="#dimen/_14sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_5sdp"
android:gravity="center"
android:maxLines="1"
android:text="Aguarde o reboque em um local seguro"
android:textColor="#color/text_color_black"
android:textSize="#dimen/_14sdp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginTop="#dimen/_10sdp"
android:background="#android:color/primary_text_dark"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:id="#+id/lnrPriceBase"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start"
android:maxLines="1"
android:text="Base Price"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblBasePricePopup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end"
android:maxLines="1"
android:text=""
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
<LinearLayout
android:id="#+id/lnrPricekm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start|center"
android:maxLines="1"
android:text="Price/km"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblPriceKm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end"
android:maxLines="1"
android:text=""
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
<LinearLayout
android:id="#+id/lnrPricemin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start|center"
android:maxLines="1"
android:text="Price/min"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblPriceMin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end"
android:maxLines="1"
android:text=""
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
<LinearLayout
android:id="#+id/lnrCalculationType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start|center"
android:maxLines="1"
android:text="- É obrigatório o acompanhamento do responsável"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
<LinearLayout
android:id="#+id/lnrCapacity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:orientation="horizontal">
<com.helpcars.app.Utils.MyBoldTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start|center"
android:maxLines="1"
android:text="- Para remoção, somente veículos descarregados"
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblCapacity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end"
android:maxLines="1"
android:text=""
android:textColor="#color/black_text_color"
android:textSize="#dimen/_12sdp" />
</LinearLayout>
</LinearLayout>
<com.helpcars.app.Utils.MyBoldTextView
android:id="#+id/lblProviderDesc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_15sdp"
android:layout_weight="1"
android:lineSpacingMultiplier="1.3"
android:text="The fare will be the price presented upon booking, or, if the journey changes, the fare will be based on the rates provided. Tap fare for details."
android:textSize="#dimen/_10sdp" />
</LinearLayout>
HomeFragment
#Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
if (rootView == null) {
rootView = inflater.inflate(R.layout.fragment_home, container, false);
}
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
init(rootView);
//permission to access location
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// Android M Permission check
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
} else {
initMap();
MapsInitializer.initialize(getActivity());
}
}
}, 500);
return rootView;
}
The detail is that it works for various devices and android versions, but specifically for the Moto G Android Pie I get this error.
The error is on the XML file line #133, but I couldn't understand why the LinearLayout starts there.
Possible solution based on the provided source code:
Check if you have used android:src instead of app:srcCompat to assign vector assets. Is #drawable/pickup_drop_icon a vector asset? If yes, you should NOT use android:src.
You forgot to place the trailing </LinearLayout> of the parent.
Add </LinearLayout> to the bottom of your code.
Try code folding the XML file, you will notice that it is missing a </LinearLayout> at the end.
when the compiler gives a generic error message Binary XML file line #133: Error inflating class, I recommend that you first identify if there are any errors in the XML file.
Let me know if you have any questions.
First of all, I know that Material Components 1.1.0 is still in alpha and I am aware, that it can be unstable, but I am interested in some solution. It still could be some problem in my code.
I am creating Alert Dialog with custom view and it is just crashing with such logs. It is working perfectly on some devices and just crashing on other.
android.content.res.Resources$NotFoundException: File res/drawable-v21/abc_dialog_material_background.xml from color state list resource ID #0x7f080019
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2750)
at android.content.res.Resources.loadColorStateList(Resources.java:2699)
at android.content.res.TypedArray.getColor(TypedArray.java:439)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:3780)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:3981)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:1969)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:699)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:641)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:535)
at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
at android.app.Dialog.show(Dialog.java:295)
at com.itemstudio.castro.services.dialogs.DialogsHelper.openScreenTesterSettingsDialog(DialogsHelper.kt:168)
at com.itemstudio.castro.screens.tools.screen_tester_activity.ScreenTesterView$initClickListeners$1.onClick(ScreenTesterView.kt:25)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid color state list tag inset
at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:217)
at android.content.res.ColorStateList.createFromXml(ColorStateList.java:201)
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2746)
at android.content.res.Resources.loadColorStateList(Resources.java:2699)
at android.content.res.TypedArray.getColor(TypedArray.java:439)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:3780)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:3981)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:1969)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:699)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:641)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:535)
at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
at android.app.Dialog.show(Dialog.java:295)
at com.itemstudio.castro.services.dialogs.DialogsHelper.openScreenTesterSettingsDialog(DialogsHelper.kt:168)
at com.itemstudio.castro.screens.tools.screen_tester_activity.ScreenTesterView$initClickListeners$1.onClick(ScreenTesterView.kt:25)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Here is my XML.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="24dp"
android:background="?attr/colorBackgroundSecondary"
android:paddingTop="24dp"
android:paddingEnd="24dp"
android:paddingBottom="8dp">
<TextView
android:id="#+id/screenTesterOptionsLayoutTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:fontFamily="sans-serif-medium"
android:text="#string/screen_tester_dialog_title"
android:textColor="?android:attr/textColorPrimary"
android:textSize="20sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="vertical">
<Switch
android:id="#+id/screenTesterOptionsDifferentColors"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_different_colors" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<Switch
android:id="#+id/screenTesterOptionsCoordinates"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_coordinates" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<Switch
android:id="#+id/screenTesterOptionsLines"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_lines" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<Switch
android:id="#+id/screenTesterOptionsVibration"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration" />
<View
android:id="#+id/screenTesterOptionsVibrationIntensityDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="?attr/colorDivider" />
<TextView
android:id="#+id/screenTesterOptionsVibrationIntensityTitle"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:text="#string/screen_tester_dialog_vibration_intensity"
android:textColor="?android:attr/textColorPrimary" />
<RadioGroup
android:id="#+id/screenTesterOptionsVibrationIntensitySelection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp">
<RadioButton
android:id="#+id/screenTesterOptionsVibrationIntensityLow"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration_intensity_low"
android:textColor="?android:attr/textColorSecondary" />
<RadioButton
android:id="#+id/screenTesterOptionsVibrationIntensityMedium"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration_intensity_medium"
android:textColor="?android:attr/textColorSecondary" />
<RadioButton
android:id="#+id/screenTesterOptionsVibrationIntensityHigh"
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="#string/screen_tester_dialog_vibration_intensity_high"
android:textColor="?android:attr/textColorSecondary" />
</RadioGroup>
<com.google.android.material.button.MaterialButton
android:id="#+id/screenTesterOptionsLayoutButtonApply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="8dp"
android:text="#string/screen_tester_dialog_action_apply"
android:textColor="?attr/colorAccent" />
</LinearLayout>
</ScrollView>
If you think, that it is some bug in framework I will just open issue in Google's issue tracker.
The only solution that i found for now is to supercharge the dialog theme overlay :
<style name="Theme.App" parent="Theme.MaterialComponents.Light.NoActionBar" />
<item name="materialAlertDialogTheme">#style/ThemeOverlay.App.MaterialAlertDialog</item>
</style>
<style name="ThemeOverlay.App.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="android:windowBackground">#color/white</item>
</style>
I'm working on some project and i use linear layout and set image and text in it. after ending first linear layout i want another linear layout and set image. But i'm setting image my app keep on crashing.
This is Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".guidance_new"
android:id="#+id/layout"
android:background="#drawable/bg_animation"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="#+id/hanging_lamp"
android:src="#drawable/bulb1"/>
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="180dp"
android:orientation="vertical"
>
<TextView
android:layout_width="150dp"
android:layout_height="70dp"
android:text="100W Bulb"
android:textColor="#000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginLeft="180dp"
android:id="#+id/textView1"/>
<TextView
android:layout_width="150dp"
android:layout_height="80dp"
android:text="Price:100/. Voltage:220V-240V ."
android:textColor="#a9a9a9"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginLeft="180dp"
android:id="#+id/textView2"/>
/////// layout is set here
</LinearLayout>
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="#+id/chandlier"
android:src="#drawable/chandelier"
android:layout_below="#id/linear1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_below="#id/linear1">
<TextView
android:layout_width="150dp"
android:layout_height="70dp"
android:text="Chandlier"
android:textColor="#000"
android:textStyle="bold"
android:layout_marginLeft="180dp"
android:textSize="20sp"/>
</LinearLayout>
</RelativeLayout>
And this is mainlog:
06-09 18:26:34.348 23904-23904/com.example.animation E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.animation, PID: 23904
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.animation/com.example.animation.guidance_new}: android.view.InflateException: Binary XML file line #52: Binary XML file line #52: Error inflating class ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2484)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: android.view.InflateException: Binary XML file line #52: Binary XML file line #52: Error inflating class ImageView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.animation.guidance_new.onCreate(guidance_new.java:20)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: android.view.InflateException: Binary XML file line #52: Error inflating class ImageView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.animation.guidance_new.onCreate(guidance_new.java:20)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.animation:drawable/chandelier" (7f060064) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060064 a=-1 r=0x7f060064}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2617)
at android.content.res.Resources.loadDrawable(Resources.java:2555)
at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
at android.widget.ImageView.<init>(ImageView.java:152)
at android.widget.ImageView.<init>(ImageView.java:140)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
at android.support.v7.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:182)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.animation.guidance_new.onCreate(guidance_new.java:20)
at android.app.Activity.performCreate(Activity.java:6248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2437)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)
at android.app.ActivityThread.access$900(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
06-09 18:26:34.357 23904-23927/com.example.animation V/FA: Connection attempt already in progress
Resource that you are trying to display in ImageView (chandelier) is invalid.
You can read in your log that: Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.animation:drawable/chandelier" (7f060064) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060064 a=-1 r=0x7f060064} Check if path to the file is correct and try to display other image.
Try this xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".guidance_new"
android:id="#+id/layout"
android:background="#drawable/bg_animation"
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="#+id/hanging_lamp"
android:src="#drawable/bulb1"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="70dp"
android:text="100W Bulb"
android:textColor="#000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginLeft="30dp"
android:id="#+id/textView1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="80dp"
android:text="Price:100/. Voltage:220V-240V ."
android:textColor="#a9a9a9"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginLeft="30dp"
android:id="#+id/textView2"/>
</LinearLayout>
/////// layout is set here
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/chandelier"
android:orientation="horizontal"
android:layout_marginTop="30dp">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="#+id/chandlier"
android:src="#drawable/bulb1"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="70dp"
android:textColor="#000"
android:textStyle="bold"
android:text="Chandlier"
android:textSize="20sp"
android:layout_marginLeft="30dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
After target my apps to api 28, Fabric shows me some crashes that said:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mydomain.myapp/com.mydomain.myapp.SplashScreen}: android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2330)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5278)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at base.activity.BaseSplash.onCreate(BaseSplash.java:149)
at com.mydomain.myapp.SplashScreen.onCreate(SplashScreen.java:77)
In all kinds of devices and in the splash screen but only on less than 0.1% of the users. Before target to API 28 I did not have this error.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bckgrnd_splash">
<View
android:id="#+id/grass"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#color/grass"
android:layout_alignParentBottom="true"/>
<View
android:background="#drawable/grass"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:id="#+id/grassImage"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<View
android:background="#drawable/road_bckgrnd"
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/roadView"
android:layout_above="#+id/grass"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<View
android:background="#color/grassRoad"
android:layout_width="match_parent"
android:layout_height="30dp"
android:id="#+id/topRoadView"
android:layout_above="#+id/roadView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<View
android:id="#+id/buildins"
android:background="#drawable/buildings_cloud"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_above="#+id/topRoadView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageView
android:paddingTop="20dp"
android:src="#drawable/splash_bus_sitp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/grassImage"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:id="#+id/sitpImage" />
<ImageView
android:id="#+id/taxiImage"
android:src="#drawable/splash_taxi"
android:layout_above="#id/grass"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"/>
<ImageView
android:id="#+id/tmImage"
android:src="#drawable/splash_bus_tm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_above="#+id/grassImage"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageView
android:id="#+id/cloudLeft"
android:layout_marginTop="32dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:src="#drawable/splash_cloud_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/logo"
android:layout_marginTop="48dp"
android:layout_below="#id/cloudLeft"
android:src="#drawable/splash_logo"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:layout_marginTop="32dp"
android:layout_below="#id/logo"
android:layout_alignParentRight="true"
android:src="#drawable/splash_cloud_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
Someone can help me with this issue? or maybe know something about that? Line #14 is the second view.
Thanks for your help.
This is the error that occurs when I click a button:
09-15 01:09:08.934 32386-32386/com.example.ajalandoni.chemistryworld E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ajalandoni.chemistryworld, PID: 32386
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ajalandoni.chemistryworld/sarveshchavan777.triviaquiz.MainGameActivity}: android.view.InflateException: Binary XML file line #105: Binary XML file line #105: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2781)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
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 #105: Binary XML file line #105: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #105: Error inflating class <unknown>
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.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at sarveshchavan777.triviaquiz.MainGameActivity.onCreate(MainGameActivity.java:36)
at android.app.Activity.performCreate(Activity.java:7013)
at android.app.Activity.performCreate(Activity.java:7004)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2734)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
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: java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
at android.content.res.TypedArray.getColor(TypedArray.java:473)
at info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)
at info.hoang8f.widget.FButton.<init>(FButton.java:52)
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.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at sarveshchavan777.triviaquiz.MainGameActivity.onCreate(MainGameActivity.java:36)
at android.app.Activity.performCreate(Activity.java:7013)
at android.app.Activity.performCreate(Activity.java:7004)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2734)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1592)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
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)
This my activity_game_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fbutton="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/backgroundColor"
android:orientation="vertical"
tools:context="sarveshchavan777.triviaquiz.MainGameActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#color/lightGreen"
android:minHeight="?actionBarSize">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="0dp">
<ImageView
android:id="#+id/coinImage"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/coin" />
<TextView
android:id="#+id/coinText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text=""
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:gravity="center"
android:textSize="20sp"
android:layout_toRightOf="#id/coinImage"
android:layout_toEndOf="#id/coinImage" />
<TextView
android:id="#+id/triviaQuizText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/app_name"
android:textColor="#color/white"
android:textSize="25sp"
android:layout_toLeftOf="#+id/timeText"
android:layout_toRightOf="#+id/coinText"
android:layout_toStartOf="#+id/timeText"
android:layout_toEndOf="#+id/coinText" />
<TextView
android:id="#+id/timeText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:paddingLeft="10dp"
android:gravity="center"
android:paddingRight="10dp"
android:text="#string/time"
android:textSize="20sp" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<View
android:layout_width="match_parent"
android:layout_height="10dp"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".5"
android:background="#color/white"
android:orientation="vertical">
<TextView
android:id="#+id/triviaQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="#string/question"
android:textColor="#color/grey"
android:textSize="18sp" />
<TextView
android:id="#+id/resultText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text=""
android:textColor="#color/green"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<info.hoang8f.widget.FButton
android:id="#+id/buttonA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:onClick="buttonA"
android:text=""
android:textColor="#color/grey"
fbutton:buttonColor="#color/white"
fbutton:cornerRadius="10dp"
fbutton:shadowColor="#color/grey" />
<info.hoang8f.widget.FButton
android:id="#+id/buttonB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:onClick="buttonB"
android:text=""
android:textColor="#color/grey"
fbutton:buttonColor="#color/white"
fbutton:cornerRadius="10dp"
fbutton:shadowColor="#color/grey" />
<info.hoang8f.widget.FButton
android:id="#+id/buttonC"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:onClick="buttonC"
android:text=""
android:textColor="#color/grey"
fbutton:buttonColor="#color/white"
fbutton:cornerRadius="10dp"
fbutton:shadowColor="#color/grey" />
<info.hoang8f.widget.FButton
android:id="#+id/buttonD"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:onClick="buttonD"
android:text=""
android:textColor="#color/grey"
fbutton:buttonColor="#color/white"
fbutton:cornerRadius="10dp"
fbutton:shadowColor="#color/grey" />
</LinearLayout>
</LinearLayout>
What could be the possible cause of this problem?
I already tried this solution, but this doesn't work for me.
Change your dependency with this
compile 'com.github.jd-alexander:android-flat-button:v1.1'
use this library it will fix your problem. The library you are using has some issue check this library.
Also add maven { url "https://jitpack.io" } in build.gradle (Project Level) in repositories block your code will look like this :
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
Well I think the problem is with the android gradle plugin version. Try changing it to 2.3.3 in File -> Project Structure -> Project.