firebase / FirebaseUI-Android

Optimized UI components for Firebase
https://firebaseopensource.com/projects/firebase/firebaseui-android/
Apache License 2.0
4.63k stars 1.84k forks source link

android.view.InflateException: Binary XML file line #0: Error inflating class com.firebase.ui.auth.util.ui.BaselineTextInputLayout #1162

Closed abdulwasae closed 6 years ago

abdulwasae commented 6 years ago

Step 1: Are you in the right place? Yes

Step 2: Describe your environment Android device: SM-G386T1, SM-N910T, Galaxy S3 (, and possibly more) Android OS version: API 18, 19 Google Play Services version: 11.8.0 Firebase/Play Services SDK version: 11.8.0 FirebaseUI version: 3.2.0 com.android.support:support-v4: 27.0.2 com.android.support:appcompat-v7: 27.0.2 compileSdkVersion 27 minSdkVersion 17 targetSdkVersion 27

Step 3: Describe the problem: Please take a look at the following stack trace, which seems to arise in API 18 and 19.

Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.yyy/com.firebase.ui.auth.ui.phone.PhoneActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class com.firebase.ui.auth.util.ui.BaselineTextInputLayout android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2447) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2507) android.app.ActivityThread.access$900 (ActivityThread.java:172) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1308) android.os.Handler.dispatchMessage (Handler.java:102) android.os.Looper.loop (Looper.java:146) android.app.ActivityThread.main (ActivityThread.java:5692) java.lang.reflect.Method.invokeNative (Method.java) java.lang.reflect.Method.invoke (Method.java:515) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1291) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1107) dalvik.system.NativeStart.main (NativeStart.java)

Caused by android.view.InflateException: Binary XML file line #0: Error inflating class com.firebase.ui.auth.util.ui.BaselineTextInputLayout android.view.LayoutInflater.createView (LayoutInflater.java:626) android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:702) android.view.LayoutInflater.rInflate (LayoutInflater.java:761) android.view.LayoutInflater.rInflate (LayoutInflater.java:769) android.view.LayoutInflater.inflate (LayoutInflater.java:498) android.view.LayoutInflater.inflate (LayoutInflater.java:398) com.firebase.ui.auth.ui.phone.VerifyPhoneNumberFragment.access$000 (VerifyPhoneNumberFragment.java) android.support.v4.app.Fragment.access$800 (Fragment.java) android.support.v4.app.FragmentManagerImpl.access$500 (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.dispatchOnFragmentStopped (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.access$500 (FragmentManagerImpl.java) android.support.v4.app.BackStackRecord.executeOps (BackStackRecord.java) android.support.v4.app.FragmentManagerImpl.addAddedFragments (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.access$500 (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.addAddedFragments (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.execPendingActions (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.dispatchOnFragmentStopped (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java) android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java) android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java) android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java) com.firebase.ui.auth.ui.phone.PhoneActivity.onStart (PhoneActivity.java) android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1177) android.app.Activity.performStart (Activity.java:5551) android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2420) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2507) android.app.ActivityThread.access$900 (ActivityThread.java:172) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1308) android.os.Handler.dispatchMessage (Handler.java:102) android.os.Looper.loop (Looper.java:146) android.app.ActivityThread.main (ActivityThread.java:5692) java.lang.reflect.Method.invokeNative (Method.java) java.lang.reflect.Method.invoke (Method.java:515) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1291) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1107) dalvik.system.NativeStart.main (NativeStart.java)

Caused by java.lang.reflect.InvocationTargetException: java.lang.reflect.Constructor.constructNative (Constructor.java) java.lang.reflect.Constructor.newInstance (Constructor.java:423) android.view.LayoutInflater.createView (LayoutInflater.java:600) android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:702) android.view.LayoutInflater.rInflate (LayoutInflater.java:761) android.view.LayoutInflater.rInflate (LayoutInflater.java:769) android.view.LayoutInflater.inflate (LayoutInflater.java:498) android.view.LayoutInflater.inflate (LayoutInflater.java:398) com.firebase.ui.auth.ui.phone.VerifyPhoneNumberFragment.access$000 (VerifyPhoneNumberFragment.java) android.support.v4.app.Fragment.access$800 (Fragment.java) android.support.v4.app.FragmentManagerImpl.access$500 (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.dispatchOnFragmentStopped (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.access$500 (FragmentManagerImpl.java) android.support.v4.app.BackStackRecord.executeOps (BackStackRecord.java) android.support.v4.app.FragmentManagerImpl.addAddedFragments (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.access$500 (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.addAddedFragments (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.execPendingActions (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.dispatchOnFragmentStopped (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java) android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java) android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java) android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java) com.firebase.ui.auth.ui.phone.PhoneActivity.onStart (PhoneActivity.java) android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1177) android.app.Activity.performStart (Activity.java:5551) android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2420) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2507) android.app.ActivityThread.access$900 (ActivityThread.java:172) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1308) android.os.Handler.dispatchMessage (Handler.java:102) android.os.Looper.loop (Looper.java:146) android.app.ActivityThread.main (ActivityThread.java:5692) java.lang.reflect.Method.invokeNative (Method.java) java.lang.reflect.Method.invoke (Method.java:515) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1291) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1107) dalvik.system.NativeStart.main (NativeStart.java)

