vector-compat
vector-compat copied to clipboard
vector-compat with android-gradle 1.4.0-beta1
The current 1.4.0-beta1 release of the android gradle plugin has new features that regard vector drawables (from http://tools.android.com/tech-docs/new-build-system):
PNGs are generated for every vector drawable found in a resource directory that does not specify an API version (or specifies a version lower than 21). This only happens if minSdk is below 21. Densities to use can be set using the new "generatedDensities" property in defaultConfig or per-flavor.
When I use vector-compat in a project together with 1.4.0-beta1, the mergeDebugResources
tasks fails while trying to process the vector drawables:
Generating PNG: [/android-app/app/build/generated/res/pngs/debug/drawable-xxxhdpi/ic_pause_vector.png] from [/android-app/app/build/intermediates/exploded-aar/com.wnafee/vector-compat/1.0.5/res/drawable/ic_pause_vector.xml]
Stacktrace:
Caused by: java.lang.NullPointerException
at com.android.ide.common.vectordrawable.VdParser.parse(VdParser.java:181)
at com.android.ide.common.vectordrawable.VdPreview.getPreviewFromVectorXml(VdPreview.java:249)
at com.android.builder.png.VectorDrawableRenderer.generateFile(VectorDrawableRenderer.java:133)
at com.android.ide.common.res2.MergedResourceWriter$1.call(MergedResourceWriter.java:191)
at com.android.ide.common.res2.MergedResourceWriter$1.call(MergedResourceWriter.java:174)
I can't tell what part in the vector drawable xml causes this.
From what I understand, it shouldn't be necessary to generate the PNGs from these vector drawables since this library contains all the code for backwards compatibility to display them directly. So when placing them in drawable-v21
the gradle plugin would ignore them perhaps?
Now I know 1.4.0 is just a beta release so far and things might change, I just couldn't find a workaround so far to make it work in my project together with vector-compat.
I can't build project with gradle 1.3.1 and build tools 23.0.1:
[ERROR] [org.gradle.BuildExceptionReporter]
[ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
[ERROR] [org.gradle.BuildExceptionReporter]
[ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
[ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:mergeDebugResources'.
[ERROR] [org.gradle.BuildExceptionReporter] > D:\app\build\intermediates\exploded-aar\com.wnafee\vector-compat\1.0.5\res\drawable\ic_arrow_vector.xml: Error: Generating the image failed.
[ERROR] [org.gradle.BuildExceptionReporter]
[ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
[ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeDebugResources'.
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:62)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
[ERROR] [org.gradle.BuildExceptionReporter] Caused by: com.android.build.gradle.tasks.ResourceException: D:\app\build\intermediates\exploded-aar\com.wnafee\vector-compat\1.0.5\res\drawable\ic_arrow_vector.xml: Error: Generating the image failed.
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:164)
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:104)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:243)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:230)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
[ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
[ERROR] [org.gradle.BuildExceptionReporter] ... 14 more
[ERROR] [org.gradle.BuildExceptionReporter] Caused by: D:\app\build\intermediates\exploded-aar\com.wnafee\vector-compat\1.0.5\res\drawable\ic_arrow_vector.xml: Error: Generating the image failed.
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.ide.common.res2.MergeWriter.end(MergeWriter.java:54)
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:129)
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.ide.common.res2.DataMerger.mergeData(DataMerger.java:291)
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.ide.common.res2.ResourceMerger.mergeData(ResourceMerger.java:48)
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:157)
[ERROR] [org.gradle.BuildExceptionReporter] ... 22 more
[ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.RuntimeException: D:\app\build\intermediates\exploded-aar\com.wnafee\vector-compat\1.0.5\res\drawable\ic_arrow_vector.xml: Error: Generating the image failed.
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.ide.common.internal.WaitableExecutor.waitForTasksWithQuickFail(WaitableExecutor.java:117)
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.ide.common.res2.MergeWriter.end(MergeWriter.java:50)
[ERROR] [org.gradle.BuildExceptionReporter] ... 26 more
[ERROR] [org.gradle.BuildExceptionReporter] Caused by: D:\app\build\intermediates\exploded-aar\com.wnafee\vector-compat\1.0.5\res\drawable\ic_arrow_vector.xml: Error: Generating the image failed.
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.ide.common.res2.MergedResourceWriter$1.call(MergedResourceWriter.java:191)
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.ide.common.res2.MergedResourceWriter$1.call(MergedResourceWriter.java:171)
[ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.IllegalStateException: Generating the image failed.
[ERROR] [org.gradle.BuildExceptionReporter] at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.builder.png.VectorDrawableRenderer.generateFile(VectorDrawableRenderer.java:135)
[ERROR] [org.gradle.BuildExceptionReporter] at com.android.ide.common.res2.MergedResourceWriter$1.call(MergedResourceWriter.java:189)
[ERROR] [org.gradle.BuildExceptionReporter] ... 1 more
[ERROR] [org.gradle.BuildExceptionReporter]
i face the same issue. please advise
It seems to compile fine with gradle plugin v1.3.1, not so much with anything above (I tried various 1.4 beta versions upto 1.5.0
Same here with gradle plugin v1.3.1 since I upgraded play-service to 8.3 (don't know if it's related)
....
:app:processStagingGoogleServices
:app:generateStagingResources
:app:mergeStagingResources
>>>>>> DID NOT UNDERSTAND ! "app:vc_fillColor" <<<<
>>>>>> DID NOT UNDERSTAND ! "app:vc_pathData" <<<<
.....
>>>>>> DID NOT UNDERSTAND ! "app:vc_fillColor" <<<<
>>>>>> DID NOT UNDERSTAND ! "app:vc_pathData" <<<<
/app/build/intermediates/exploded-aar/com.wnafee/vector-compat/1.0.5/res/drawable/ic_play_vector.xml: Error: error in parsing "g/"
:app:mergeStagingResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeStagingResources'.
> /app/build/intermediates/exploded-aar/com.wnafee/vector-compat/1.0.5/res/drawable/ic_play_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: 4.493 secs
Xml file parsing seems to crash on <group> </group>
balise.
The file, from the lib:
<?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="90">
<path
android:name="v"
android:fillColor="#000000"
android:pathData="@string/path_play"
app:vc_fillColor="#000000"
app:vc_pathData="@string/path_play"/>
</group>
</vector>
<!-- From: file:/Users/wnafee/code/vector-compat/library/src/main/res/drawable/ic_play_vector.xml -->
I just want to suggest the following discussion: https://groups.google.com/forum/?fromgroups#!topic/adt-dev/Snv3dW2dEM4
Try to add this setup to your configuration to disable vector to png resterizing
generatedDensities = []
e.g.
defaultConfig { applicationId “com.example" minSdkVersion 9 targetSdkVersion 23 versionCode 1 versionName “1.0" generatedDensities = [] }
@bonnyfone i try your solution but if you have png in drawable they won't show up
@bonnyfone your solution solves the the issue but seems to cause other issues. see: https://github.com/wnafee/vector-compat/issues/30#issuecomment-163012205