I am receiving many errors of kind displayed in the subj. These errors seems to be occasional and I cannot reproduce them. From stack I can learn that such error may occurs
For me, my issue was that I was
android:background="?attr/selectableItemBackground"
To a LinearLayout background, once I removed it the test passed.
I had this problem just now and managed to figure out what it was. Was referencing a colour in my values that was causing problems. So defined it manually instead of using one from the dropdown suggestions.Then it worked!
Solved it by moving all my drawable items from drawable-v24 to drawable
I had faced the same issue, I had used view tag in xml instead of View. Replacing to View class fixed the issue.
Hope it helps for you too..
We need to check API Version. I used to give background color to my LinearLayout
like
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/as_royalblue"
android:orientation="vertical"></LinearLayout>
for sure I had the same error, as_royalblue.xml
inside drawable
folder
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:endColor="@color/royalblue_s"
android:startColor="@color/royalblue_e" />
</shape>
and how I fixed it, actually it seems Api problem so we need to check the api level if it is above API 24 so we are able to use the way we like. But if it is under 24 we need to avoid usage, juts give a normal color or one color not color gradential mixed one.
fun checkAPI_N(): Boolean {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N)
return true
else
return false
}
give id to your linearlayouts and set backgrounds if its ok
if(UtilKotlin.checkAPI_N()){
linlay_act_menu_container.setBackgroundResource(R.drawable.a_6)
linlay_act_menu_logo.setBackgroundResource(R.drawable.as_strain)
}else {//todo normal color background setting}
For me, the error message was actually insufficient in the log cat, so here's what I did to figure out what caused the problem:
(In the log cat error message, it said the error occurred while inflating a specific layout in my HomeFragment.java)
Evaluate expression
on it:
Run > Evaluate Expression
or alt - F8
tools:targetApi="lollipop"
(the bug only occurred on older devices).