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
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'
Here is the stack trace of the crash:
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) ...
Am I totally missing something? Or is this already a known issue (I couldn't find anything on Google)? Any help would be appreciated.
Support for vector drawables in places like android:drawableLeftwas disabled in support library 23.3. It was announced on Google+: we’ve decided to remove the functionality which let you use vector drawables from resources on pre-Lollipop devices due to issues found in the implementation in version 23.2.0/23.2.1.
A VectorDrawable is a vector graphic defined in an XML file as a set of points, lines, and curves along with its associated color information. The major advantage of using a vector drawable is image scalability.
There are multiple ways to import the vector drawable into your applications. If you have a vector drawable (XML) directly you can paste them in a drawable folder and set them to the ImageView Initially at the start point of vector drawable if we set vector to an ImageView on pre-Lollipop devices it is used crash.
A vector format is a special kind that defines the image in its file. It’s simply an XML file where the image shape is defined based on which it’s rendered on the screen. It doesn't depend on pixels of the device. So we only use a provide one file for vector assets. Vector assets are more preferable than traditional bitmaps because they are
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With