Android Application crash on Android 13 - android

Getting weird crash in Samsung android 13 devices, but this is working fine in other devices. Recently we are getting one crash in firebase crash analytics, below is the crash report . Application is targeting api level 33 and so far crash reported only in samsung android 13 devices.
edit_texts.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/login_input1_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/input_field_text_color"
android:theme="#style/login_floating_text_style">
<com.mobileaware.unified.ui.controls.common.MaEditText
android:id="#+id/login_input1"
style="#style/input_field_validation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:visibility="gone" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/login_input2_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/input_field_text_color"
android:theme="#style/login_floating_text_style">
<com.mobileaware.unified.ui.controls.common.MaEditText
android:id="#+id/login_input2"
style="#style/input_field_validation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:visibility="gone" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/login_input3_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/input_field_text_color"
android:theme="#style/login_floating_text_style">
<com.mobileaware.unified.ui.controls.common.MaEditText
android:id="#+id/login_input3"
style="#style/input_field_validation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:visibility="gone" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
Stack Trace :
Fatal Exception: android.view.InflateException
Binary XML file line #21 `com.xyz.abc:layout/edit_texts: Attempt to invoke virtual method 'int android.graphics.Typeface.getWeight()' on a null object reference
Caused by java.lang.NullPointerException
Attempt to invoke virtual method 'int android.graphics.Typeface.getWeight()' on a null object reference
keyboard_arrow_up
com.google.android.material.resources.TypefaceUtils.maybeCopyWithFontWeightAdjustment (TypefaceUtils.java:57)
com.google.android.material.internal.CollapsingTextHelper.setCollapsedTypefaceInternal (CollapsingTextHelper.java:480)
com.google.android.material.internal.CollapsingTextHelper.setTypefaces (CollapsingTextHelper.java:463)
com.google.android.material.textfield.TextInputLayout.setEditText (TextInputLayout.java:1426)
com.google.android.material.textfield.TextInputLayout.addView (TextInputLayout.java:836)
android.view.ViewGroup.addView (ViewGroup.java:5268)
android.view.LayoutInflater.rInflate (LayoutInflater.java:1149)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:1106)
android.view.LayoutInflater.rInflate (LayoutInflater.java:1148)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:1106)
android.view.LayoutInflater.inflate (LayoutInflater.java:692)
android.view.LayoutInflater.inflate (LayoutInflater.java:544)
arrow_right
com.mobileaware.unified.ui.fragments.NativeLoginFragment.showTabs (NativeLoginFragment.java:364)
com.mobileaware.unified.ui.presenters.NativeLoginFragmentPresenter.bind (NativeLoginFragmentPresenter.java:92)
com.mobileaware.unified.ui.presenters.NativeLoginFragmentPresenter.loadData (NativeLoginFragmentPresenter.java:114)
com.mobileaware.unified.ui.presenters.BasePresenter.loadData (BasePresenter.java:484)
com.mobileaware.unified.ui.fragments.NativeLoginFragment.injectPresenter (NativeLoginFragment.java:673)
com.mobileaware.unified.ui.fragments.BaseFragment.onResume (BaseFragment.java:214)
com.mobileaware.unified.ui.fragments.NativeLoginFragment.onResume (NativeLoginFragment.java:1244)
androidx.fragment.app.Fragment.performResume (Fragment.java:3071)
androidx.fragment.app.FragmentStateManager.resume (FragmentStateManager.java:605)
androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:285)
androidx.fragment.app.SpecialEffectsController$FragmentStateManagerOperation.complete (SpecialEffectsController.java:771)

There's probably an issue in implementation of TextInputLayout, as it can call: (TextInputLayout.java:1426)
collapsingTextHelper.setTypefaces(this.editText.getTypeface());
with null typeface.
It happened when turning on the Bold text in Android 13:
Settings -> Display size & text -> Bold text
In my case the issue was in the style of com.google.android.material.textfield.TextInputEditText.
So try to remove and fix the style of MaEditText in your case.

Related

How to make ConstraintLayout (androidx.constraintlayout.widget) work with MaterialButton (com.google.android.material.button)?

