com.android.support:design with androidX (1.0.2) - android

I want to use TextInputLayout inside my project, but I'm using androidX library
implementation "androidx.appcompat:appcompat:1.0.2"
/*this don't work*/
implementation "com.android.support:design:28.0.0"
This is the exception which I'm facing
android.view.InflateException: Binary XML file line #30: Binary XML file line #30: Error inflating class android.support.design.widget.TextInputLayout
Caused by: android.view.InflateException: Binary XML file line #30: Error inflating class android.support.design.widget.TextInputLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.TextInputLayout" on path: DexPathList[[zip file "/data/app/com.example

Error inflating class android.support.design.widget.TextInputLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class
This error thrown when the Java Virtual Machine (JVM) tries to load a particular class and the specified class cannot be found in the classpath.
You should use
com.google.android.material.textfield.TextInputLayout
DEMO
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
Then Clean-Rebuild-Run.

Related

NullPointerException:Attempt toread from field 'androidx.viewpager2.widget.FakeDrag androidx.viewpager2.widget.ViewPager2.mFakeDragger' on null object

We are seeing this crash on Firebase for few of our users during layout inflation:
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.abc.xyz/com.abc.xyz.onboarding.activity.OnboardingActivity}: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class <unknown>
Caused by java.lang.NullPointerException: Attempt to read from field 'androidx.viewpager2.widget.FakeDrag androidx.viewpager2.widget.ViewPager2.mFakeDragger' on a null object reference
at androidx.viewpager2.widget.ViewPager2.fakeDragBy(ViewPager2.java:735)
at androidx.viewpager2.widget.ViewPager2$PageAwareAccessibilityProvider.updatePageAccessibilityActions(ViewPager2.java:1494)
at androidx.viewpager2.widget.ViewPager2$PageAwareAccessibilityProvider.onSetOrientation(ViewPager2.java:1408)
at androidx.viewpager2.widget.ViewPager2.setOrientation(ViewPager2.java:569)
at androidx.viewpager2.widget.ViewPager2.setOrientation(ViewPager2.java:297)
at androidx.viewpager2.widget.ViewPager2.initialize(ViewPager2.java:190)
at androidx.viewpager2.widget.ViewPager2.<init>(ViewPager2.java:163)
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:652)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:800)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:740)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
We are not using FakeDrag ourself anywhere. Below is the XML code:
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/welcome_screen_vp2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-22dp"
app:layout_constraintTop_toBottomOf="#id/welcome_screen_hike_logo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
And in Kotlin file we are just attaching Viewpager2 to the TabLayout
TabLayoutMediator(mBinding.welcomeScreenVp2TabLayout, mPager) { tab, position ->
}.attach()
Any idea what could be the reason for this crash?

Error inflating class androidx.appcompat.widget.AppCompatSpinner

We are seeing a crash Error inflating class androidx.appcompat.widget.AppCompatSpinner on the play console,but we are not able to reproduce it.
Here is my xml :
<androidx.appcompat.widget.AppCompatSpinner
android:id="#+id/spinnerState"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/xMargin_42_156"
android:layout_marginEnd="#dimen/xMargin_42_156"
android:background="#drawable/spinner_down_arrow"
android:focusableInTouchMode="true"
android:overlapAnchor="false"/>
In build.gradle
implementation 'androidx.appcompat:appcompat:1.2.0'
Logs:
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{com.wrap/com.wrap.activities.NewIntroActivity}: android.view.InflateException: Binary XML file line #129 in com.wrap:layout/activity_new_intro: Binary XML file line #129 in com.wrap:layout/activity_new_intro: Error inflating class androidx.appcompat.widget.AppCompatSpinner

FragmentContainerView with SupportMapFragment crashes when minify is enabled

I have the following layout:
<androidx.fragment.app.FragmentContainerView 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:id="#+id/map"
tools:context=".map.MapActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
It works fine with my debug build, but my release build with minify enabled crashes.
09-04 15:14:06.727 15555 15555 E AndroidRuntime: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class androidx.fragment.app.FragmentContainerView
09-04 15:14:06.727 15555 15555 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class androidx.fragment.app.FragmentContainerView
09-04 15:14:06.727 15555 15555 E AndroidRuntime: Caused by: androidx.fragment.app.Fragment$c: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists
Any suggestions on how to fix it? If I replace the FragmentContainerView with the old fragment view, it works.
The problem might be related to minification. If you have minify enabled, you probably have to add something similar to this to your proguard:
-keep class com.google.android.gms.maps.** { *; }
This is caused by a bug in aapt2, and is being tracked in a bug by google here: https://issuetracker.google.com/issues/142601969
In the meantime, the easiest way to fix this is to add #Keep to any fragments that you use in this manner.
If it's a fragment from a library where you are unable to modify the code, you can add it as a rule in your proguard.cfg:
-keep class om.google.android.gms.maps.** { *; }

java.lang.ClassNotFoundException: Didn't find class "androidx.core.view.ViewPager" on path

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

Generating signed apk getting error on inflating BottomNavigationView after switching to androidX

App crashes with error error inflating class com.google.android.material.bottomnavigation.BottomNavigationView when generating signed apk. Running the app with debug apk from android studio directly to device has no problem. I have migrated my project to androidX as well.
I've read some other post saying the drawable or colors might have problem so I've confirm that there are no other drawable folders (e.g. drawable-v21, drawable-v24). Im not sure why but it only happens when I generate a signed apk.
app:itemIconTint="#drawable/drawable_selector"
app:itemTextColor="#drawable/drawable_selector"
app:itemBackground="#color/primary"
but it doesn't work
line 15 error starts here:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="#menu/bottom_navigation"
android:elevation="8dp"
app:itemIconTint="#drawable/drawable_selector"
app:itemTextColor="#drawable/drawable_selector"
app:itemBackground="#color/primary"
android:background="?android:attr/windowBackground"/>
have already included this in my gradle:
implementation 'com.google.android.material:material:1.1.0-alpha06'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
Caused by: android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
Caused by: java.lang.reflect.InvocationTargetException

Categories

Resources