"android.view.Inflateexception: Binary XM file line" when changing activity

Asked

Viewed 110 times

0

I am currently developing an app for Android and I have a problem that ends up making my program stop working from the moment I press the button "Signin".

The App has no problem at the time of reaching the main activity, but always ends up "crashing" at the time of pressing the button.

Basically there is some kind of problem with the code that is escaping me and unfortunately Android Studio also does not give any clue about the problem itself beyond the log that you can see below.

> 05-12 18:42:57.687 32378-32378/com.cars.evd.dealership
> E/AndroidRuntime: FATAL EXCEPTION: main
>     Process: com.cars.evd.dealership, PID: 32378
>     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cars.evd.dealership/com.cars.evd.dealership.main.SignIn}:
> android.view.InflateException: Binary XML file line #53: Binary XML
> file line #53: Error inflating class info.hoang8f.widget.FButton
>         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
>         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
>         at android.app.ActivityThread.-wrap11(Unknown Source:0)
>         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
>         at android.os.Handler.dispatchMessage(Handler.java:106)
>         at android.os.Looper.loop(Looper.java:164)
>         at android.app.ActivityThread.main(ActivityThread.java:6494)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
>         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
>      Caused by: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class info.hoang8f.widget.FButton
>      Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class info.hoang8f.widget.FButton
>      Caused by: java.lang.reflect.InvocationTargetException
>         at java.lang.reflect.Constructor.newInstance0(Native Method)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
>         at android.view.LayoutInflater.createView(LayoutInflater.java:647)
>         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
>         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
>         at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
>         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
>         at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
>         at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
>         at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
>         at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
>         at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
>         at com.cars.evd.dealership.main.SignIn.onCreate(SignIn.java:25)
>         at android.app.Activity.performCreate(Activity.java:7009)
>         at android.app.Activity.performCreate(Activity.java:7000)
>         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
>         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
>         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
>         at android.app.ActivityThread.-wrap11(Unknown Source:0)
>         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
>         at android.os.Handler.dispatchMessage(Handler.java:106)
>         at android.os.Looper.loop(Looper.java:164)
>         at android.app.ActivityThread.main(ActivityThread.java:6494)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
>         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
>      Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
>         at android.content.res.TypedArray.getColor(TypedArray.java:473)
>         at info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)
>         at info.hoang8f.widget.FButton.<init>(FButton.java:52)
>         at java.lang.reflect.Constructor.newInstance0(Native Method) 
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:334) 
>         at android.view.LayoutInflater.createView(LayoutInflater.java:647) 
>         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) 
>         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) 
>         at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) 
>         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) 
>         at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
>         at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
>         at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
>         at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
>         at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
>         at com.cars.evd.dealership.main.SignIn.onCreate(SignIn.java:25) 
>         at android.app.Activity.performCreate(Activity.java:7009) 
>         at android.app.Activity.performCreate(Activity.java:7000) 
>         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) 
>         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) 
>         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
>         at android.app.ActivityThread.-wrap11(Unknown Source:0) 
>         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
>         at android.os.Handler.dispatchMessage(Handler.java:106) 
>         at android.os.Looper.loop(Looper.java:164) 
>         at android.app.ActivityThread.main(ActivityThread.java:6494) 
>         at java.lang.reflect.Method.invoke(Native Method) 
>         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
>         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Manifest

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".SignIn">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
    </intent-filter>
</activity>
</application> 
</manifest>

Mainactivity.Java

Button btnSignIn, btnSignUp;
TextView txtSlogan;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    btnSignIn = (Button) findViewById(R.id.btnSignIn);
    btnSignUp = (Button) findViewById(R.id.btnSignUp);

    txtSlogan = (TextView) findViewById(R.id.txtSlogan);
    Typeface face = Typeface.createFromAsset(getAssets(), "fonts/NABILA.TTF");
    txtSlogan.setTypeface(face);


    btnSignUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent SignUp = new Intent(MainActivity.this, SignUp.class);
            startActivity(SignUp);
        }
    });

    btnSignIn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent SignIn = new Intent(MainActivity.this, SignIn.class);
            startActivity(SignIn);
        }
    });

} }

