4
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nuku.mc.august/com.nuku.mc.august.LoginActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class EditText.

this is my activity_login:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:id="@+id/login_layout"
    android:padding="10dp" >


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="vertical"
        android:paddingLeft="20dp"
        android:paddingRight="20dp" >

        <EditText
            android:id="@+id/email"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:hint="@string/hint_email"
            android:inputType="textEmailAddress"
            android:padding="10dp"
            android:singleLine="true"
            android:textColor="@color/white"
            android:textColorHint="@color/white"
            android:drawableLeft="@drawable/ic_email"
            android:background="@null"/>

        <EditText
            android:id="@+id/password"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:background="@null"
            android:hint="@string/hint_password"
            android:inputType="textPassword"
            android:padding="10dp"
            android:singleLine="true"
            android:drawableLeft="@drawable/ic_lock_icon_png"
            android:textColor="@color/white"
            android:textColorHint="@color/white"
           />

        <!-- Login Button -->

        <android.support.v7.widget.AppCompatButton
            android:id="@+id/btn_login"
            android:layout_width="147dp"
            android:layout_gravity="center"
            android:layout_height="wrap_content"
            android:background="@drawable/normal"
            android:textColor="@color/white"
            android:textStyle="bold|italic"
            android:layout_marginTop="24dp"
            android:layout_marginBottom="24dp"
            android:padding="12dp"
            android:text="login"
            android:alpha="0.6"

            />


    </LinearLayout>
</LinearLayout>

there is also error setting activity background image,I realize it's quite large what should I do about it? I looked for a few solution but they seem quite difficult. please suggest something easier.

logs:

            java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nuku.mc.august/com.nuku.mc.august.LoginActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)
                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
                                                                at android.app.ActivityThread.access$600(ActivityThread.java:162)
                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                                                at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                at android.os.Looper.loop(Looper.java:194)
                                                                at android.app.ActivityThread.main(ActivityThread.java:5371)
                                                                at java.lang.reflect.Method.invokeNative(Native Method)
                                                                at java.lang.reflect.Method.invoke(Method.java:525)
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                                                                at dalvik.system.NativeStart.main(Native Method)
                                                             Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                                                                at android.view.LayoutInflater.createView(LayoutInflater.java:613)
                                                                at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
                                                                at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
                                                                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                                                                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                                                                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                at com.nuku.mc.august.LoginActivity.onCreate(LoginActivity.java:45)
                                                                at android.app.Activity.performCreate(Activity.java:5122)
                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
                                                                at android.app.ActivityThread.access$600(ActivityThread.java:162) 
                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                                                                at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                at android.os.Looper.loop(Looper.java:194) 
                                                                at android.app.ActivityThread.main(ActivityThread.java:5371) 
                                                                at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                                                                at dalvik.system.NativeStart.main(Native Method) 
                                                             Caused by: java.lang.reflect.InvocationTargetException
                                                                at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                                at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
                                                                at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 
                                                                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
                                                                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                at com.nuku.mc.august.LoginActivity.onCreate(LoginActivity.java:45) 
                                                                at android.app.Activity.performCreate(Activity.java:5122) 
                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) 
                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 
                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
                                                                at android.app.ActivityThread.access$600(ActivityThread.java:162) 
                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                                                                at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                at android.os.Looper.loop(Looper.java:194) 
                                                                at android.app.ActivityThread.main(ActivityThread.java:5371) 
                                                                at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                                                                at dalvik.system.NativeStart.main(Native Method) 
                                                             Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02005a a=-1 r=0x7f02005a}
                                                                at android.content.res.Resources.loadDrawable(Resources.java:1967)
                                                                at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
                                                                at android.view.View.<init>(View.java:3338)
                                                                at android.view.ViewGroup.<init>(ViewGroup.java:436)
                                                                at android.widget.LinearLayout.<init>(LinearLayout.java:176)
                                                                at android.widget.LinearLayout.<init>(LinearLayout.java:172)
                                                                at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
                                                                at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
                                                                at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
                                                                at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 
                                                                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                                at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
                                                                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                at com.nuku.mc.august.LoginActivity.onCreate(LoginActivity.java:45) 
                                                                at android.app.Activity.performCreate(Activity.java:5122) 
                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) 
                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 
                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
                                                                at android.app.ActivityThread.access$600(ActivityThread.java:162) 
                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                                                                at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                at android.os.Looper.loop(Looper.java:194) 
                                                                at android.app.ActivityThread.main(ActivityThread.java:5371) 
                                                                at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                                                                at dalvik.system.NativeStart.main(Native Method) 

this is my build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.nuku.mc.august"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:design:23.4.0'

    compile 'com.squareup.retrofit:retrofit:1.9.0'
}
Nukhba Arshad
  • 131
  • 2
  • 14
  • Can you post the whole logcat of the exception? It may contain some useful stuff like `Caused by:` part. – Vucko Aug 06 '16 at 18:01
  • @Vucko I've edited the question with logcats. – Nukhba Arshad Aug 06 '16 at 18:12
  • As your logcat says, your drawable is not getting referenced properly. Check it. Also, clean your project. – Shaishav Aug 06 '16 at 18:15
  • 2
    Yes, exactly this ^ . Check both your drawables you're using like this: `android:drawableLeft="@drawable/ic_lock_icon_png"`. I think therein lies the problem. Comment them both and see if the error occurs again, if not, you got a problem with one of them at least. Especially the one I mentioned looks suspicious to me because of `_png` in the name. – Vucko Aug 06 '16 at 18:17
  • 1
    Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02005a a=-1 r=0x7f02005a} - This line clearly states that one of the resources is not a drawable. Check the ic_email or ic_lock_icon and whether they are right. – Narayan Acharya Aug 06 '16 at 18:17
  • Since its line 19 its probably with the first edit text i.e the one with the ic_email – Narayan Acharya Aug 06 '16 at 18:19
  • @Vucko I removed the above-mentioned lines of code now there's another error similar to this one, am updating the logcats in my question. – Nukhba Arshad Aug 06 '16 at 18:41
  • @NarayanAcharya I removed the above-mentioned lines of code now there's another error similar to this one, am updating the logcats in my question. – Nukhba Arshad Aug 06 '16 at 18:43
  • I see no difference in the logcat unfortunately. Can you do the following: first locate the editText in question - by commenting out one and then the other and seeing which one causes the trouble, after that try commenting/uncommenting line after line of it's attributes to see which one causes the error :) Write the results, good luck hunting. – Vucko Aug 06 '16 at 18:45
  • Please post your build.gradle file contents. I had a similar problem like this. Maybe i can solve yours too. Post your build.gradle file – Nick Asher Aug 06 '16 at 18:56
  • One problem could be the size of the image. If its too large it could pose problems. Check this out, have you made a similar mistake? - http://stackoverflow.com/a/34707995/5512274 – Narayan Acharya Aug 06 '16 at 18:58
  • @NickAsher I've edited the question with my gradle file. – Nukhba Arshad Aug 06 '16 at 19:07
  • @NarayanAcharya okay thank you – Nukhba Arshad Aug 06 '16 at 19:08

1 Answers1

0

the problem is in your android:drawableLeft="@drawable/ic_lock_icon_png" drawable left,right doesn't work in old device so remove it and check

if you want drawableleft then change your vector asset "ic_lock_icon_png" to image asset or jpeg. (recomended image asset) .

Ryan M
  • 18,333
  • 31
  • 67
  • 74