Problem statement
I am using com.google.android.material.button.MaterialButton inside androidx.constraintlayout.widget.ConstraintLayout where the constraint layout cannot deploy or detect the constraints of the material button.
Code
<?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=".views.screens.VeritasFolderReadSelectionScreen">
<androidx.appcompat.widget.Toolbar
android:id="#+id/folderSelectToolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/startGrad"
android:minHeight="?attr/actionBarSize"
android:theme="#style/AppBarOverlay"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/folderSelectMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="Select folders you want PeerPots to read"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/folderSelectToolbar"/>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/folderRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:layout_constraintTop_toBottomOf="#id/folderSelectMessage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<!-- Following code not working -->
<com.google.android.material.button.MaterialButton
android:id="#+id/folderViewButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Done"
android:textSize="12sp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
ScreenShot
Material button not visible
UPDATED
The error thrown while rendering
java.lang.IllegalArgumentException:
java.lang.ClassCastException#207d8929 at
sun.reflect.GeneratedMethodAccessor226.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108)
at
android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:143)
at
android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java)
at
android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
at
android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)
at
android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)
at
android.animation.ValueAnimator.animateBasedOnTime(ValueAnimator.java:1339)
at
android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1471)
at
android.animation.ValueAnimator.pulseAnimationFrame(ValueAnimator.java:1490)
at android.animation.AnimatorSet.pulseFrame(AnimatorSet.java:1163)
at
android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1146)
at
android.animation.AnimatorSet.doAnimationFrame(AnimatorSet.java:1046)
at
android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at
android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at
android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:947)
at android.view.Choreographer.doCallbacks(Choreographer.java:761) at
android.view.Choreographer_Delegate.doFrame(Choreographer_Delegate.java:66)
at
com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:563)
at
com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:425)
at
com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:120)
at
com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:151)
at
com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:133)
at
com.android.tools.idea.rendering.RenderTask.lambda$null$8(RenderTask.java:755)
at
java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I have verified everything looks good and its working as well. As you can see in the attached image it's your above-mentioned code.
Please make sure you added the dependency into your gradle file. If yes, then there may be some issue in some more properly working code here which is overlap on the button. So you need to check in that code.
implementation 'com.google.android.material:material:1.0.0'
After testing the code in other computers the reasons of the error found are-
System support lack - The system used for coding was not able to provide enough resources to render the views efficiently and for which the preview does not work.
Android Studio efficiency - On low capacity systems Android Studio cannot manage dependencies well while rendering and thus throws the error java.lang.IllegalArgumentException: java.lang.ClassCastException
Solution
Optimal solution - Use the recommended system configuration as per documentation.
Ostrich solution - Run the app every-time a change is made on the UI to see how it really works without depending on the Preview

How to fix 'Error inflating class EditText' in Android XML Layout

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.

getView() crashes in getDrawable()

I get many weird reports of app crashes (using app compat library) when OS calls the getView() of one of my adapter. It crashes in getDrawable() with ResourceNotFoundException under Android 4.x or RuntimeException under Android 5.x or UnsupportedOperationException under Android 6.x. The getView() is actually calling inflate() with a mostly simple layout file.
The call stack is always like this:
at android.content.res.TypedArray.getDrawable (TypedArray.java)
at android.view.View.<init> (View.java:3756)
at android.view.ViewGroup.<init> (ViewGroup.java)
at android.widget.LinearLayout.<init> (LinearLayout.java)
at android.widget.LinearLayout.<init> (LinearLayout.java)
at android.widget.LinearLayout.<init> (LinearLayout.java)
at java.lang.reflect.Constructor.newInstance (Constructor.java)
at java.lang.reflect.Constructor.newInstance (Constructor.java)
at android.view.LayoutInflater.createView (LayoutInflater.java)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java)
at android.view.LayoutInflater.onCreateView (LayoutInflater.java)
at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java)
at android.view.LayoutInflater.inflate (LayoutInflater.java)
at android.view.LayoutInflater.inflate (LayoutInflater.java)
at android.view.LayoutInflater.inflate (LayoutInflater.java)
at my_app.activity$adapter.getView
Here is the layout files that 'cause' this on Android 4.x and 5.x:
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<TextView
android:id="#+id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>
<ImageButton
android:id="#+id/menu"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#00000000"
android:src="#drawable/ic_menu_moreoverflow_normal_holo_dark"/>
The only drawable used in that layout is available in hdpi, mdpi and xhdpi. How come Android cannot find it? By the way, I can't reproduce this in emulator or an actual device running 4.x or 5.x!
Any suggestions will be appreciated, Those are my top 4 app crashes representing more than 90% of those!
I used to have background set to #null and changed it to #00000000 to no avail. Also included the drawable in theme's attributes and having src="?menu_overflow" but it didn't change anything.
Try
app:srcCompat="#drawable/ic_menu_moreoverflow_normal_holo_dark"
instead of
android:src="#drawable/ic_menu_moreoverflow_normal_holo_dark" // in your image button
Update
Dont forget to use android's android.support.v7.widget.AppCompatImageButton instead of ImageButton (this wont crash ).
<android.support.v7.widget.AppCompatImageButton
android:id="#+id/menu"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#00000000"
app:srcCompat="#drawable/ic_menu_moreoverflow_normal_holo_dark"/>

