vector-compat icon indicating copy to clipboard operation
vector-compat copied to clipboard

res/drawable/ic_drawer_vector.xml has error in parsing during build

Open Bekilotron opened this issue 9 years ago • 4 comments

This is in android studio 15: build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.foo.bar"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.wnafee:vector-compat:1.0.5'
}

offending file

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:width="48dp"
    android:height="48dp"
    android:viewportWidth="24"
    android:viewportHeight="24"

    app:vc_viewportWidth="24"
    app:vc_viewportHeight="24" >
    <group
        android:name="rotationGroup"
        android:pivotX="12.0"
        android:pivotY="12.0"
        android:rotation="0.0">

        <path
            android:name="v"
            android:fillColor="#000000"
            android:pathData="@string/path_drawer"

            app:vc_fillColor="#000000"
            app:vc_pathData="@string/path_drawer"/>
    </group>
</vector>
<!-- From: file:/Users/wnafee/code/vector-compat/library/src/main/res/drawable/ic_drawer_vector.xml -->

error:

Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources]

Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareComWnafeeVectorCompat105Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
E:\AndroidProjects\androapplication\app\build\intermediates\exploded-aar\com.wnafee\vector-compat\1.0.5\res\drawable\ic_drawer_vector.xml: Error: error in parsing "g/"
:app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> E:\AndroidProjects\androapplication\app\build\intermediates\exploded-aar\com.wnafee\vector-compat\1.0.5\res\drawable\ic_drawer_vector.xml: Error: error in parsing "g/"

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 58.321 secs

Bekilotron avatar Dec 06 '15 20:12 Bekilotron

A workaround for this issue is to disable the auto PNG rasterizing per densities; add the following statement in your build.gradle:

defaultConfig {
    //...
    generatedDensities = []
}

bonnyfone avatar Dec 07 '15 08:12 bonnyfone

After adding:

defaultConfig {
    //...
    generatedDensities = []
}

I am getting this: android.content.res.Resources$NotFoundException: Resource ID for every Vector resource. Any ideas?

Example line where the exception is happening:

VectorDrawable chevronDrawable = VectorDrawable.getDrawable(getContext(), R.drawable.vect_ic_chevron_right);

philote avatar Dec 08 '15 20:12 philote

vectorDrawables.useSupportLibrary = true

alkurop avatar Jun 15 '16 13:06 alkurop

Hi there. :wave:

I'm using Android Studio 2.1.2.

Adding vectorDrawables.useSupportLibrary = true to the defaultConfig { ... } section of my build.gradle file seems to alleviate this problem for me. :smile: Something like:


    defaultConfig {
        //...
        vectorDrawables.useSupportLibrary = true
    } 

Thanks @alkurop for the suggestion. :+1:

joshua-kairu avatar Jul 11 '16 07:07 joshua-kairu