AlmogBaku / IntlPhoneInput

International phone input for Android
Other
164 stars 96 forks source link

Getting Inflate Exception while adding net.rimoto.intlphoneinput.IntlPhoneInput to layout xml #11

Open Maheshkmrao opened 8 years ago

Maheshkmrao commented 8 years ago

Hi -

I am adding view in my layout file as below. <net.rimoto.intlphoneinput.IntlPhoneInput android:id="@+id/intlphone_input_phonenumber" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_phonenumber" /> However, I am getting "android.view.InflateException: Binary XML file line #: Error inflating class net.rimoto.intlphoneinput.IntlPhoneInput" exception while running on device.

So, anybody could you please check this and provide me the solution.

jarrodholliday commented 8 years ago

Hey @Maheshkmrao, It's most likely the hint. This library auto fills the hint based on the suggested format for the country selected.

Maheshkmrao commented 8 years ago

Hi @jarrodholliday , even if I remove "android:hint" also, I am getting android.view.InflateException. I am using net.rimoto:intlphoneinput:0.9.3@aar library. Could you please suggest me.

jarrodholliday commented 8 years ago

@Maheshkmrao would be easier to help you with the full layout file and the exact line it's complaining about.

Maheshkmrao commented 8 years ago

Hi @jarrodholliday , this is my layout file. And in layout preview mode, I am getting "java.lang.ClassNotFoundException: com.google.i18n.phonenumbers.NumberParseException"

<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_marginTop="?attr/actionBarSize" android:orientation="vertical" android:paddingLeft="20dp" android:paddingRight="20dp" android:paddingTop="20dp">

    <net.rimoto.intlphoneinput.IntlPhoneInput
        android:id="@+id/intlphone_input_phonenumber"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/editext_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_emailaddress"
            android:inputType="textEmailAddress" />

    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/input_layout_invitationcode"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/editext_invitationcode"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_invitationcode"
            android:inputType="number" />

    </android.support.design.widget.TextInputLayout>

    <ImageButton
        android:id="@+id/btn_send_sms_code"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="40dp"
        android:background="@color/colorWhite"
        android:src="@drawable/login_button" />
</LinearLayout>

So, please help me to resolve this.

prolific commented 7 years ago

Any update? Facing the same issue.

jarrodholliday commented 7 years ago

@Maheshkmrao and @prolificrohit, sorry got super duper busy with work and spaced on this completely. With the exception it looks like there it's trying to find a class that is no longer in the google libphonenumbers library used to determine if a phone number is valid and what country it belongs to.

Long ago I abandoned trying to make fixes and pull requests to this library since the author seemed to be inactive. Maybe give my fork of the library a try and see if it fixes it. Quick warning though my fork has changes to suit my needs like the flags being in a Circular ImageView and it now uses helper text instead of hint text to display the hint. Lots of our users were getting confused thinking the hint was us entering their phone number wrong so the helper text below the EditText should resolve that. compile 'com.github.jarrodholliday:intlphoneinput:0.9.16'

prolific commented 7 years ago

@jarrodholliday I was able to trace the problem which created this error.

This errors occurs when we try to use setNumber function with an invalid number like a number without country code. This was the exact case which created a problem for me.

For now, I have handled the problem myself but i do believe that this should be handled in the library and a default country code should be added when not provided.

jarrodholliday commented 7 years ago

@prolificrohit, awesome! Glad you figured it out.

Yea it probably should be handled in the library, but last activity was 4 months ago so it might not happen in a timely manner.

MahmoudAymann commented 6 years ago

hello guys, i just followed your answers but not working for any of them i'm just adding `<FrameLayout 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" tools:context=".fragments.BlankFragment">

<net.rimoto.intlphoneinput.IntlPhoneInput
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

</net.rimoto.intlphoneinput.IntlPhoneInput>

` only one fragment to test but its not working...

visheshhartler commented 5 years ago

I am facing a similar issue.

aamir-github commented 5 years ago

Running fine on android 8 and 9, but facing the same issue on android 6.0

juanvictorbascopecastro commented 4 years ago

I have the same problem, if someone has a solution please let me know

rexendz commented 3 years ago

I'm currently facing the same issue now BUT only when READ_SMS permission is granted If I don't allow READ_SMS permission, the InflateException does not get triggered

Any fix for this?