2016-09-19 110 views
1

我知道這個問題已被問了幾次,但沒有人的答案幫助了我。 只有當我在Android 4.4.2上運行我的應用程序時纔會出現此錯誤,而不是在Android 5或更高版本上運行時出現此錯誤。錯誤在Android 4.4.2中膨脹類android.support.v7.widget.Toolbar 4.4.2

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

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

清單:

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

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/budget" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme" > 
     android:largeHeap="true" 
     <activity android:name=".MainActivity" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <provider 
        android:name=".data.NoteContentProvider" 
        android:authorities="com.okason.simplenotesapp.data.provider" 
        android:exported="false" 
        android:multiprocess="true" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity android:name=".Addition" > 
     </activity> 
    </application> 

</manifest> 

編輯:

App.gradle文件:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "com.gmail.saadbnwhd.mybudget" 
     minSdkVersion 19 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    // compile 'com.android.support:appcompat-v7:23.2.0' 
    compile "com.android.support:support-core-utils:24.2.0" 
    compile 'com.android.support:support-v4:24.2.0' 
    compile 'com.android.support:design:24.2.0' 
    compile 'com.android.support:appcompat-v7:24.2.0' 
    // compile 'com.mobilesiri.sqliteexample' 
} 

logcat的:

09-20 11:52:12.576 24023-24023/? E/cutils-trace: Error opening trace file: No such file or directory (2) 
09-20 11:52:12.756 24023-24023/? E/memtrack: Couldn't load memtrack module (No such file or directory) 
09-20 11:52:12.756 24023-24023/? E/android.os.Debug: failed to load memtrack module: -2 
09-20 11:52:12.848 24023-24033/? E/jdwp: jdwp::setsockopt(SO_SNDTIMEO) 
09-20 11:52:12.848 24023-24033/? E/jdwp: jdwp::setsockopt(SO_RCVTIMEO) 
09-20 11:52:13.373 24038-24038/? E/cutils-trace: Error opening trace file: No such file or directory (2) 
09-20 11:52:13.540 24038-24038/? E/memtrack: Couldn't load memtrack module (No such file or directory) 
09-20 11:52:13.540 24038-24038/? E/android.os.Debug: failed to load memtrack module: -2 
09-20 11:52:13.637 24038-24044/? E/jdwp: jdwp::setsockopt(SO_SNDTIMEO) 
09-20 11:52:13.637 24038-24044/? E/jdwp: jdwp::setsockopt(SO_RCVTIMEO) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate: Exception while inflating <vector> 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:541) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:478) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:441) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:736) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:359) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:189) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:182) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:717) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:187) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:127) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:147) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:27) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:50) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at com.gmail.saadbnwhd.mybudget.MainActivity.onCreate(MainActivity.java:16) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.app.Activity.performCreate(Activity.java:5343) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.app.ActivityThread.access$900(ActivityThread.java:151) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.os.Handler.dispatchMessage(Handler.java:110) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.os.Looper.loop(Looper.java:193) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at android.app.ActivityThread.main(ActivityThread.java:5345) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at java.lang.reflect.Method.invokeNative(Native Method) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at java.lang.reflect.Method.invoke(Method.java:515) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) 
09-20 11:52:13.751 24048-24048/? E/VdcInflateDelegate:  at dalvik.system.NativeStart.main(Native Method) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime: FATAL EXCEPTION: main 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime: Process: com.gmail.saadbnwhd.mybudget, PID: 24048 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gmail.saadbnwhd.mybudget/com.gmail.saadbnwhd.mybudget.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2389) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.access$900(ActivityThread.java:151) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.os.Handler.dispatchMessage(Handler.java:110) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.os.Looper.loop(Looper.java:193) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.main(ActivityThread.java:5345) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at java.lang.reflect.Method.invokeNative(Native Method) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at java.lang.reflect.Method.invoke(Method.java:515) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at dalvik.system.NativeStart.main(Native Method) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.content.res.Resources.loadDrawable(Resources.java:2152) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.content.res.Resources.getDrawable(Resources.java:710) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:346) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:194) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:182) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:717) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:187) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:127) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:147) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:27) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:50) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at com.gmail.saadbnwhd.mybudget.MainActivity.onCreate(MainActivity.java:16) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.Activity.performCreate(Activity.java:5343) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.access$900(ActivityThread.java:151)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.os.Handler.dispatchMessage(Handler.java:110)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.os.Looper.loop(Looper.java:193)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.main(ActivityThread.java:5345)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at java.lang.reflect.Method.invokeNative(Native Method)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at java.lang.reflect.Method.invoke(Method.java:515)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at dalvik.system.NativeStart.main(Native Method)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime: Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.content.res.Resources.loadDrawable(Resources.java:2148) 
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.content.res.Resources.getDrawable(Resources.java:710)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:346)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:194)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:182)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:717)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:187)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:127)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:147)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:27)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:50)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at com.gmail.saadbnwhd.mybudget.MainActivity.onCreate(MainActivity.java:16)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.Activity.performCreate(Activity.java:5343)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.access$900(ActivityThread.java:151)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.os.Handler.dispatchMessage(Handler.java:110)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.os.Looper.loop(Looper.java:193)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at android.app.ActivityThread.main(ActivityThread.java:5345)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at java.lang.reflect.Method.invokeNative(Native Method)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at java.lang.reflect.Method.invoke(Method.java:515)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)  
09-20 11:52:13.763 24048-24048/? E/AndroidRuntime:  at dalvik.system.NativeStart.main(Native Method)  
+1

發佈您的logcat – Lingeshwaran

+1

工具欄是本機可用於Android 5.0及更高版本的UI元素。使用** Android設計支持庫**在Android 5.0下使用它。 – SripadRaj

+0

謝謝你。 – DivisionSi

回答

1

它已經解決了。我不得不使用升級我的gradle這個插件版本:

classpath 'com.android.tools.build:gradle:1.5.0' 

的問題是與ASSETTAG啄這是造成invalid drawable tag vector。不得不在gradle中添加兩行。

這就是app.gradle的編輯部分。

defaultConfig { 
    applicationId "com.gmail.saadbnwhd.sfas" 
    minSdkVersion 19 
    targetSdkVersion 24 
    versionCode 1 
    versionName "1.0" 
    generatedDensities = [] //Added line 1st 
} 

//Added lines 2nd 
aaptOptions { 
    additionalParameters "--no-version-vectors" 
} 

另外,我不得不更新我的Android SDK,並從SDK管理器中獲得它的'Android Support Library'。

+0

雖然在考慮更新到構建工具24.0.2。 –

+0

是的。謝謝。 – DivisionSi

相關問題