Vector Drawables标志在支持库上不起作用24+ [英] Vector Drawables flag doesn't work on Support Library 24+

查看:72
本文介绍了Vector Drawables标志在支持库上不起作用24+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,Android Nougat似乎是已发布。因此,我比以往任何时候都更兴奋地为分屏等新功能优化我的应用程序。我想推送针对SDK版本 24 的应用程序版本,以便不通知用户我的应用程序可能无法在分屏模式下使用。但是,这样做意味着我还应该更新支持库的版本 24 。像许多其他人一样,我在更新到支持库的 23.2.0 版本时遇到了问题。但是,我遵循了此答案,它解决了我的问题。现在问题从版本 24.0.0 和支持库开始返回。在所有测试中,我都使用链接答案中所述的gradle标志:

Today, it seems as though Android Nougat was released. Thus, I am more excited than ever to optimize my app for the new features like split-screen. I would like to push a version of my app that targets SDK version 24 so that users aren't notified that my app may not work in split-screen. However, doing so means that I should also update to version 24 of the Support Library. Like many others, I experienced a problem when updating to version 23.2.0 of the Support Library. However, I followed this answer and it fixed my issue. Now the issue is returning as of version 24.0.0 and up of the Support Library. In all of my tests I am using the gradle flag described in the linked answer:

vectorDrawables.useSupportLibrary = true

同样重要的是要注意,这仅发生在Lolliop之前的设备(Kitkat及更低版本)上。棒棒糖和完美的作品。使用以下依赖项时,该标记可以正常工作:

It is also important to note that this is only happening on pre-Lolliop devices (Kitkat and below). Lollipop and up works perfectly. When using the following dependencies, the flag works fine:

compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'

但是使用这些依赖项时,我会崩溃我在使用该标志之前得到的标志:

But when using these dependencies, I get a crash similar to the one I got before using the flag:

compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'

这是崩溃的堆栈跟踪:

FATAL EXCEPTION: main
Process: com.badon.brigham.time, PID: 2070
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.badon.brigham.time/com.badon.brigham.time.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
      at android.app.ActivityThread.access$800(ActivityThread.java:135)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:136)
      at android.app.ActivityThread.main(ActivityThread.java:5017)
      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:779)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
      at dalvik.system.NativeStart.main(Native Method)
    Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f
      at android.content.res.Resources.loadDrawable(Resources.java:2101)
      at android.content.res.Resources.getDrawable(Resources.java:700)
      at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:346)
      at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:194)
      at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:182)
      at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:717)
      at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:187)
      at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
      at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:127)
      at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:147)
      at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:27)
      at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:50)
      at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201)
      at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181)
      at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521)
      at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
      ...

我完全错过了什么吗?还是这已经是一个已知问题(我在Google上找不到任何东西)?任何帮助将不胜感激。

Am I totally missing something? Or is this already a known issue (I couldn't find anything on Google)? Any help would be appreciated.

推荐答案

呃...我讨厌这种情况。您问一个问题,然后几个小时后自己回答。无论如何,似乎我使用的是过时的构建工具版本。我所要做的就是在gradle中更改一行:

Ugh... I hate it when this happens. You ask a question and then answer it yourself a few hours later. Anyways, it appears as though I was using an outdated build tools version. All I had to do was change one line in my gradle:

buildToolsVersion "24.0.1"

这篇关于Vector Drawables标志在支持库上不起作用24+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