0

I'm working on a login screen and it contains two EditText and when I run the application in android studio, I'm getting error

android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class EditText

here's the first lines of log error

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.techgeorge.loginscreen, PID: 27960
    java.lang.RuntimeException: Unable to start activity ComponentInfo{org.techgeorge.loginscreen/org.techgeorge.loginscreen.MainActivity}: android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class EditText
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2974)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3059)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:7000)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
     Caused by: android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class EditText
     Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class EditText
     Caused by: java.lang.NumberFormatException: For input string: "18sp"

hint to line 37 of xml file, which is an EditText, but I see nothing wrong with the EditText. xml layout file is not giving me errors as to any property error or typos. The logs are not giving a lot of information other than it points to this line

setContentView(R.layout.activity_main);

in MainActivity.java heres the class

package org.techgeorge.loginscreen;

public class MainActivity extends AppCompatActivity {

    private TextView titleTextView, registerTextView, forgetPassTextView;
    private EditText usernameEditText, passwordEditText;
    private ImageView logoImageView;
    private Button loginButton;

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

        titleTextView = findViewById(R.id.title_textview);
        registerTextView = findViewById(R.id.register_textview);
        forgetPassTextView = findViewById(R.id.forget_password_textview);
        usernameEditText = findViewById(R.id.user_edittext);
        passwordEditText = findViewById(R.id.password_edittext);
        logoImageView = findViewById(R.id.logo_imageview);
        loginButton = findViewById(R.id.button);

        loginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getApplicationContext(), ProfileActivity.class);
                startActivity(intent);
            }
        });
    }
}

here's xml layout class activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
    android:background="@drawable/login_background"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/logo_imageview"
        android:layout_width="62dp"
        android:layout_height="61dp"
        android:layout_marginTop="52dp"
        android:layout_marginEnd="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.511"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/ic_whatshot_white_24dp" />

    <TextView
        android:id="@+id/title_textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:fontFamily="@font/abril_fatface"
        android:text="SUNKAT"
        android:textAlignment="center"
        android:textColor="@color/headerTextColor"
        android:textSize="46sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/logo_imageview" />

    <EditText
        android:id="@+id/user_edittext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="118dp"
        android:layout_marginEnd="8dp"
        android:backgroundTint="#ffffff"
        android:drawableLeft="@drawable/ic_person_white_24dp"
        android:ems="12"
        android:hint="@string/user_text_hint"
        android:inputType="textPersonName"
        android:text=""
        android:textAlignment="center"
        android:textColorHint="@color/hintTextColor"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/title_textview" />

    <EditText
        android:id="@+id/password_edittext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="8dp"
        android:backgroundTint="#ffffff"
        android:drawableLeft="@drawable/ic_lock_white_24dp"
        android:ems="12"
        android:hint="@string/password_text_hint"
        android:inputType="textPassword"
        android:text=""
        android:textAlignment="center"
        android:textColorHint="@color/hintTextColor"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/user_edittext" />

    <Button
        android:id="@+id/button"
        android:layout_width="256dp"
        android:layout_height="42dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="8dp"
        android:background="@drawable/button_shape"
        android:text="login"
        android:textColor="@android:color/background_light"
        android:textSize="16sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.539"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/password_edittext" />

    <TextView
        android:id="@+id/register_textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:text="Register"
        android:textColor="#62BCFA"
        android:textSize="16sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.223"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button" />

    <TextView
        android:id="@+id/forget_password_textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:text="forgot password?"
        android:textColor="#62BCFA"
        android:textSize="16sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.762"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button" />

</android.support.constraint.ConstraintLayout>
miatech
  • 2,150
  • 8
  • 41
  • 78

2 Answers2

2

Note that your stack trace also has this information:

Caused by: java.lang.NumberFormatException: For input string: "18sp"

This should help you pinpoint the problem.

h_k
  • 1,674
  • 1
  • 24
  • 46
  • remove the line... keeps happening. I think android studio has been hacked lol – miatech Nov 11 '19 at 14:03
  • ohh I found it.. it was in the string files that's why couldn't find it. do you know how can I increase size of hint text? – miatech Nov 11 '19 at 14:18
  • @miatech Do you mean separately from the regular text size? Increasing the normal text size also increases the hint text size. If you want to have different hint text size from the normal text size, you can do so programmatically, or do something like so https://stackoverflow.com/a/29963972/1421014 – h_k Nov 11 '19 at 16:00
0

I've experienced the same thing and i think its bug, lets try to delete it first, and rewrite it