Unable to reproduce Error inflating class TextView

I'm getting next error from crashlytics: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class TextView
Problem is that I'm not able to reproduce this issue and I can only guess why app has crashed while trying to inflate TextView.
This TextView is in drawer_item_1.xml file which is menu item for application drawer.
This issue is reported only on devices running Android version 7.1.1 and 7.1.2 (Nexus 6P, Nexus 5x, Pixel XL and Sony Xperia X)
As I can see there is nothing suspicious here, it is simple TextView with some white text set to be bold, except layout_width is set to wrap_content and should be 0dp because of set layout_weight. Is it possible that this is causing this crashes?
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:src="#drawable/ic_add"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="My String"
android:textColor="#color/white"
android:textStyle="bold"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/rbn_menu_arrow"
/>

void android.view.View.setBackgroundTintList(android.content.res.ColorStateList) Error in TextInputLayout

<android.support.design.widget.TextInputLayout
android:id="#+id/txtInputLayDateOfBirth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginBottom="10dp">
<TextView
android:id="#+id/txtDateOfBirth"
style="#style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="6dp"
android:background="#drawable/drop_down"
android:clickable="true"
android:drawableRight="#drawable/ic_calendar"
android:gravity="left|center_vertical"
android:paddingLeft="5dp"
android:paddingRight="20dp"
android:hint="#string/dob"
android:textColorHint="#color/colorGray"
android:textColor="#color/colorWhite"/>
</android.support.design.widget.TextInputLayout>
When I following statement it gives error
mDateOfBirthTextInputLayout.setError(error.getCollatedErrorMessage(mContext));
It was working fine in Android 4.4 but gives error in Android 5.1
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sample, PID: 1824
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setBackgroundTintList(android.content.res.ColorStateList)' on a null object reference
at android.support.v4.view.ViewCompatLollipop.setBackgroundTintList(ViewCompatLollipop.java:78)
at android.support.v4.view.ViewCompat$LollipopViewCompatImpl.setBackgroundTintList(ViewCompat.java:1602)
at android.support.v4.view.ViewCompat.setBackgroundTintList(ViewCompat.java:2893)
at android.support.design.widget.TextInputLayout.updateEditTextBackground(TextInputLayout.java:544)
at android.support.design.widget.TextInputLayout.setError(TextInputLayout.java:445)
at com.example.sample.ui.CompleteProfileFragment$RegistrationController.onValidationFailed(CompleteProfileFragment.java:390)
at com.mobsandgeeks.saripaar.Validator.triggerValidationListenerCallback(Validator.java:721)
at com.mobsandgeeks.saripaar.Validator.validateFieldsWithCallbackTill(Validator.java:697)
at com.mobsandgeeks.saripaar.Validator.validateUnorderedFieldsWithCallbackTill(Validator.java:679)
at com.mobsandgeeks.saripaar.Validator.validate(Validator.java:334)
at com.mobsandgeeks.saripaar.Validator.validate(Validator.java:295)
What could be the error?. No error is appearing when the EditText is inside the TextInputLayout. But gives error in the case when a TextView is placed inside it.

Categories

Resources