Caused by java.lang.IndexOutOfBoundsException: android.content.res.StringBlock.nativeGetString (StringBlock.java) android.content.res.StringBlock.get (StringBlock.java:82) android.content.res.AssetManager.getPooledString (AssetManager.java:275) android.content.res.TypedArray.loadStringValueAt (TypedArray.java:730) android.content.res.TypedArray.getString (TypedArray.java:125) android.support.design.widget.CollapsingTextHelper.getExpandedTypeface (CollapsingTextHelper.java) android.support.design.widget.CollapsingTextHelper.calculateOffsets (CollapsingTextHelper.java) android.support.design.widget.TextInputLayout.setHintTextAppearance (TextInputLayout.java) android.support.design.widget.TextInputLayout.<init> (TextInputLayout.java) android.support.design.widget.TextInputLayout.<init> (TextInputLayout.java) com.firebase.ui.auth.util.ui.BaselineTextInputLayout.<init> (BaselineTextInputLayout.java) java.lang.reflect.Constructor.constructNative (Constructor.java) java.lang.reflect.Constructor.newInstance (Constructor.java:423) android.view.LayoutInflater.createView (LayoutInflater.java:600) android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:702) android.view.LayoutInflater.rInflate (LayoutInflater.java:761) android.view.LayoutInflater.rInflate (LayoutInflater.java:769) android.view.LayoutInflater.inflate (LayoutInflater.java:498) android.view.LayoutInflater.inflate (LayoutInflater.java:398) com.firebase.ui.auth.ui.phone.VerifyPhoneNumberFragment.access$000 (VerifyPhoneNumberFragment.java) android.support.v4.app.Fragment.access$800 (Fragment.java) android.support.v4.app.FragmentManagerImpl.access$500 (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.dispatchOnFragmentStopped (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.access$500 (FragmentManagerImpl.java) android.support.v4.app.BackStackRecord.executeOps (BackStackRecord.java) android.support.v4.app.FragmentManagerImpl.addAddedFragments (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.access$500 (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.addAddedFragments (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.execPendingActions (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.dispatchOnFragmentStopped (FragmentManagerImpl.java) android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java) android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java) android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java) android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java) com.firebase.ui.auth.ui.phone.PhoneActivity.onStart (PhoneActivity.java) android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1177) android.app.Activity.performStart (Activity.java:5551) android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2420) android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2507) android.app.ActivityThread.access$900 (ActivityThread.java:172) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1308) android.os.Handler.dispatchMessage (Handler.java:102) android.os.Looper.loop (Looper.java:146) android.app.ActivityThread.main (ActivityThread.java:5692) java.lang.reflect.Method.invokeNative (Method.java) java.lang.reflect.Method.invoke (Method.java:515) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1291) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1107) dalvik.system.NativeStart.main (NativeStart.java)

Likely, there is something wrong with the styling part of the the layout. But upon giving the code a look, nothing seems fishy. Any help would be appreciated.

Quick links to relevant files: fui_phone_layout.xml styles.xml BaselineTextInputLayout.java

KMCGamer commented 6 years ago

My apologies, I can't read.

samtstern commented 6 years ago

@abdulwasae can you show your app's build.gradle file?

abdulwasae commented 6 years ago

Here you go:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.xxx.yyy"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 8
        versionName "1.0.8"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }
    buildTypes {
        debug {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguardTest-rules.pro'
        }

        release {
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguardTest-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.android.support:support-v4:27.0.2'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:27.0.2'
    implementation 'com.android.support:support-vector-drawable:27.0.2'
    implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
    implementation 'com.google.code.findbugs:jsr305:3.0.1'
    implementation 'com.firebaseui:firebase-ui-auth:3.2.1'
    implementation 'com.firebaseui:firebase-ui-storage:3.2.1'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.android.gms:play-services-auth:11.8.0'
    implementation 'com.google.firebase:firebase-firestore:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.firebase:firebase-config:11.8.0'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
        transitive = true
    }
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    compile ('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {
        exclude module: 'support-v4'
    }
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'io.reactivex.rxjava2:rxjava:2.1.7'
    compile 'com.orhanobut:hawk:2.0.1'
    compile 'me.xdrop:fuzzywuzzy:1.1.9'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.github.bumptech.glide:glide:4.5.0'
    implementation ('com.github.bumptech.glide:recyclerview-integration:4.5.0') {
        transitive = false
    }
    compile 'com.github.bumptech.glide:annotations:4.5.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
    implementation('com.github.hotchemi:permissionsdispatcher:3.1.0') {
        exclude module: "support-v13"
    }
    annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:3.1.0'
    implementation 'com.ncapdevi:frag-nav:2.4.0'

    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
abdulwasae commented 6 years ago

Update:

I was lucky enough to find out that Firebase test lab has a Samsung Galaxy S3 (API 18) which would reproduce the above issue. So i debugged and found out that, yes, it was an issue regarding the styling. However, it wasn't from inside the FirebaseUI. The thing is that when a start the AuthUI using the builder, i also set a custom theme, which was:

  <style name="FirebaseUiTheme" parent="AppTheme">
        <item name="windowActionBar">true</item>
        <item name="windowNoTitle">false</item>
        <item name="android:includeFontPadding">true</item>
        <item name="android:textDirection">ltr</item>
        <item name="android:layoutDirection">ltr</item>
        <item name="android:fontFamily">sans-serif</item>
        <item name="android:textSize">@dimen/font_size_m_eng</item>
    </style>

The issue was gone when i removed this theme altogether. I then decided to narrow the cause down. First, i removed the parent="AppTheme, and then tried a number of combinations of the items inside the FirebaseUiTheme theme. After several tests i was able to confirm that:

These combinations cause the crash:

These combinations Do Not cause the crash:

It is weird that textSize alone does not cause the crash, and textDirection + layoutDirection also do not cause the crash. But these 3 together cause the crash.

samtstern commented 6 years ago

Wow @abdulwasae thanks for the thorough investigation! I agree ... it's very strange which combinations cause the crash. I am going to close this issue as it's not related directly to FirebaseUI (as you said), but it is really interesting!