Skip to content

Crash when trying to open country picker #26

@davinh2306

Description

@davinh2306

Hello,

I want to open the country picker but sadly I face this attribute at index 5 exception :

2022-03-15 19:09:32.599 15232-15232 E/AndroidRuntime: FATAL EXCEPTION: main
PID: 15232
android.view.InflateException: Binary XML file line #24 in layout/bottom_sheet_country_picker: Binary XML file line #24 in bottom_sheet_country_picker: Error inflating class androidx.appcompat.widget.AppCompatImageView
Caused by: android.view.InflateException: Binary XML file line #24 in bottom_sheet_country_picker: Error inflating class androidx.appcompat.widget.AppCompatImageView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:856)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1008)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:963)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1125)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1128)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
at android.view.LayoutInflater.inflate(LayoutInflater.java:684)
at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
at me.ibrahimsn.lib.databinding.BottomSheetCountryPickerBinding.inflate(BottomSheetCountryPickerBinding.java:56)
at me.ibrahimsn.lib.databinding.BottomSheetCountryPickerBinding.inflate(BottomSheetCountryPickerBinding.java:50)
at me.ibrahimsn.lib.internal.ui.CountryPickerBottomSheet.onCreateView(CountryPickerBottomSheet.kt:60)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2995)
at androidx.fragment.app.DialogFragment.performCreateView(DialogFragment.java:492)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:523)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1764)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1701)
at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:488)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8061)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 5: TypedValue{t=0x2/d=0x7f0300f2 a=-1}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:599)
at android.widget.ImageView.(ImageView.java:227)
at android.widget.ImageView.(ImageView.java:190)
at androidx.appcompat.widget.AppCompatImageView.(AppCompatImageView.java:78)
at androidx.appcompat.widget.AppCompatImageView.(AppCompatImageView.java:73)
at java.lang.reflect.Constructor.newInstance0(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:343) 
at android.view.LayoutInflater.createView(LayoutInflater.java:856) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1008) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:963) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1125) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1128) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:684) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:536) 
at me.ibrahimsn.lib.databinding.BottomSheetCountryPickerBinding.inflate(BottomSheetCountryPickerBinding.java:56) 
at me.ibrahimsn.lib.databinding.BottomSheetCountryPickerBinding.inflate(BottomSheetCountryPickerBinding.java:50) 
at me.ibrahimsn.lib.internal.ui.CountryPickerBottomSheet.onCreateView(CountryPickerBottomSheet.kt:60) 
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2995) 
at androidx.fragment.app.DialogFragment.performCreateView(DialogFragment.java:492) 
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:523) 
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261) 
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840) 
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1764) 
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1701) 
at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:488) 
at android.os.Handler.handleCallback(Handler.java:938) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:236) 
at android.app.ActivityThread.main(ActivityThread.java:8061) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) 

Here is my code :

    val localCountry = Locale.getDefault().country.lowercase()

    val phoneNumberKit = PhoneNumberKit.Builder(context)
        .setIconEnabled(true)
        .build()

    phoneNumberKit.attachToInput(phoneTextInputLayout, localCountry)

    context.getActivity()?.let {
        phoneNumberKit.setupCountryPicker(
            activity = it,
            searchEnabled = true
        )
    }

Is there anything obvious I am doing wrong?

Greetings,
David

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions