Home > front end >  after run the android xml file the app has install in my phone but the app is not opening
after run the android xml file the app has install in my phone but the app is not opening

Time:12-26

I am totally new to android development and trying to learn it by my own, I have done some coding in xml file but when I run the application, app has install in my phone but not opening.

Here is the error log:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.sumita.yourhelp, PID: 6407
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sumita.yourhelp/com.sumita.yourhelp.MainActivity}: android.view.InflateException: Binary XML file line #39: Binary XML file line #39: Error inflating class androidx.appcompat.widget.AppCompatButton
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2994)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3072)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1766)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:6977)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:528)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:910)
     Caused by: android.view.InflateException: Binary XML file line #39: Binary XML file line #39: Error inflating class androidx.appcompat.widget.AppCompatButton
     Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class androidx.appcompat.widget.AppCompatButton
     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:650)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:797)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:737)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:870)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:831)
        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 androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:710)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at com.sumita.yourhelp.MainActivity.onCreate(MainActivity.java:12)
        at android.app.Activity.performCreate(Activity.java:7227)
        at android.app.Activity.performCreate(Activity.java:7218)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3072)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1766)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:6977)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:528)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:910)
     Caused by: java.lang.UnsupportedOperationException: Can't convert to ComplexColor: type=0x1
        at android.content.res.ResourcesImpl.loadComplexColorForCookie(ResourcesImpl.java:1217)
        at android.content.res.ResourcesImpl.loadComplexColorFromName(ResourcesImpl.java:1094)
        at android.content.res.ResourcesImpl.loadColorStateList(ResourcesImpl.java:1173)
        at android.content.res.Resources.loadColorStateList(Resources.java:1076)
        at android.content.res.TypedArray.getColorStateList(TypedArray.java:541)
        at android.view.View.<init>(View.java:5180)
        at android.widget.TextView.<init>(TextView.java:867)
        at android.widget.Button.<init>(Button.java:166)
        at android.widget.Button.<init>(Button.java:141)
        at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:80)
        at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:75)
        at java.lang.reflect.Constructor.newInstance0(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:650) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:797) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:737) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:870) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:831) 
        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 androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:710) 
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195) 
        at com.sumita.yourhelp.MainActivity.onCreate(MainActivity.java:12) 
        at android.app.Activity.performCreate(Activity.java:7227) 
        at android.app.Activity.performCreate(Activity.java:7218) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3072) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1766) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:6977) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:528) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:910) 

And here is the xml file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical"
    android:padding="11dp"
    android:gravity="center_horizontal">


    <ImageView
        android:layout_width="match_parent"
        android:layout_height="258dp"
        android:contentDescription="@string/About"
        android:scaleType="fitXY"
        android:src="@drawable/ic_contact_us" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Aboutus"
        android:textSize="20sp"
        android:textStyle="bold"
        android:textColor="?android:attr/colorFocusedHighlight"/>

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="12"
        android:hint="enter number"
        android:inputType="number" />
    <androidx.appcompat.widget.AppCompatButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:backgroundTint="@color/material_dynamic_neutral40"
        android:text="contact us"
        android:textColor="@color/black"/>
</LinearLayout>

CodePudding user response:

Two relevant parts of your error log.

This section points to a problem in line 39 of your layout file, inflating an AppCompatButton.

Caused by: android.view.InflateException: Binary XML file line #39: Binary XML file line #39: Error inflating class androidx.appcompat.widget.AppCompatButton

There's also this in your error log:

Caused by: java.lang.UnsupportedOperationException: Can't convert to ComplexColor: type=0x1

So, taken together, your error log suggests that there's a problem with a color that's being used in an AppCompatButton on line 39 of your layout XML.

If you look at that line in your layout file, you'll see this:

android:textColor="@color/black"/>

Taken together, I would guess that you haven't defined the color you've called black correctly. Try and replace it with @android:color/black and see if that works. If it does, then you need to fix whatever color you've defined for black in your resources files.

  • Related