• Home
  • About Us
  • Amazon Affiliate Disclaimer
    • Cookie Policy
    • Terms of Use
  • tech and gaming
  • World Tech
  • Sitemap

goto11.net

Tech gear reviews and guide

  • Home
  • About Us
  • Amazon Affiliate Disclaimer
    • Cookie Policy
    • Terms of Use
  • tech and gaming
  • World Tech
  • Sitemap

Support library VectorDrawable Resources$NotFoundException –

December 23, 2020 by tuio

Development issue/problem:

I am using the Design Support Library version 23.4.0. I lit the flag on the Gradel:

defaultConfig {
vectorDrawables.useSupportLibrary = true
}

I use version 23.0.2 of the build tools, but I get the exception Resources$NotFound on KitKat or lower.

This happens when I use android:drawableLeft or imageView.setImageResource(R.drawable.drawable_image).

And yes, I use it in every class where I use drawings.

static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

Is this a bug in the support library?

How can I solve this problem?

Solution 1:

It took me three different things to make it work with the 23.4.0 support library:

  1. Add this to build.gradle

defaultConfig {
vectorDrawables.useSupportLibrary = true
}

  1. Add the following to the OnCreate section of your application class

AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) ;

(Reference to this link – https://stackoverflow.com/a/45582033/10752962).

In APIs smaller than 21, use this line for setContentView() ;

  1. For all XML views in which you define vector view, replace

android:src

с

Application: srcCompatible

and replace it in code:

imageView.setImageResource(…) ;

с

imageView.setImageDrawable(…) ;

Solution 2:

In addition to some of the answers given here: The VectorDrawables backwards compatible media has a price and does not work in all cases.

When does it work? I created this diagram to help (relevant to support the 23.4.0 library up to at least 25.1.0).

VectorDrawable Cheater

Solution 3:

Give it a try:

imageView.setImageDrawable(VectorDrawableCompatible.create(getResources(), drawableRes, null)) ;

This way you do not need to add AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
.

Skip the vector drawings with VectorDrawableCompatible and that’s it.

Solution 4:

We had the same question. Vector drawings were not visible on Kitkat. I have fixed this issue by adding AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) to the onCreate method of the activity.

Don’t forget to add something beforehand:

defaultConfig {
vectorDrawables.useSupportLibrary = true
}

and call setImageResource for the display in which you are using vector display. My opinion is ImageButton. I have tools to create the Android SDK version 23.0.3.

Solution No 5:

Sorry for the delay, but this answer may help users who want to enable AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); flag for all actions.

1. Create a class to be distributed to the application (android.app.Application).

The MyApplicationClass public class extends the
application {
@Override
public void onCreate()
{
super.onCreate();
}
}.

2. Go to Manifest.xml and add the following line

…

3. Add the above onCreate code to MyApplicationClass.java

// This flag must be set to true to enable API support by VectorDrawable.

Full code for MyApplicationClass.java

import android.app.Application;
import android.support.v7.app.AppCompatDelegate ;

/**
*Created by Gaurav Lonkar 12/23/17.
*/

The MyApplicationClass public class extends the
application {
// This flag must be set to true to enable VectorDrawable API support.

Solution No 6:

defaultConfig {
vectorDrawables.useSupportLibrary = true
}

to use it in the app.gradle

Then use the AppCompatibleDrawableManager to set upDrawable and getDrawable. Works for me.

Solution No 7:

The 23.3 support library has disabled support for vector rendering in places like android:drawableLeft. This was announced on Google+ :

We have decided to remove the functionality that allows the use of vector renderings from
sources on pre-Lollipop devices due to issues found during the implementation of version
in version 23.2.0/23.2.1. With app:srcCompat and setImageResource()
still works.

Problem notes :

However, if you can live with these problems, in version 23.4 you can reactivate this function with AppCompatDelegate.setCompatVectorFromResourcesEnabled().

If you’re curious about how it works, it’s best to ask Chris Baines, the author of this feature. He explains it in detail on his blog.

Solution No 8:

Edit

imageView.setImageResource(R.drawable.drawable_image)

at the following address:

imageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.drawable_image)) ;

if you want to use vector in xml, use this :

app:[email protected]/drawable_image

