I am trying to implement SwipeRefreshLayout in fragments. It is looking created correctly, but I continue to get the errors:
Caused by: android.view.InflateException: Binary XML file line #2:
Binary XML file line #2: Error inflating class
android.support.v4.widget.SwipeRefreshLayout
Caused by: android.view.InflateException: Binary XML file line #2:
Error inflating class android.support.v4.widget.SwipeRefreshLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class
"android.support.v4.widget.SwipeRefreshLayout" on path:
DexPathList[[zip file "/data/app/com.weather.rainy-
2/base.apk"],nativeLibraryDirectories=[/data/app/com.weather.rainy-
2/lib/x86, /system/lib, /vendor/lib]]
I really don't have any idea what is causing this.
My fragment layout for implementing the SwipeRefreshLayout:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/swipeToRefresh4Maps"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/topRL4Maps"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg_gradient_purple"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingTop="64dp"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingBottom="64dp"
tools:context="com.weather.rainy.ui.MapsActivity">
<TextView
android:id="#+id/yourLocationLabelTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="#+string/your_location"
android:textColor="#android:color/white"
android:textSize="24sp" />
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/addressValueTextView"
android:layout_alignBottom="#+id/addressValueTextView"
android:layout_below="#+id/yourLocationLabelTextView"
android:layout_centerHorizontal="true"
android:layout_margin="15dp"
tools:context="com.weather.rainy.ui.MapsActivity" />
<TextView
android:id="#+id/addressValueTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/map"
android:layout_alignEnd="#+id/map"
android:layout_alignParentStart="false"
android:layout_alignParentBottom="true"
android:text="#+string/..."
android:textColor="#aaffffff"
android:textSize="18sp" />
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
And, my fragment class for calling the SwipeRefreshLayout:
//Code for Swipe Refresh
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeToRefresh4Maps);
mSwipeRefreshLayout.setColorSchemeResources(R.color.Red, R.color.Orange, R.color.Blue, R.color.Green);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
#Override
public void onRefresh() {
Log.v(TAG, "************** MAPS - SWIPE REFRESH EVENT TRIGGERED!!!!!");
findLocation();
}
});
I really don't have any clue, what is the wrong. Any help is greatly appreciated.
Because you are using AndroidX, your XML is referencing the wrong version of SwipeRefreshLayout
Change in your XML from android.support.v4.widget.SwipeRefreshLayout to androidx.swiperefreshlayout.widget.SwipeRefreshLayout
I was stuck on the SwipeRefreshLayout using AndroidX
I was not able to get Reference of SwipeRefreshLayout in AndroidX
So I added implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
dependency in app level gradle file.
So in my case solution is,
Add the dependency in app level build.gradle file
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
This issue seems to happen when migrating to AndroidX as there are many build artifact to be changed when Migrating to AndroidX.
Solution 1: Do it manually
For exemple:
android.support.v4.widget.SwipeRefreshLayout changed to => androidx.swiperefreshlayout.widget.SwipeRefreshLayout
You must update all the build artifact listed in Migrating to AndroidX
Solution 2: Automate on Android Studio 3.2+
As suggested in this same link, you could automate this process by selecting Refactor > Migrate to AndroidX from the menu bar.
ADDITIONAL INFO - The errors I had:
Error inflating class android.support.constraint.ConstraintLayout
element WebView is not allowed here
Gradle needs to new dependency which is AndroidX:
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
If you use SwipeRefreshLayout in Java class, you can see this line:
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
In you XML file, you should use the tags of SwipeRefreshLayout:
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Related
I am trying to test a fragment, following these instructions: https://developer.android.com/training/basics/fragments/testing
However I am getting the following crash when calling launchFragmentInContainer from my test.
Stacktrace:
android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
at android.view.LayoutInflater.$$robo$$android_view_LayoutInflater$createView(LayoutInflater.java:647)
...
at com.myapp.poll.PollHomeFragment.onCreateView(PollHomeFragment.kt:31)
...
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f0301b1 a=-1}
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:946)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.view.View.__constructor__(View.java:5010)
at android.view.View.<init>(View.java)
at android.widget.TextView.<init>(TextView.java)
...
at com.myapp.poll.PollHomeFragment.onCreateView(PollHomeFragment.kt:31)
Here's the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:gravity="center"
android:orientation="vertical"
tools:context=".poll.PollActivity">
<TextView
android:id="#+id/tvEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="asdf#asdf.com" />
<TextView <!-- This is line 16 -->
android:id="#+id/tvViewPoll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:minHeight="48dp"
android:text="View Poll" />
<TextView
android:id="#+id/tvCreatePoll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:minHeight="48dp"
android:text="Create Poll" />
OK, from an educated guess based on the stacktrace, I tried removing android:background="?attr/selectableItemBackground" and this resolves the issue.
It appears that ?attr/selectableItemBackground is perhaps not compatible with FragmentScenario or this is a framework bug.
I submitted a bug on the issue tracker: https://issuetracker.google.com/issues/144629519
Update from Google:
Status: Won't Fix (Intended Behavior) The default theme does not have
an app defined attribute ?attr/selectableItemBackground (as Fragment
has no dependency on AppCompat, MDC, etc)
It sounds like you should be passing the correct theme to
FragmentScenario:
launchFragmentInContainer<PollHomeFragment>(themeResId = R.style.Theme_YourTheme)
In Java one also has to pass the theme to the FragmentScenario. Else the Fragment will not know about the current theme and will eventually complain that one should set an AppCompat theme ...
FragmentScenario<SomeFragment> scenario = FragmentScenario.launchInContainer(
SomeFragment.class,
Bundle.EMPTY,
R.style.Theme_Custom,
null
);
For me, using "android:?attr/selectableItemBackground" instead, solved the problem
I just migrated my project to androidx and i am getting an inflation error for inflating viewpager component...I replaced android.support.v4.view.ViewPager with androidx.viewpager.widget.ViewPager
This my xml file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:padding="#dimen/_1dp"
android:layout_height="wrap_content"
android:background="#color/banner_border_color">
<androidx.viewpager.widget.ViewPager
android:id="#+id/vp_slider"
android:layout_width="match_parent"
android:layout_height="#dimen/_140dp"
android:background="#drawable/thumb_new_background" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<TextView
android:id="#+id/tv_banner_view_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/_16dp"
android:background="#drawable/drawable_btn_curved"
android:paddingBottom="#dimen/_6dp"
android:paddingLeft="#dimen/_8dp"
android:paddingRight="#dimen/_8dp"
android:paddingTop="#dimen/_6dp"
android:visibility="gone"
android:text="#string/text_view_more"
android:textColor="#color/c_white"
android:textSize="#dimen/_8sp" />
</RelativeLayout>
</FrameLayout>
The Error i'm getting :
Caused by: android.view.InflateException: Binary XML file line #329: Binary XML file line #8: Error inflating class androidx.core.view.ViewPager
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class androidx.core.view.ViewPager
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.view.ViewPager" on path: DexPathList[
I figure out problem,
When we merger to androidx then android studio convert viewpager, swipe to refresh layout and some other views to androidx.core for example viewpager its looks like androidx.core.view.ViewPager but correct is androidx.viewpager.widget.ViewPager please check in your xml layouts and see there is right component is added or not if there is androidx.core then check for right one and replace it.
And also import dependency
implementation 'com.google.android.material:material:1.1.0-alpha08
You need to below dependencies in your build.gradle file
implementation 'com.google.android.material:material:1.1.0
You need to add below dependencies in your build.gradle file
implementation 'com.google.android.material:material:1.4.0
I think you need to Invalidate caches and restart
Go to File > Invalidate caches/Restart > ** Invalidate
Then rebuild project
I've searched for an answer to my problem, as shown in the title of this question, and found Error inflating class androidx.constraintlayout.ConstraintLayout after migration to androidx, which aligns with the official migration instructions presented in Migrating to AndroidX. I took the information as requiring me to change android.support.constraint.ConstraintLayoutto androidx.constraintlayout.widget.ConstraintLayout, but this doesn't work for me.
I haven't found anything about what dependency to put in my gradle file, so I tried this (this is a shot in the dark):
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
which is accepted but when I tried:
implementation 'androidx.constraintlayout.widget:constraintlayout:1.1.3'
I get ERROR: Failed to resolve: androidx.constraintlayout.widget:constraintlayout:1.1.3, so I used the previous implementation directive.
Here is my XML file:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.jbiss.petminder.activities.MainActivity">
<!--<android.support.v7.widget.Toolbar-->
<androidx.appcompat.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#color/colorPrimaryDark"
android:elevation="4dp"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="#style/AppTheme.PopupOverlay"/>
<TextView
android:id="#+id/tvMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:accessibilityLiveRegion="assertive"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/my_toolbar"
tools:text="error message goes here"/>
<TextView
android:id="#+id/tvEmVet"
android:layout_width="wrap_content"
android:layout_height="44dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:text="#string/emergency_vet"
android:textColor="#android:color/holo_red_dark"
android:textSize="24sp"
app:layout_constraintStart_toEndOf="#+id/phoneCallEmVet"
app:layout_constraintTop_toBottomOf="#+id/recyclerview1"
tools:textSize="24sp"/>
<ImageView
android:id="#+id/phoneCallEmVet"
android:layout_width="37dp"
android:layout_height="44dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="8dp"
android:onClick="callEmVet"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/recyclerview1"
app:srcCompat="#android:drawable/sym_action_call"/>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerview1"
android:layout_width="368dp"
android:layout_height="365dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="#string/pet_name"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/my_toolbar"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Running my app produces the following error:
2019-02-18 19:43:36.031 458-458/com.example.jbiss.petminder E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jbiss.petminder, PID: 458
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.ConstraintLayout" on path: DexPathList[[zip file "/data/app/com.example.jbiss.petminder-i-ubC_oLu_y7-aFpiqALqg==/base.apk", zip file "/data/app/com.example.jbiss
Following the information doesn't work, for some reason. The migration has been tough but I've cleaned up a lot of issues and am now unable to find a reason why this is happening when it appears that I have done what is intended.
I solved my problem. I found that Androidx migration is a bit more involved than I had at first thought. Knowing that I had updated the labels of the ConstraintLayout elements in the XML files used in the initial screen, I used Windows GREP to search for "android.support.constraint.ConstraintLayout" throughout my project. Lo and behold I found instances that I had missed and so I updated the XML file reference to "androidx.constraintlayout.widget.ConstraintLayout".
This allowed my project to be successfully built and launch on the emulator. However, after trying to access another screen I got the same error as shown in my initial post, but for the AppBarLayout. So, I must proceed for this one as I did for ConstraintLayout and then any others.
If you are migrating, be prepared for a little more work than you had anticipated!
I was facing the same problem after migrating to androidX. Tried above solution. But, it didn't work. I added mavenCentral() in project level app gradle.
repositories {
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
with following changes
dependencies {
implementation 'com.google.android.material:material:1.0.0'
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
updated "android.support.constraint.ConstraintLayout" xml tag with "androidx.constraintlayout.widget.ConstraintLayout"
finally it worked.
If you experience this issue on Android Studio 3.6.3 after using the Migrate to Androidx tool like I did, Here is what worked for me:
I was using androidx.constraintlayout.ConstraintLayout in my layout XML file instead of androidx.constraintlayout.widget.ConstraintLayout
The difference is one has widget before ConstraintLayout. The dependency in my app-level build.gradle was:
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
The latest at that time.
My app crashed because
Error inflating class android.support.design.widget.FloatingActionButton
This is my code in the XML
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="#drawable/icon_right"
app:backgroundTint="#color/green"
android:onClick="previewphoto"
app:layout_anchorGravity="bottom|right|end" />
and here is my gradle
compile 'com.android.support:appcompat-v7:23.4.0' // appcompat library
compile 'com.android.support:design:23.4.0'
my logcat
FATAL EXCEPTION: main Process: com.cyanlabsid.cetakphoto, PID: 15298
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.cyanlabsid.cetakphoto/com.cyanlabsid.cetakphoto.PhotoPicker}:
android.view.InflateException: Binary XML file line #76: Binary XML
file line #76: Error inflating class
android.support.design.widget.FloatingActionButton at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
at android.app.ActivityThread.access$900(ActivityThread.java:153) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:148) at
android.app.ActivityThread.main(ActivityThread.java:5441) at
java.lang.reflect.Method.invoke(Native Method) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628) Caused
by: android.view.InflateException: Binary XML file line #76: Binary
XML file line #76: Error inflating class
android.support.design.widget.FloatingActionButton at
android.view.LayoutInflater.inflate(LayoutInflater.java:543) at
android.view.LayoutInflater.inflate(LayoutInflater.java:427) at
android.view.LayoutInflater.inflate(LayoutInflater.java:374) at
android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at
android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.cyanlabsid.cetakphoto.PhotoPicker.onCreate(PhotoPicker.java:74)
at android.app.Activity.performCreate(Activity.java:6303) at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
at android.app.ActivityThread.access$900(ActivityThread.java:153) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:148) at
android.app.ActivityThread.main(ActivityThread.java:5441) at
java.lang.reflect.Method.invoke(Native Method) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
Can somebody tell my fault?
Use
app:backgroundTint
in stead of
android:backgroundTint
Hope it will work.
Because android:backgroundTint doesn't work below android API 21, so you need to use app:backgroundTint instead.
Tried your code, the problem is with the 23.4.0 library.
Upgrade to 24.+ , there's no error in that lib.
For example :
implementation 'com.android.support:appcompat-v7:24.2.1' // appcompat library
implementation 'com.android.support:design:24.2.1'
You need to change the compile version to 24 too.
compileSdkVersion 24
Below API level 21 app versions not support for the
app:backgroundTint="#color/green"
or you can use this library for achieve more material design widgets.
https://github.com/navasmdc/MaterialDesignLibrary
happy coding...
You need to add
android:theme="#style/Theme.AppCompat"
in the XML_Layout file in which you are using FloatingActionButton...
I had the same problem
I faced the same issue with Pre-Lolipop version and to resolve it, I just changed "android:src" to "app:srcCompat" & it worked for me.
To make compatibility with older version and if you're using a Vector graphics (as drawable assets) you should use:
app:srcCompat="#drawable/you_graphics"
instead of:
android:src="#drawable/your_graphics"
I am using:
classpath 'com.android.tools.build:gradle:3.3.2'
and
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.1-all.zip
I changed my XML to:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:focusable="true"
app:srcCompat="#drawable/mapit"
app:layout_anchor="#id/foundit_imageView"
app:layout_anchorGravity="bottom|right|end" />
and everything built and ran correctly.
I hope this helps
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:src="#drawable/ic_add_foreground"
android:layout_margin="16dp" />
Use this
<com.google.android.material.floatingactionbutton.FloatingActionButton>
instead of
<android.support.design.widget.FloatingActionButton>
Make sure the library from which you declared the FloatingActionButton in the activity is the same as the one used for the layout markup
For example have
import com.google.android.material.floatingactionbutton.FloatingActionButton; in the activity and
com.google.android.material.floatingactionbutton.FloatingActionButton as the tag for the layout
I was using Material Design for my ExtendedFloatingActionButton and when using API 24 it would crash the app.
I tried updating my gradle dependencies to the latest version:
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0-alpha02'
but I had no luck with that either. My solution was adding android:theme="" even though I had set a style it would still crash so I set the theme to the same as the style and it worked perfectly.
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="#+id/btn_one"
android:theme="#style/"
style="#style/"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/text"
android:text="#string/text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Add in
build.gradle(:app)
implementation 'com.google.android.material:material:1.2.0'
Use this in your XML
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="#drawable/icon_right"
app:backgroundTint="#color/green"
android:onClick="previewphoto"
app:layout_anchorGravity="bottom|right|end" />
use this code it will be work better ;
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="16dp"
app:backgroundTint="#f9fcfc"
android:src="#drawable/chat_float"
tools:targetApi="lollipop" />
This happened a couple of days ago. Still cannot find the way to fix it.
Here is a simple test project.
http://s000.tinyupload.com/index.php?file_id=03903482111052488979
Pretty simple layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<EditText
android:id="#+id/editUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ems="10"
android:hint="#string/input_hint_email"
android:inputType="textEmailAddress"
/>
<EditText
android:id="#+id/editPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/edit_hint_password"
android:inputType="textPassword"
android:layout_gravity="center"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Enter"
/>
</LinearLayout>
Gradle important parts:
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.1'
}
Ple-lollipop devices (genymotion and real devices)
The background (pressed, sometimes normal) looks like something wrong with 9-patch file. Some of affected views - item in navigation view, menu item, edittext
edittext - https://gyazo.com/71f13003a46ff596514e475a72f924b7
pressed menu item - https://gyazo.com/7a5d9db29e17524e353f10a18562786e
Lollipop until 5.1
Crashes on startup (stop crashing on appcompat 23.1.1 and lower)
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ww.aeli.wtf.MainActivity}: android.view.InflateException:
Binary XML file line #11: Error inflating class EditText
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class EditText at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v21/abc_edit_text_material.xml from drawable resource ID #0x7f020015 at android.content.res.Resources.loadDrawableForCookie(Resources.java:2428)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #24: <nine-patch> requires a valid 9-patch source image at android.graphics.drawable.NinePatchDrawable.updateStateFromTypedArray(NinePatchDrawable.java:445)
Lollipop 5.1 and marshmallow
Everything works fine
What have i tried
Problem also was reproduced on other developer machine.
Downgrading appcompat till the version 23.0.0. Lollipop do not crashes on 23.1.1 and lower, but background problem persists.
Disabling vector support (the main 23.2.0 feature, that theoretically could affect).
Similar recent problems - https://code.google.com/p/android/issues/detail?id=210467 (the discussion went on the strange way), https://github.com/afollestad/material-dialogs/issues/1081, https://code.google.com/p/android/issues/detail?id=210547
older one:
https://code.google.com/p/android/issues/detail?id=198457
Well, i find the way to "fix" all the issues as always just after posting a question.
Downgrading the gradle version from 2.2.0-alpha1 to 2.1.+ will solve all the problems.
And again note to myself - never use "+" in library versions.