activity_main.xml

<LinearLayout
    android:orientation="vertical"
    android:layout_centerInParent="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:src="@drawable/logo" />

    <TextView
        android:id="@+id/txtSlogan"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/slogan"
        android:textColor="@android:color/white" />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_alignParentBottom="true"
    android:weightSum="2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <Button
        android:id="@+id/btnSignUp"
        style="@style/Widget.AppCompat.Button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:background="@color/btnSignActive"
        android:text="@string/SignUp"
        android:textColor="@android:color/white"
       />

    <Button
        android:id="@+id/btnSignIn"
        style="@style/Widget.AppCompat.Button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:background="@color/btnSignActive"
        android:text="@string/SignIn"
        android:textColor="@android:color/white"
       />
</LinearLayout>

Signin.Java

public class SignIn extends AppCompatActivity {
EditText edtemail, edtPassword;
Button btnSignIn; 
@Override
protected void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    setContentView(R.layout.activity_sign_in);

    edtPassword = (MaterialEditText) findViewById(R.id.edtPassword);
    edtemail = (MaterialEditText) findViewById(R.id.edtemail);
    btnSignIn = (Button) findViewById(R.id.btnSignIn);


    //Init Firebase
    final FirebaseDatabase database = FirebaseDatabase.getInstance();
    final DatabaseReference table_user = database.getReference("User");

    btnSignIn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            final ProgressDialog mDialog = new ProgressDialog(SignIn.this);
            mDialog.setMessage("Please Wait...");
            mDialog.show();

            table_user.addValueEventListener(new ValueEventListener() {

                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {

                    //check if user not exist in database
                    if(dataSnapshot.child(edtemail.getText().toString()).exists()) {
                        //get user information
                        mDialog.dismiss();
                        User user = dataSnapshot.child(edtemail.getText().toString()).getValue(User.class);
                        assert user != null;
                        user.setName(edtemail.getText().toString());
                        if (user.getPassword().equals(edtPassword.getText().toString())) {
                        } else {
                            Toast.makeText(SignIn.this, "Wrong Password !", Toast.LENGTH_SHORT).show();
                        }
                    }else{
                        Toast.makeText(SignIn.this, "User not exist in Database !", Toast.LENGTH_SHORT).show();
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            });
        }
    });

} }

Signin.xml

<LinearLayout
    android:orientation="vertical"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_centerInParent="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.rengwuxian.materialedittext.MaterialEditText
        android:id="@+id/edtemail"
        android:hint="@string/name_of_e_mail"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColorHint="@android:color/white"
        android:text="@string/daniel25_gmail_com"
        android:textColor="@android:color/white"
        android:textSize="34sp"
        android:inputType="phone"
        app:met_baseColor="@android:color/white"
        app:met_floatingLabel="highlight"
        app:met_maxCharacters="11"
        app:met_primaryColor="@android:color/white"
        app:met_singleLineEllipsis="true"
        />

    <com.rengwuxian.materialedittext.MaterialEditText
        android:id="@+id/edtPassword"
        android:hint="@string/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColorHint="@android:color/white"
        android:text="@string/_1234"
        android:textColor="@android:color/white"
        android:textSize="34sp"
        android:inputType="textPassword"
        app:met_baseColor="@android:color/white"
        app:met_floatingLabel="highlight"
        app:met_maxCharacters="11"
        app:met_primaryColor="@android:color/white"
        app:met_singleLineEllipsis="true"
        />

</LinearLayout>
<info.hoang8f.widget.FButton
    android:id="@+id/btnSignIn"
    android:text="@string/SignIn"
    android:textColor="@android:color/white"
    android:layout_marginRight="8dp"
    android:layout_marginLeft="8dp"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    app:buttonColor="@color/btnSignActive"
    app:shadowColor="@android:color/black"
    app:shadowEnabled="true"
    app:shadowHeight="5dp"
    app:cornerRadius="4dp"
    /> </RelativeLayout>

1 answer

0


As described here, is a problem with the Fbutton library you are using. Follow the link to get alternatives.

  • Thankful for the answer, it’s totally correct. The problem you had was related to Fbutton and the new library solved all the problems.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.