我的android工作室无法启动一个新的未经编辑的Android应用程序

时间:2016-07-15 09:11:50

标签: android android-studio

我用android studio 2.0创建了一个新的Android应用程序但是无论何时我运行应用程序它都会停止并且android studio一直告诉我"无法启动活动"即使我尝试使用基本活动创建和启动未经编辑的新应用程序,它仍会出现相同的错误。 请问为什么?

我的代码:

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

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

这是xml格式:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.kagcom.myapplication7.MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!" /></RelativeLayout>

和清单:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.kagcom.myapplication7">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

logcat的:

07-15 11:07:00.015 24923-24923 / com.kagcom.myapplicationonthreading E / AndroidRuntime:FATAL EXCEPTION:main

                                                                                 Process: com.kagcom.myapplicationonthreading, PID: 24923
                                                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kagcom.myapplicationonthreading/com.kagcom.myapplicationonthreading.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:2367)
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2419)
                                                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                                     at android.os.Looper.loop(Looper.java:193)
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5323)
                                                                                     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(AppCompatDrawableManager.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.kagcom.myapplicationonthreading.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:2331)
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2419) 
                                                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                                     at android.os.Looper.loop(Looper.java:193) 
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5323) 
                                                                                     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: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
                                                                                     at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
                                                                                     at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
                                                                                     at android.content.res.Resources.loadDrawable(Resources.java:2148)
                                                                                     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(AppCompatDrawableManager.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.kagcom.myapplicationonthreading.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:2331) 
                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2419) 
                                                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342) 
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                                     at android.os.Looper.loop(Looper.java:193) 
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5323) 
                                                                                     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) 

1 个答案:

答案 0 :(得分:1)

将build.gradle更改为 23.0.0代替24.0.0