Android-应用程序运行时失败

时间:2019-03-05 13:58:43

标签: android xml android-layout runtime

我正在制作一个测试应用,并且该应用正在运行。我转移到另一个项目,并被这个错误困扰。 **

错误

**

 Process: muhammadhassaan.com.tipcalculator, PID: 7646
java.lang.RuntimeException: Unable to start activity ComponentInfo{muhammadhassaan.com.tipcalculator/muhammadhassaan.com.tipcalculator.MainActivity}: android.view.InflateException: Binary XML file line #164: Binary XML file line #164: Error inflating class <unknown>
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 Caused by: android.view.InflateException: Binary XML file line #164: Binary XML file line #164: Error inflating class <unknown>
 Caused by: android.view.InflateException: Binary XML file line #164: Error inflating class <unknown>
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
    at android.view.LayoutInflater.createView(LayoutInflater.java:647)
    at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
    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.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
    at muhammadhassaan.com.tipcalculator.MainActivity.onCreate(MainActivity.java:11)
    at android.app.Activity.performCreate(Activity.java:7136)
    at android.app.Activity.performCreate(Activity.java:7127)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 5: TypedValue{t=0x2/d=0x101012d a=-1}
    at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:946)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:930)

2019-03-05 18:39:30.350 7646-7646 / muhammadhassaan.com.tipcalculator E / AndroidRuntime:位于android.widget.LinearLayout。(LinearLayout.java:282)         在android.widget.LinearLayout。(LinearLayout.java:240)         在android.widget.LinearLayout。(LinearLayout.java:236)             ...再加30

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="@color/colorBlue"
tools:context=".MainActivity">

<TextView
    android:id="@+id/tvBillAmount"
    android:layout_width="match_parent"
    android:layout_height="38dp"
    android:layout_marginStart="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginEnd="16dp"
    android:layout_marginRight="16dp"
    android:text="@string/main.msg.billamount"
    android:textAppearance="?android:textAppearanceMedium"
    android:textColor="@color/colorWhite"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/guideline2" />

<EditText
    android:id="@+id/etBillAmount"
    android:layout_width="match_parent"
    android:layout_height="61dp"
    android:layout_marginStart="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="16dp"
    android:layout_marginRight="16dp"
    android:background="@android:color/transparent"
    android:ems="10"
    android:gravity="center"
    android:hint="@string/main.hint.billamount"
    android:inputType="numberDecimal"
    android:textAppearance="?android:textAppearanceLarge"
    android:textColor="@color/colorWhite"
    android:textColorHint="@color/colorGray"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvBillAmount" />

<View
    android:id="@+id/vSeprator1"
    android:layout_width="0dp"
    android:layout_height="1dp"
    android:layout_marginStart="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="16dp"
    android:layout_marginEnd="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginBottom="16dp"
    android:background="@color/colorGray"
    app:layout_constraintBottom_toTopOf="@+id/llRatingButtons"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/etBillAmount" />

<LinearLayout
    android:id="@+id/llRatingButtons"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/etBillAmount">

    <ImageButton
        android:id="@+id/ibRegularService"
        android:layout_width="16dp"
        android:layout_height="match_parent"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:backgroundTint="@color/colorBlue"
        android:src="@drawable/emoticon_sad">

    </ImageButton>

    <ImageButton
        android:id="@+id/ibGoodService"
        android:layout_width="16dp"
        android:layout_height="match_parent"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:backgroundTint="@color/colorBlue"
        android:src="@drawable/emoticon_happy">

    </ImageButton>

    <ImageButton
        android:id="@+id/ibExcellentService"
        android:layout_width="16dp"
        android:layout_height="match_parent"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:backgroundTint="@color/colorBlue"
        android:src="@drawable/emoticon">

    </ImageButton>

</LinearLayout>

<android.support.constraint.Constraints
    android:id="@+id/constraints"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toTopOf="parent"
    app:layout_constraintEnd_toStartOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<android.support.constraint.Guideline
    android:id="@+id/guideline2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_begin="16dp" />

<View
    android:id="@+id/vSeprator2"
    android:layout_width="0dp"
    android:layout_height="1dp"
    android:layout_marginStart="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginBottom="16dp"
    android:background="@color/colorGray"
    app:layout_constraintBottom_toTopOf="@+id/tvServiceText"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/llRatingButtons"
    app:layout_constraintVertical_bias="0.0" />

<TextView
    android:id="@+id/tvServiceText"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="56dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:text="@string/main.msg.servicerating"
    android:textAppearance="?android:textAppearanceMedium"
    android:textColor="@color/colorWhite"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.028"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/llRatingButtons" />

<LinearLayout
    android:id="@+id/linearLayout"
    android:layout_width="0dp"
    android:layout_height="80dp"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:divider="?android:horizontalDivider"
    android:orientation="horizontal"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvServiceText">

    <TextView
        android:id="@+id/tvTipPercent"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:gravity="center"
        android:text="@string/main.msg.tippercent"
        android:textColor="@color/colorWhite" />

    <TextView
        android:id="@+id/tvTipTotal"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:gravity="center"
        android:text="@string/main.msg.tiptotal"
        android:textColor="@color/colorWhite" />
</LinearLayout>

<TextView
    android:id="@+id/tvBillAmountText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginBottom="16dp"
    android:text="@string/main.msg.billtotal"
    android:textAppearance="?android:textAppearanceMedium"
    android:textColor="@color/colorWhite"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent" />

<TextView
    android:id="@+id/tvBillAmountResult"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginBottom="16dp"
    android:text="@string/main.msg.billtotalresult"
    android:textAppearance="?android:textAppearanceLarge"
    android:textColor="@color/colorWhite"
    app:layout_constraintBottom_toTopOf="@+id/tvBillAmountText"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/linearLayout"
    app:layout_constraintVertical_bias="1.0" />

 </android.support.constraint.ConstraintLayout>

XML design

0 个答案:

没有答案