Android studio drops
"android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout"
error when i run my app on Android Marshmallow or below. It perfectly works on nougat and oreo
I added "implementation 'com.android.support.constraint:constraint-layout:1.1.0'" as i saw it in other answers but it still not works
xml:
<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/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/soros3"
android:padding="0dp"
tools:co0-ntext=".MainActivity">
please help
ok
So I removed the background of the layout and removed the
tools:co0-ntext=".MainActivity"
line and it works.
I don't really know why but it works
Related
I have WebView on my application and I got many same errors on android 7.0 from users while inflating WebView fragment.
Error log:
android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class android.webkit.WebView
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class android.webkit.WebView
WebView fragment layout:
<android.support.v7.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background">
<WebView
android:id="#+id/wvAparat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="16dp" />
</android.support.v7.widget.LinearLayoutCompat>
I got this error from these devices:
SM-G950F Android 7.0
SM-J330F Android 7.0
Moto E (4) Plus Android 7.1.1
It's definitely device related. here is a link for more information:
https://www.androidpolice.com/2016/07/20/google-explains-chrome-will-become-webview-android-7-0/
My hunch would be, if you find one of these devices, to check if they have Chrome installed. If not, that's your answer. No idea for a workaround.
I use https://github.com/mattprecious/swirl/blob/master/README.md in my app.
I don't want appear SwirlView on lowwer sdk marshmallow version. because SwirlView working on version sdk marshmallow or higher version.
so I add "tools:targetApi='M'" to SwirlView xml node. look at the code below.
<com.mattprecious.swirl.SwirlView
android:id="#+id/fingerprint_SwirlView"
android:layout_width="100dp"
android:layout_height="100dp"
tools:targetApi="M"/>
but when I run app on lolipop version. occure error like this.
android.view.InflateException: Binary XML file line #29: Error inflating class com.mattprecious.swirl.SwirlView
what is problem with my code.
sorry for my poor english skill.
You gotta override the xml instead of suppressing the error. Tools don't affect the app, only Android Studio.
I am creating an app in VS 2015 using Xamarin and when running it I get this error
Android.Views.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
This is my XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/food" />
I have the Food.jpg in the drawable folder as it shows up in VS when I select design.
Thanks
I am able to test my android app on my mobile 5.0 perfectly fine, but testing it on anything lower than 5.0 throws an exception.
"Binary XML file line #16: Error inflating class android.support.design.widget.NavigationView"
My line 16 is basically this
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/main_app_bar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
I did see other posts about this error, but none of it seems to fix my issue.
This is the full callstack of the error
http://pastebin.com/raw/FaJQFCie
I found it. The error comes from navigation's menu. When I created new project with navigation drawer, Android Studio generates complete work for me. There's a drawable folder named drawable-v21 which stores the icon xml files
I had had the same problem some time ago.
1) Look at your gradle dependencies: you should add library -
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
2) Look at your based colors: you should have
colorPrimary
colorPrimaryDark
colorAccent
3) Look at your layout.nav_header_main. If you will have in the end of error log some message like "Caused by: java.lang.OutOfMemoryError: Failed to" - background image of nav_header_main has a very big resolution or kb weight. Change it and will have success ;)
I'm trying to use TextInputLayout in my XML, and I'm meeting this error :
java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.jechange.moncompte/fr.jechange.moncompte.SignUpActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/design/R$styleable;
I've imported the design library, and the support-v7-appcompat library. And I'm using the Theme.AppCompat.Light.NoActionBar theme.
The XML in which I'm using the Text Input Layout contains just something like that:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:res="http://schemas.android.com/apk/res-auto"
style="#style/matchParent">
<android.support.design.widget.TextInputLayout
android:id="#+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
if you are calling layout(containg TextInputLayout) from activity then
nothing just use YouActivityClassName.this in place of getApplicationcontext or YourApplicationClassName.getcontext() or other where you are passing context
I had the same issue fixed here.
Make sure you don't have any other support library import v4 and v7. You can use only the design-support library. Also you should make sure your theme "matchParent" inherit from Theme.AppCompat for all the platform you trying to run.
My issue was only on Lollipop because of the values-21/style.xml.
Hope it will help.