Solution No 9:

I had a similar problem a long time ago, it didn’t work on installation…

vectorDrawables.useSupportLibrary = true

only worked when I created the mipmap folder, and the code I used

imageView.setImageResource (R.mipmap.drawable_image)

More information can be found here

Solution No 10:

Animation API 16
Inflatable drawing strip

The VectorDrawable and AnimatedVectorDrawable from this support library can be discovered in this way:

  • Call the static methods getDrawable() :

// This will make the drawing explode with only the basic element
VectorDrawable.getDrawable(context, R.drawable.ic_arrow_vector) ;

// This will blow up the render with only the root element
AnimatedVectorDrawable.getDrawable(context, R.drawable.ic_arrow_to_menu_animated_vector) ;

// This blows up any drawing and automatically returns to the Lollipop implementation on api 21+ devices
ResourcesCompat.getDrawable(context, R.drawable.any_drawable) ;

It is always recommended to use ResourceCompat.getDrawable() when inflating Java drawable code, as it handles Lollipop folding if necessary. This allows the system to cache the state constant that can be drawn, making it more efficient.
The library has the following morphing animations (bidirectional) :

  • Animation of the Game Break Morph
  • Play the Stop Morph animation
  • Animation of the Morph menu of the Arrow burger

As you can see, I created the image above on my phone using API 16 :

Import com.wnafee.vector.compat.AnimatedVectorDrawable;
mdrawable = (AnimatedVectorDrawable) AnimatedVectorDrawable.getDrawable(this.getApplicationContext(), R.drawable.consolidated_animated_vector) ;

See github’s README file for vector compilation here: https://github.com/wnafee/vector-compat
This will solve your problem (up to API 14) if you merge it with the build.gradle dependencies of your application module (usually at the end of the file):

dependencies [
compile fileTree(dir : ‘libs’, include : [‘*.jar’])
//try FIX Binary XML file line #2 : invalid drawable tag animated-vector
compile ‘com.android.support:appcompat-v7:25.0.0’
compile ‘com.android.support:design:25.0.0’
// no need for
// compile ‘com.android.support: support-vector-drawable: 25.0.0.0
// compile ‘com.wnafee: vector-compatible: 1.0.5’ //*******holy grail *******https://github.com/wnafee/vector-compat
//fail ‘com.android.support: attimated-vector-drawable: 25.0.0
//no need
// compile ‘com.android.support: support-animated-vector-drawable: 25.0.0’
}

Good luck!

Related Tags:

drawable (missing name) with resource id,drawableleft compat not found,android resources$notfoundexception,vectordrawables.usesupportlibrary = true,resource id not found android,no vector content found in android studio,android:drawable resource not found,usecompatloadingfordrawables,vector drawable states,app:srccompat data binding,android drawable v24,android scale vector drawable,how to use svg images in android,fillalpha android,rotate vector drawable android,android vector gradient,vectordrawables generateddensities,android vector drawable pre lollipop,animated-vector requires api 21,android lollipop,contextcompat getdrawable resource not found,com android support animated-vector-drawable,resources notfoundexception: file res/drawable xxhdpi v4,android content res resources notfoundexception vector drawable,android content res resources$notfoundexception drawable,animated vector drawable library

Filed Under: World Tech

About tuio

Recent Posts

  • Logitech Gaming Software User Guide 2021
  • Surface Pro won’t connect to the iPhone’s hotspot
  • Are you sure you want to leave this page?
  • Learn To Use Multiple Apps On Your Windows
  • The 13 Best Cell Phone Companies List in 2021
  • Windows 10 laptop battery drains very fast after update? Apply these tips
  • Best Free and paid parental control apps for iPad 2020
  • Divi by Elegant Themes Review 2020
  • How to boot Apple Mac M1 in Recovery Mode [Definitive Guide]
  • Android: Create a toggle button with image and no text –
  • PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT (in windows 10) –
  • How to Transfer Files Between Two Computers Using LAN Cable
  • Best Remote Cell Phone Spy Software Without Target Phone
  • Best Ways To Tackle Windows 10 Num Lock Issues With Ease
  • Python Machine Learning Third Edition: Book Review

Copyright © 2023 · GoTo11.net