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 ;)
Related
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
I'm trying to transition my app to the action bar. I'm following Google's tutorial. Unfortunately, when trying to build the app, AAPT returns the following error:
menu.xml:6: AAPT: Error parsing XML: unbound prefix
I did some research and found out that this error usually happens when the line xmlns:android="http://schemas.android.com/apk/res/android" isn't included in the XML because then AAPT doesn't know how to interpret the android.xxx tag. However, as you can see from my code, I've included this line in the first node:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
</LinearLayout>
So why doesn't this compile?
You have not declared the app namespace via xmlns:app, but you use it in app:popupTheme. IIRC, there is a quick-fix for that in Android Studio. If not, add xmlns:app="http://schemas.android.com/apk/res-auto" to your root element.
I have an android project which was developed according to API 25 and was running fine. But, now i wanted to change some code in it and i have also updated my Android Studio to 3.0 since(may be that's the problem). Following are the errors i receive :
C:\Users\nutty geek\Desktop\Ankur\app\build\intermediates\res\merged\debug\layout\activity_main.xml:17: error: No resource identifier found for attribute 'headerLayout' in package 'com.nuttygeek.vastucosmos.vastucompass'
C:\Users\nutty geek\Desktop\Ankur\app\build\intermediates\res\merged\debug\layout\activity_main.xml:17: error: No resource identifier found for attribute 'menu' in package 'com.nuttygeek.vastucosmos.vastucompass'
C:\Users\nutty geek\Desktop\Ankur\app\build\intermediates\res\merged\debug\layout\content_main.xml:2: error: No resource identifier found for attribute 'layout_behavior' in package 'com.nuttygeek.vastucosmos.vastucompass'
C:\Users\nutty geek\Desktop\Ankur\app\build\intermediates\res\merged\debug\layout\content_main.xml:2: error: Error: No resource found that matches the given name (at 'layout_behavior' with value '#string/appbar_scrolling_view_behavior').
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
i also have added this line to gradle.properties :
android.enableAapt2=false
for disabing AAPT2 but it still give some errors.
Questions:
1. Why has this problem occured ?
2. How can i resolve this issue ?
here is the activity_main.xml of the project...
<?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/app_bar_main"
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>
Seems like i was your using some features which demanded the need of this dependency.
compile 'com.android.support:design:26.1.0'
i added it and the problem is finally solved !
I have the following layout in Android Studio 2.1
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.kea.trimetrail.MainActivityFragment"
tools:showIn="#layout/activity_main">
<com.mapbox.mapboxsdk.maps.MapView
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:accessToken="#string/mapbox_access_token"/>
</RelativeLayout>
It displays the following error:
No resource identifier found for attribute 'accessToken' in package 'com.example.myapp'
In this case, the error is generated building a simple Mapbox application. I'm developing mapbox from source (yes, I need the source build, not the pre-built).
See:
https://github.com/mapbox/mapbox-gl-native/blob/master/INSTALL.md
The source tree is for multiple platforms, I'm using:
https://github.com/mapbox/mapbox-gl-native/tree/master/platform/android
The source build is located as a dependent library located at:
myapp/app/libs/mapbox-gl-native/platform/android
I've tried importing the module and more using other similar posts, but nothing helps.
While a solution to my particular issue would be awesome, simply understanding the cause of the message might help too. Everything I read is about specific solutions to similar messages, but I can't find any information about the message itself.
Thx
Not sure, but looks like they changed the name from accessToken to access_token. I can't tell for sure because this just brings up a new error. I'll assume the new error is something beyond the old error and not instead of.
I'm trying to use Fragments and ActionBar in a Android 2.2 project. There is some error when using "?android:attr/actionBarSize", how to get and set that value correctly?
Example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/frags">
<fragment class="com.example.android.hcgallery.TitlesFragment"
android:id="#+id/frag_title"
android:visibility="gone"
android:layout_marginTop="?android:attr/actionBarSize"
android:layout_width="#dimen/titles_size"
android:layout_height="match_parent" />
<fragment class="com.example.android.hcgallery.ContentFragment"
android:id="#+id/frag_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Error: No resource found that matches the given name (at 'layout_marginTop' with value '?android:attr/actionBarSize').
You should just use:
android:layout_marginTop="?attr/actionBarSize"
See http://developer.android.com/training/basics/actionbar/overlaying.html
"...The one with the android: prefix is for versions of Android that
include the style in the platform and the one without the prefix is
for older versions that read the style from the Support Library..."
For me replacing
android:layout_marginTop="?android:attr/actionBarSize"
with
android:layout_marginTop="?attr/actionBarSize"
helped to launch app on Android 2.2 and Android 4.3 without any issues.
I think the problem is that actionbar comes with android 3.0 and you are using 2.2. But there is a way to skip this by a extension called "actionbarsherlock".