My app fails to start because of Error inflating class ImageButton, Because of this the phone says "app has stopped" Etc.
I am using firebase test lab to debug the problem
the Errors occur on samsung devices specifically A20, s7 Edge , s7(tested with firebase same problem)
I am new to android and have tried many solutions from google and SO none have worked sofar
Here is the error report on firebase
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartpractice.smartpracticesmartapp/com.smartpractice.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #117: Binary XML file line #117: Error inflating class ImageButton
FATAL EXCEPTION: main
Process: com.smartpractice.smartpracticesmartapp, PID: 26921
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartpractice.smartpracticesmartapp/com.smartpractice.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #117: Binary XML file line #117: Error inflating class ImageButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
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 #117: Binary XML file line #117: Error inflating class ImageButton
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 androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.smartpractice.myapplication.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
... 9 more
Caused by: android.view.InflateException: Binary XML file line #117: Error inflating class ImageButton
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
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)
... 17 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070089
at android.content.res.Resources.getValue(Resources.java:2558)
at androidx.appcompat.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:331)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:102)
at androidx.appcompat.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:59)
at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:79)
at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:69)
at androidx.appcompat.app.AppCompatViewInflater.createImageButton(AppCompatViewInflater.java:202)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:122)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:758)
Here is the XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/relativeLayout4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/ic_launcher_background"
tools:context=".MainActivity">
<com.google.android.flexbox.FlexboxLayout
android:id="#+id/flexboxLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:alignContent="stretch"
app:alignItems="stretch"
app:flexWrap="wrap"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.863"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/guideline7">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="48dp"
android:fontFamily="#font/nunito"
android:gravity="center_horizontal"
android:text="#string/welcome_to_smartpractice"
android:textSize="24sp"
app:fontFamily="#font/nunito"
app:layout_alignSelf="baseline"
tools:layout_editor_absoluteY="100dp"
tools:targetApi="jelly_bean" />
<TextView
android:id="#+id/textView7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
android:gravity="center_horizontal|fill_vertical"
android:text="#string/docsharesmart"
android:textColor="#color/ic_launcher_background"
app:layout_alignSelf="flex_end"
tools:layout_editor_absoluteY="16dp" />
</com.google.android.flexbox.FlexboxLayout>
<com.google.android.flexbox.FlexboxLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:alignContent="center"
app:alignItems="stretch"
app:flexDirection="row"
app:flexWrap="nowrap"
app:justifyContent="space_between"
app:layout_constraintBottom_toTopOf="#+id/guideline7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/imageView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/logo1"
app:layout_alignSelf="center"
app:srcCompat="#drawable/smartpractice_logo_02"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="-46dp" />
<ImageButton
android:id="#+id/LoginScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#null"
android:contentDescription="#string/loginscreen"
app:layout_alignSelf="center"
app:layout_wrapBefore="false"
app:srcCompat="#drawable/ic_more_vert_black_24dp"
tools:layout_editor_absoluteX="248dp"
tools:layout_editor_absoluteY="134dp" />
</com.google.android.flexbox.FlexboxLayout>
<com.google.android.flexbox.FlexboxLayout
android:id="#+id/flexboxLayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:alignContent="stretch"
app:alignItems="stretch"
app:flexWrap="wrap"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/flexboxLayout"
app:layout_constraintVertical_bias="0.146">
Here is line 117 from the error
<ImageButton
android:id="#+id/UploadButton"
android:layout_width="300dp"
android:layout_height="209dp"
android:background="#android:color/transparent"
app:layout_constraintTop_toBottomOf="#+id/flexboxLayout"
app:srcCompat="#drawable/upload_files_upload"
android:contentDescription="#string/todo" />
</com.google.android.flexbox.FlexboxLayout>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="185dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
It means upload_files_upload is not found in drawble folder, well this can be a case, where your file may present in drawable-24 but not in drawble folder, in that case this problem still arise. The point is your file must be in all drawble folder.
The reason for your error is that the upload_files_upload is not in your drawable folder :
<ImageButton
android:id="#+id/UploadButton"
android:layout_width="300dp"
android:layout_height="209dp"
android:background="#android:color/transparent"
app:layout_constraintTop_toBottomOf="#+id/flexboxLayout"
app:srcCompat="#drawable/upload_files_upload"// this line
android:contentDescription="#string/todo" />
I have solved The Issue I changed app:srcCompat="#drawable/upload_files_upload"// to android:src="#drawable/upload_files_upload"
So the problem was by app:srcCompat I changed it to Android:src and it works fine now
Related
When working with 4.7 WXGA API 23, I am getting the error of "android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class "
but in higher versions, it is all working well, I have added the code and the xml layout for my issue, don't understand why it is happening so
Code where this error is occurring
#NonNull
#Override
public PostsHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.post_list_layout,
parent, false);
return new PostsHolder(v);
}
XML Layout for recyclerview Item
<?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"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/shadow_300_50"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:padding="5dp"
android:orientation="horizontal"
>
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="#drawable/profile"
android:id="#+id/post_user_profile_image"
android:scaleType="centerCrop"
android:layout_marginLeft="4dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Username"
android:id="#+id/post_item_username"
android:layout_marginLeft="5dp"
android:layout_marginTop="8dp"
android:textAlignment="textStart"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#android:color/black"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Time"
android:id="#+id/post_item_time"
android:layout_marginLeft="257dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:textAlignment="textStart"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#android:color/black"/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:id="#+id/post_item_title"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:textAlignment="textStart"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="5dp"
android:padding="2dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="post_item_Category"
android:textColor="#color/colorPrimaryDark"
android:textSize="13sp"
android:textStyle="bold"
android:id="#+id/post_item_Category"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Post_item_SpinnerC"
android:textColor="#color/colorPrimaryDark"
android:textSize="13sp"
android:id="#+id/post_item_SpinnerC"
android:layout_marginLeft="7dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/post_item_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginRight="3dp"
android:padding="3dp"
android:text="Post Description"
android:textColor="#android:color/black"
android:textSize="14dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:padding="2dp">
<Button
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mark"
app:srcCompat="#drawable/ic_heart_normal"
android:background="#drawable/button"/>
<Button
android:id="#+id/commenting_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="140dp"
android:text="Comment"
android:background="#drawable/button"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
The problem is that a constructor for a class for creating one of the widgets doesn't exist or can't be found. The LayoutInflater class (in the sdk, ie: Android\Sdk\sources\android-17\android\view\LayoutInflater.java) uses reflection(code introspection) on the widget name to build the widget object. In your case I would guess it is 'de.hdodenhof.circleimageview.CircleImageView', in my case it was 'androidx.appcompat.widget.Toolbar'.
Finding the problem is buried in several layers of exceptions, and only the (pretty useless) 'Binary XML file line #7: Error inflating class...' message appears. I set up Android Studio to break on the android.view.InflateException exception:
The 'ie' InflateException at the bottom contains a java.lang.reflect.InvocationTargetException, which was in turn caused by a android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f03008f a=-1} exception (in my case)
In the LayoutInflator code:
Lin 616 is where they embed the exception named 'e' in the InflationException. Using the 'Evaluate Expression' feature of AS, I called 'e.getStackTrace()' which shows where the error really occurred:
StackTrace line 2 shows that it was line LayoutInflater line 587 (seen with red background in code image above) that threw the exception. Looking up to stackTrace line 0, it is the java.lang.reflect.Constructor.constructNative method that threw the original exception.
LayoutInflator line 587 is was trying to instanciate androidx.appcompat.widget.Toolbar (for me) and was looking for a Toolbar constructor with 2 arguments:
1) Context: ref to activity in which the layout was being inflated
2) AttributeSet: the opaque XmlBlock object named 'attrs'
I found this out by using Expression Evaluator on 'this.mConstructorArgs' (seen in line 584 of the code).
So, for me, it could not find a constructor with the Toolbar(Activity, XmlBlock) signature. So I have to look into where Toolbar is defined in by configuration and find out what constructors it has.
The usual 'solution' people give as in this question, is to clear caches, reset support libraries, run with the latest dependencies etc, which don't get you to the root cause, and sometimes don't work.
I'm documenting this here somewhat for my own future problems -- and also as a plea to the Android developers to give clearer error messages. 'Binary XML file line #7: Error inflating' doesn't help much and line 7 of some Binary XML file doesn't give and clues.
#ramneek, 'de.hdodenhof.circleimageview.CircleImageView' is the only unusual widget you are inflating there must be some method or constructor for that class/widget that the inflator can't find.
I am facing an error on android studio. I have been working on an assignment and for the past week, with everything going according to plan. Today I added some small code and the build executes, however, it force closes the app. I tried running a previous version (which I am SURE that worked) and it's giving me the same error in logcat. The error is:
2019-05-30 13:10:01.626 28770-28770/? E/Zygote: isWhitelistProcess -
Process is Whitelisted
2019-05-30 13:10:01.629 28770-28770/? E/Zygote: accessInfo : 1
2019-05-30 13:10:02.768 28770-28770/com.example.myapplication
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 28770
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.myapplication/
com.example.myapplication.fingerprint}:
android.view.InflateException: Binary XML file line #70: Binary XML
file
line #70: Error inflating class Button
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3115)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3258)
at
android.app.servertransaction.LaunchActivityItem.execute
(LaunchActivityItem.ja va:78)
at
android.app.servertransaction.TransactionExecutor.
executeCallbacks(TransactionExecutor.java:108)
at
android.app.servertransaction.TransactionExecutor.
execute(TransactionExecutor.java:68)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7073)
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:964)
Caused by: android.view.InflateException: Binary XML file line #70:
Binary XML file line #70: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #70:
Error inflating class Button
Caused by: android.content.res.Resources$NotFoundException: Drawable
android:color/tertiary_text_light with resource ID #0x1060011
Caused by: android.content.res.Resources$NotFoundException: File
res/color/tertiary_text_light.xml from drawable resource ID #0x1060011
at android.content.res.ResourcesImpl.loadDrawableForCookie
(ResourcesImpl.java:898)
at
android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:677)
at android.content.res.Resources.loadDrawable(Resources.java:912)
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:5442)
at android.widget.TextView.<init>(TextView.java:1118)
at android.widget.Button.<init>(Button.java:181)
at android.widget.Button.<init>(Button.java:156)
at android.support.v7.widget.AppCompatButton.<init>
(AppCompatButton.java:71)
at android.support.v7.widget.AppCompatButton.<init>
(AppCompatButton.java:67)
at android.support.v7.app.AppCompatViewInflater.createButton
(AppCompatViewInflater.java:187)
at android.support.v7.app.AppCompatViewInflater.createView
(AppCompatViewInflater.java:110)
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:811)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:902)
at
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:863)
at android.view.LayoutInflater.inflate(LayoutInflater.java:554)
at android.view.LayoutInflater.inflate(LayoutInflater.java:461)
at android.view.LayoutInflater.inflate(LayoutInflater.java:383)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView
(AppCompatActivity.java:140)
at com.example.myapplication.fingerprint.onCreate
(fingerprint.java:58)
at android.app.Activity.performCreate(Activity.java:7327)
at android.app.Activity.performCreate(Activity.java:7318)
at android.app.Instrumentation.callActivityOnCreate
(Instrumentation.java:1275)
at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:3095)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3258)
at android.app.servertransaction.LaunchActivityItem.execute
(LaunchActivityItem.java:78)
2019-05-30 13:10:02.773 28770-28770/com.example.myapplication
E/AndroidRuntime: at
android.app.servertransaction.TransactionExecutor.executeCallbacks
(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute
(TransactionExecutor.java:68)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7073)
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:964)
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:146)
at android.graphics.drawable.Drawable.createFromXmlInnerForDensity
(Drawable.java:1359)
at android.graphics.drawable.Drawable.createFromXmlForDensity
(Drawable.java:1318)
at android.content.res.ResourcesImpl.loadDrawableForCooki
e(ResourcesImpl.java:879)
This is my layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/darker_gray"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:theme="#style/AppTheme.AppBarOverlay"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="427dp"
android:layout_height="wrap_content"
android:background="#android:color/background_dark"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<TextView
android:id="#+id/txt_name"
android:layout_width="169dp"
android:layout_height="22dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="76dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="Enter Name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.513"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/appBarLayout" />
<EditText
android:id="#+id/eT_name"
android:layout_width="212dp"
android:layout_height="37dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.601"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/txt_name" />
<TextView
android:id="#+id/txt_surname"
android:layout_width="169dp"
android:layout_height="21dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="Enter Surname"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/txt_name" />
<EditText
android:id="#+id/eT_surname"
android:layout_width="212dp"
android:layout_height="37dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.601"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/txt_surname" />
<Button
android:id="#+id/btn_loadData"
android:layout_width="172dp"
android:layout_height="43dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="Load Data"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.506"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/eT_surname" />
<TextView
android:id="#+id/txt_savedData"
android:layout_width="219dp"
android:layout_height="102dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="132dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
The problem was that I set the color to a button. Upon changing the color, it worked. I don't know what made it not work though..
I am getting following error for the line #30 i.e. first line of first EditText in the provided code. This XML is basically associated with an Activity. The error is while binding XML inside activity
setContentView(R.layout.activity_login)
The error is as follows:
Caused by android.view.InflateException: Binary XML file line #30: Binary XML file line #30: Error inflating class EditText
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.pockethcm.greytrix.test.LoginActivity.onCreate(LoginActivity.kt:39)
at android.app.Activity.performCreate(Activity.java:6268)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2477)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5468)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:671)
I have tried couple of things explained in other answers but none of them actually helped me. I am not using any drawable resource for that EditText.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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:background="#drawable/login_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.pockethcm.greytrix.test.LoginActivity"
>
<LinearLayout
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:paddingStart="#dimen/_20sdp"
android:paddingEnd="#dimen/_20sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/login_layout">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image"
android:layout_width="match_parent"
android:layout_height="96dp"
android:src="#drawable/pocketlogosplash"
app:civ_border_width="2dp"
app:civ_circle_background_color="#color/colorWhite"
app:civ_border_color="#bcbcbc"/>
<EditText
android:layout_width="match_parent"
android:backgroundTint="#color/colorWhite"
android:layout_height="wrap_content"
android:hint="Company Code"
android:textColorHint="#color/colorWhite"
android:layout_marginTop="20dp"
android:drawableStart="#drawable/ic_store_white_24dp"
android:drawablePadding="10dp"
android:textColor="#color/colorWhite"
android:id="#+id/company_code"
android:imeOptions="actionNext"
android:maxLines="1"
android:singleLine="true"/>
<EditText
android:layout_width="match_parent"
android:backgroundTint="#color/colorWhite"
android:layout_height="wrap_content"
android:hint="Employee Code"
android:textColorHint="#color/colorWhite"
android:layout_marginTop="20dp"
android:drawableStart="#drawable/ic_person_black_24dp"
android:drawablePadding="10dp"
android:textColor="#color/colorWhite"
android:id="#+id/employee_code"
android:drawableTint="#color/colorWhite"
android:imeOptions="actionNext"
android:maxLines="1"
android:singleLine="true"/>
</LinearLayout>
</ScrollView>
EditText widget should load normally but the activity is crashing with error above.
Providing additional info:
compileSdkVersion 28
minSdkVersion 21
targetSdkVersion 28
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
You should set left drawable programmatically if its vector for pre kitkat.
company_code.setCompoundDrawablesWithIntrinsicBounds(AppCompatResources.getDrawable(this,R.drawable.ic_store_white_24dp), null, null, null);```
Which android version you are using, I think you use Vector Drawable in EditText, But Vector Drawable support after KitKat.
Can anyone tell me whats wrong with this layout? Because I can't seem to find anything unusual that could cause InflateException. Also I am getting this exception mostly on Samsung Devices, others seem to work more or less fine. Full exception
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{class name}: android.view.InflateException: Binary XML file line #0: Error inflating {class name}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/loginContainer"
style="#style/AuthenticationTheme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0">
<LinearLayout
android:id="#+id/holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="#string/window_enter_identifier_greeting_label"
android:textAlignment="center"
android:textSize="26sp" />
<TextView
android:id="#+id/info"
style="#style/AuthenticationTheme"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="#dimen/authentication_margin_from_sides"
android:layout_marginRight="#dimen/authentication_margin_from_sides"
android:gravity="center"
android:text="#string/window_enter_identifier_phone_description_label"
android:textAlignment="center"
android:textSize="16sp" />
<LinearLayout
android:id="#+id/phoneInputHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.custom.authentication.views.IdentifierInputView
android:id="#+id/authenticationInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/authentication_margin_from_sides"
android:layout_marginRight="#dimen/authentication_margin_from_sides" />
</LinearLayout>
</LinearLayout>
<com.custom.authentication.views.BottomButtonsView
android:id="#+id/bottomButtons"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:linkText="#string/window_enter_identifier_login_with_email_button"
app:mainText="#string/Continue" />
</android.support.constraint.ConstraintLayout>
I am inflating this layout in my custom view class like this:
class EnterIdentifierView(context: Context) : ConstraintLayout(context) {
init {
inflate(context, R.layout.view_enter_identifier, this)
}
And creating my custom view like this:
override fun onCreateControllerView(layoutInflater: LayoutInflater, viewParent: ViewGroup) = EnterIdentifierView(layoutInflater.context)
I don't think this is an answer, more of a suggestion, but as I don't have enough reputation have to post it as such.
From my experience when I get this type of error it sometimes indicates an OutOfMemory error, check to make sure your custom classes aren't trying to load any large images etc.
Also check the full Stacktrace carefully, if you have access to one, for any OOMs
I am trying to create a page in android app. It is working fine in all the mobiles except in the mobile which is having Android 8.0. Here is the XML file code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg3_logo"
>
<TextView
android:id="#+id/text1d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:enabled="true"
android:maxLength="50"
android:text="Welcome Customer xxxxxx"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/text2d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="true"
android:maxLength="50"
android:text="" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/imageButton1"
android:gravity="center"
android:singleLine="false"
android:text=""
android:textSize="12dp" />
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text2"
android:enabled="true"
android:maxLength="50"
android:text=""
android:textSize="12dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/imageButton12"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_below="#+id/textView3"
android:layout_marginRight="14dp"
android:background="#drawable/rotate6"
android:contentDescription="From Date" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="-10dp"
android:layout_gravity="right">
<ImageButton
android:id="#+id/imageButtondl"
android:layout_width="50dip"
android:layout_height="50dip"
android:background="#drawable/logout"
android:contentDescription="Logout" />
</LinearLayout>
<ListView
android:id="#+id/mylist"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
/>
<Button
android:id="#+id/btn_static"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EDIT"/>
</LinearLayout>
I was not able to get the log cat as my emulator was not in a working mode due to restriction of proxy server in our domain. Please help me out guys
Finally able to get the Stack trace by sending it to mail
java.lang.RuntimeException: Unable to start activity ComponentInfo{kvbank.kvb_ebook/kvbank.kvb_epassbook.dummy}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2744)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:136)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:348)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:769)
at android.widget.TabHost.setCurrentTab(TabHost.java:423)
at android.widget.TabHost.addTab(TabHost.java:233)
at kvbank.kvb_epassbook.TabDemo.onCreate(TabDemo.java:87)
at android.app.Activity.performCreate(Activity.java:6998)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1230)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #8: 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 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.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:432)
at android.app.Activity.setContentView(Activity.java:2677)
at kvbank.kvb_epassbook.dummy.onCreate(dummy.java:190)
at android.app.Activity.performCreate(Activity.java:6998)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1230)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:2744)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:136)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:348)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:769)
at android.widget.TabHost.setCurrentTab(TabHost.java:423)
at android.widget.TabHost.addTab(TabHost.java:233)
at kvbank.kvb_epassbook.TabDemo.onCreate(TabDemo.java:87)
at android.app.Activity.performCreate(Activity.java:6998)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1230)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x2/d=0x101009b a=1}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:538)
at android.widget.TextView.<init>(TextView.java:910)
at android.widget.TextView.<init>(TextView.java:824)
at android.widget.TextView.<init>(TextView.java:820)
... 37 more
SOLUTION
Issue got solved. I am using "android:theme="#android:style/Theme.Holo""
for my dummy class in android manifest which is not defined. removing
this line solved my issue
As you said, you are not able to get Log file. I'm not pretty much sure on the reason behind this. You may try this.
1. Unexpected text /> in your xml below the Listview myList. Remove that part
Even you can see warning in your XML with Unexpected text found in file: "/>" Always Check your XML warning for any InflateClassException
Layout Resource file should only content elements and attributes.Any
XML text content found in file is likely accidental.
(From the warning message that represents the chance of crash.)
2. Remove Numbers form Id as ids are typically assigned in the layout XML file as a string.