Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource not found Exception for vector drawables

I am going to run my app on some devices its crashes as logs below:

01-04 16:54:02.206 7466-7466/com.lawnmowers E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.lawnmowers, PID: 7466
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lawnmowers/com.lawnmowers.MapActivityNew}: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f02004f
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
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:2099)
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)
at com.lawnmowers.MapActivityNew.onCreate(MapActivityNew.java:89)
at android.app.Activity.performCreate(Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257) 
at android.app.ActivityThread.access$800(ActivityThread.java:139) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5086) 
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:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
at android.content.res.Resources.loadDrawable(Resources.java:2095)
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) 
at com.lawnmowers.MapActivityNew.onCreate(MapActivityNew.java:89) 
at android.app.Activity.performCreate(Activity.java:5248) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257) 
at android.app.ActivityThread.access$800(ActivityThread.java:139) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5086) 
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:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method) 

As resource not found in AppCompat library something. But I already added all required things in Build.gradle. Please have a ref:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 24
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.lawnmowers"
        minSdkVersion 15
        multiDexEnabled true
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        incremental = true;
        preDexLibraries = false
        javaMaxHeapSize "4g" // 2g should be also OK
    }

}
repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.facebook.android:facebook-android-sdk:4.0.1'
    compile 'com.android.support:design:24.2.0'
    compile 'com.google.android.gms:play-services:10.0.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.android.support:multidex:1.0.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }
}
apply plugin: 'com.google.gms.google-services'

Please suggests any solution for the same.

Thanks in advance.

like image 319
Sanat Pandey Avatar asked Jan 04 '17 11:01

Sanat Pandey


People also ask

How to use vector drawable in android?

To configure your app to use vector support libraries, add the vectorDrawables element to your build. gradle file in the app module. To change drawables at runtime, you can use the setImageResource() method as before.

What is vector drawable?

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.

What is vector asset in android Studio?

Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and Adobe Photoshop Document (PSD) files into your project as vector drawable resources.

How do you install Drawables?

Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import. Figure 3: Select Import Drawables from the dropdown menu.


2 Answers

You need to add abc_vector_test.xml in the drawable folder.

Updated:

You need to use it in AppCompat (activity etc) and moreover more imageView use this tag

app:srcCompat=

instead of

android:src=

hope it solves the problem.

like image 53
Sjd Avatar answered Sep 18 '22 17:09

Sjd


I just had the same problem in Visual Studio / Xamarin and switching off:

  • Use shared runtime
  • use fast deployment
  • use incremental Android packaging system

in the app project options helped in my case.

like image 24
mattus75 Avatar answered Sep 21 '22 17:09

mattus75