Android程式正在运作,但现在无法运作

时间:2019-05-30 11:28:09

标签: android

我在android studio上遇到错误。在过去的一周中,我一直在做作业,一切都按计划进行。今天,我添加了一些小代码并执行了构建,但是,它强制关闭了应用程序。我尝试运行以前的版本(我确定可以正常运行),并且在logcat中给了我同样的错误。错误是:

2019-05-30 13:10:01.626 28770-28770/? E/Zygote: isWhitelistProcess - 
Process is Whitelisted
2019-05-30 13:10:01.629 28770-28770/? E/Zygote: accessInfo : 1
2019-05-30 13:10:02.768 28770-28770/com.example.myapplication 
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.myapplication, PID: 28770
    java.lang.RuntimeException: Unable to start activity 

ComponentInfo{com.example.myapplication/ 
com.example.myapplication.fingerprint}: 
    android.view.InflateException: Binary XML file line #70: Binary XML 
file 
    line #70: Error inflating class Button
        at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3115)
        at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3258)
        at     

android.app.servertransaction.LaunchActivityItem.execute         
(LaunchActivityItem.ja    va: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:1955)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7073)
        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:964)
     Caused by: android.view.InflateException: Binary XML file line #70: 
Binary XML file line #70: Error inflating class Button
     Caused by: android.view.InflateException: Binary XML file line #70: 
Error inflating class Button
     Caused by: android.content.res.Resources$NotFoundException: Drawable 
android:color/tertiary_text_light with resource ID #0x1060011
      Caused by: android.content.res.Resources$NotFoundException: File 
res/color/tertiary_text_light.xml from drawable resource ID #0x1060011
        at android.content.res.ResourcesImpl.loadDrawableForCookie 
        (ResourcesImpl.java:898)
         at 
android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:677)
        at android.content.res.Resources.loadDrawable(Resources.java:912)
        at 
android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:955)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
        at android.view.View.<init>(View.java:5442)
        at android.widget.TextView.<init>(TextView.java:1118)
        at android.widget.Button.<init>(Button.java:181)
        at android.widget.Button.<init>(Button.java:156)
        at android.support.v7.widget.AppCompatButton.<init>        
        (AppCompatButton.java:71)
        at android.support.v7.widget.AppCompatButton.<init>        
        (AppCompatButton.java:67)
        at android.support.v7.app.AppCompatViewInflater.createButton 
        (AppCompatViewInflater.java:187)
        at android.support.v7.app.AppCompatViewInflater.createView 
        (AppCompatViewInflater.java:110)
        at android.support.v7.app.AppCompatDelegateImpl.createView 
        (AppCompatDelegateImpl.java:1266)
        at android.support.v7.app.AppCompatDelegateImpl.onCreateView 
        (AppCompatDelegateImpl.java:1316)
        at 
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:811)
        at 
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:902)
        at     
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:863)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:554)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:461)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:383)
        at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
    at android.support.v7.app.AppCompatActivity.setContentView 
    (AppCompatActivity.java:140)
        at com.example.myapplication.fingerprint.onCreate 
        (fingerprint.java:58)
        at android.app.Activity.performCreate(Activity.java:7327)
        at android.app.Activity.performCreate(Activity.java:7318)
        at android.app.Instrumentation.callActivityOnCreate 
        (Instrumentation.java:1275)
        at android.app.ActivityThread.performLaunchActivity             
        (ActivityThread.java:3095)
        at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3258)
        at android.app.servertransaction.LaunchActivityItem.execute 
        (LaunchActivityItem.java:78)
2019-05-30 13:10:02.773 28770-28770/com.example.myapplication 
E/AndroidRuntime:     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:1955)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7073)
        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:964)
     Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file 
     line #18: <item> tag requires a 'drawable' attribute or child tag 
     defining a drawable
        at 

     android.graphics.drawable.StateListDrawable.inflateChildElements 
    (StateListDrawable.java:190)
     at 
    android.graphics.drawable.StateListDrawable.inflate 
    (StateListDrawable.java:122)
        at 
android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity 
(DrawableInflater.java:146)
        at android.graphics.drawable.Drawable.createFromXmlInnerForDensity 
(Drawable.java:1359)
        at android.graphics.drawable.Drawable.createFromXmlForDensity 
(Drawable.java:1318)
        at android.content.res.ResourcesImpl.loadDrawableForCooki 
e(ResourcesImpl.java:879)

这是我的布局

<?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:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/darker_gray"
    tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="427dp"
            android:layout_height="wrap_content"
            android:background="@android:color/background_dark"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <TextView
        android:id="@+id/txt_name"
        android:layout_width="169dp"
        android:layout_height="22dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="76dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:text="Enter Name"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.513"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/appBarLayout" />

    <EditText
        android:id="@+id/eT_name"
        android:layout_width="212dp"
        android:layout_height="37dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="12dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.601"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/txt_name" />

    <TextView
        android:id="@+id/txt_surname"
        android:layout_width="169dp"
        android:layout_height="21dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="64dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:text="Enter Surname"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/txt_name" />

    <EditText
        android:id="@+id/eT_surname"
        android:layout_width="212dp"
        android:layout_height="37dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="12dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.601"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/txt_surname" />

    <Button
        android:id="@+id/btn_loadData"
        android:layout_width="172dp"
        android:layout_height="43dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="64dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:text="Load Data"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.506"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/eT_surname" />

    <TextView
        android:id="@+id/txt_savedData"
        android:layout_width="219dp"
        android:layout_height="102dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="132dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />


</android.support.constraint.ConstraintLayout>

1 个答案:

答案 0 :(得分:0)

问题是我将颜色设置为按钮。更改颜色后,它起作用了。我不知道是什么使它不起作用。