Android应用无法启动活动componentinfo android.content.res.Resources $ NotFound

时间:2016-08-23 01:00:29

标签: java android android-layout

这是整个logcat堆栈跟踪:

08-23 02:19:52.826  20628-20628/com.example.sham_tech.lastchance E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.sham_tech.lastchance, PID: 20628
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sham_tech.lastchance/com.example.sham_tech.lastchance.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2389)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441)
        at android.app.ActivityThread.access$900(ActivityThread.java:151)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:5345)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at   com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: android.content.res.Resources$NotFoundException: File    res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
        at android.content.res.Resources.loadDrawable(Resources.java:2152)
        at android.content.res.Resources.getDrawable(Resources.java:710)
        at   android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354)
        at   android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
        at   android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawable Manager.java:181)
         at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689)
        at   android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
        at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:  77)
        at android.support.v7.app.AppCompatDelegateImplBase.<init>  (AppCompatDelegateImplBase.java:83)
        at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146)
        at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28)
        at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41)
        at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
        at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
        at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
        at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
        at 
com.example.sham_tech.lastchance.MainActivity.onCreate(MainActivity.java:16)
        at android.app.Activity.performCreate(Activity.java:5343)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
        at   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)        

我无法理解问题是什么!。

她是activity_main.xml

  <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
tools:context=".MainActivity"
android:orientation="vertical">

<TextView android:text="Quantity"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="16dp"
    />

<TextView
    android:id="@+id/quantity_text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="0"
    android:layout_marginBottom="16dp"
    />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button"
    android:onClick="SubmitOrder"
    />

</LinearLayout>

代码有什么问题吗?

MainActivity.java

package com.example.sham_tech.lastchance;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

/**
 * This app displays an order form to order coffee.
 */
public class MainActivity extends AppCompatActivity {

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

/**
 * This method is called when the order button is clicked.
 */
public void submitOrder(View view) {
    display(1);
}

/**
 * This method displays the given quantity value on the screen.
 */
private void display(int number) {
    TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
    quantityTextView.setText("" + number);
}
}

我试图解决它超过4天而且没有结果。请帮我 !。谢谢先进

2 个答案:

答案 0 :(得分:1)

问题是它正在你的res / drawable /目录中寻找一个名为“abc_ic_ab_back_material.xml”的文件而它找不到它。确保您在该位置拥有该文件。

答案 1 :(得分:0)

您在此处粘贴的代码未引用

abc_ic_ab_back_material
  1. 如果您在其他代码中使用过它,那么查找 res / drawable / 下的名为 abc_ic_ab_back_material 的资源,如果找不到,只需获取一个。
  2. 如果你没有在任何地方使用它,只需清理你投射并重建