Damaged or missing vector images after starting Proguard

I am working on an application where I use the vector drawing mentioned below

 <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:viewportHeight="100"
android:viewportWidth="100">

<path
    android:name="curve_left_atrium"
    android:pathData="M4,48C4,22.6,24.6,2,50,2"
    android:strokeColor="#eb273f"
    android:strokeWidth="4"
    android:trimPathEnd="0" />
 <path
    android:name="curve_right_atrium"
    android:pathData="M96,48C96,22.6,75.4,2,50,2"
    android:strokeColor="#eb273f"
    android:strokeWidth="4"
    android:trimPathEnd="0" />
   </vector>

This works very well in debug builds, but it broke after running proguard in release builds.

Listed below are the versions of the design libraries and appcompat in the gradle file.

    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'

Compile and build versions

   compileSdkVersion 23
  buildToolsVersion = "23.0.1"

and to support the vector, I did the following in gradle.

   defaultConfig {

    generatedDensities = []

   }

   aaptOptions {
    additionalParameters "--no-version-vectors"
  }

and in proguard for the design and support library I did it

     -dontwarn android.support.v7.**
    -keep class android.support.v7.** { *; }
   -keep interface android.support.v7.** { *; }

  # support design
 -dontwarn android.support.design.**
 -keep class android.support.design.** { *; }
 -keep interface android.support.design.** { *; }
 -keep public class android.support.design.R$* { *; }

 -dontwarn android.support.**

This problem is even open here.

https://code.google.com/p/android/issues/detail?id=209558#makechanges

Any help would be appreciated. Thanks in advance.

+4
source share
3 answers

: -keepattributes LocalVariableTable

+1

, . proguard

-keep class VectorPlay.** { *; }
-keep interface VectorPlay.**
-keep enum VectorPlay.**

. .

0

I added the following code to the dexguard file to fix the problem:

# keep setters in VectorDrawables so that animations can still work.
-keepclassmembers class android.support.graphics.drawable.VectorDrawableCompat$* {
   void set*(***);
   *** get*();
}
-keepresourcexmlattributenames vector/**

(partially copied from https://code.google.com/p/android/issues/detail?id=209558#makechanges )

0
source

All Articles