二进制XML文件行#1:无效的可绘制标记向量

我有一个在大多数设备上运行完美的应用程序。 但是,每当我尝试在API <21的设备上运行我的应用程序时,我都会遇到FATALexception

这是日志:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aceinteract.sleak/com.aceinteract.sleak.activity.LoginRegisterActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class EditText at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316) at android.app.ActivityThread.access$700(ActivityThread.java:158) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5365) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class EditText at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710) at android.view.LayoutInflater.rInflate(LayoutInflater.java:752) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:846) at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.inflate(LayoutInflater.java:495) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.aceinteract.sleak.activity.LoginRegisterActivity.onCreate(LoginRegisterActivity.kt:21) at android.app.Activity.performCreate(Activity.java:5326) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316) at android.app.ActivityThread.access$700(ActivityThread.java:158) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5365) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method) Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_person_accent_24dp.xml from drawable resource ID #0x7f07006f at android.content.res.Resources.loadDrawable(Resources.java:2842) at android.content.res.TypedArray.getDrawable(TypedArray.java:602) at android.widget.TextView.(TextView.java:1023) at android.widget.EditText.(EditText.java:76) at android.support.v7.widget.AppCompatEditText.(AppCompatEditText.java:64) at android.support.v7.widget.AppCompatEditText.(AppCompatEditText.java:60) at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:112) at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1016) at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1073) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:280) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:681) at android.view.LayoutInflater.rInflate(LayoutInflater.java:752) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:846) at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.inflate(LayoutInflater.java:495) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.aceinteract.sleak.activity.LoginRegisterActivity.onCreate(LoginRegisterActivity.kt:21) at android.app.Activity.performCreate(Activity.java:5326) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316) at android.app.ActivityThread.access$700(ActivityThread.java:158) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5365) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method) Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:917) at android.graphics.drawable.Drawable.createFromXml(Drawable.java:858) at android.content.res.Resources.loadDrawable(Resources.java:2839) at android.content.res.TypedArray.getDrawable(TypedArray.java:602) at android.widget.TextView.(TextView.java:1023) at android.widget.EditText.(EditText.java:76) at android.support.v7.widget.AppCompatEditText.(AppCompatEditText.java:64) at android.support.v7.widget.AppCompatEditText.(AppCompatEditText.java:60) at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:112) at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1016) at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1073) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:280) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:681) at android.view.LayoutInflater.rInflate(LayoutInflater.java:752) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:846) at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) at android.view.LayoutInflater.inflate(LayoutInflater.java:495) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.aceinteract.sleak.activity.LoginRegisterActivity.onCreate(LoginRegisterActivity.kt:21) at android.app.Activity.performCreate(Activity.java:5326) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316) at android.app.ActivityThread.access$700(ActivityThread.java:158) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5365) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method) 

这是布局XML

        

gradle文件:

 apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 27 defaultConfig { applicationId "com.aceinteract.sleak" minSdkVersion 16 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } buildToolsVersion '27.0.2' } androidExtensions { experimental = true } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:27.0.2' implementation 'com.android.support:design:27.0.2' implementation 'com.android.support:customtabs:27.0.2' implementation 'com.android.support:support-vector-drawable:27.0.2' implementation 'com.android.support:support-v4:27.0.2' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:animated-vector-drawable:27.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' implementation 'com.android.support:cardview-v7:27.0.2' implementation 'com.android.support:gridlayout-v7:27.0.2' implementation 'com.android.support:recyclerview-v7:27.0.2' implementation 'com.android.support:design:27.0.2' implementation 'com.android.support:palette-v7:27.0.2' implementation 'com.google.code.gson:gson:2.8.0' implementation 'com.mikhaellopez:circularimageview:3.0.2' implementation 'com.squareup.retrofit2:retrofit:2.3.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0' implementation 'uk.co.chrisjenx:calligraphy:2.2.0' } 

我已经尝试过更改为AppComaptEditText ,但它仍然只是给出了同样的错误。

提前致谢 :)

有关Vector Graphics的 文档说:

Android 4.4(API级别20)及更低版本不支持矢量绘图。

使用支持库,您可以使用属性app:srcCompat向后兼容,但不会为android:drawableRight反向移植。

解决方案是继续使用.PNG文件用于这些情况或尝试通过代码设置它。

Android 4.4(API级别20)及更低版本不支持矢量绘图。

从您的app/buld.gradle删除行vectorDrawables.useSupportLibrary = true

编辑

app/buld.gradle实现也行。 implementation 'com.android.support:appcompat-v7:[version sdk]'