Search code examples
androidvectorproguardandroid-vectordrawablesigned-apk

Android - Signed APK - animated-vector not working


I am facing an issue where I am using the vector drawables along with animated vector drawables. Everything has been working fine and smooth so far on API level 15+.

Today when I was preparing to release an update, I built a Signed APK and did the last round of testing where surprisingly all the vector animations stopped working. I just see plain vector images, but no vector animations that I applied to its path. It is only working on Android M platform. Its not working any other platform, not even Lollipop. All of them were working fine on the dev build, I really don't understand and I am unable to find the possible reason. The only thing that comes to my mind is the proguard-rules.pro file, because that is the only thing that differentiates a signed version of an APK from a dev version. Can someone please throw some light and help me out with this issue. I am really stuck with the release now and unable to find a solution anywhere.

I have used this approach on vectors (its my own answer). And for the vector animations, I have simply written like this

 <animated-vector
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:drawable="@drawable/vector_img"
    tools:ignore="NewApi">
  <target
      android:animation="@anim/slide_up"
      android:name="slab_one"/>
 </animated-vector>

I'm using gradle 1.5.0. This is what some relevant parts of my build.gradle file look like -

    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        multiDexEnabled true
        generatedDensities = []
    }
    aaptOptions {
        additionalParameters "--no-version-vectors"
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:support-vector-drawable:23.4.0'
    compile 'com.android.support:animated-vector-drawable:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
}

Would really appreciate your help. Thanks in advance !


Solution

  • Found the solution. Just had to add a line to proguard.

    -keep class android.support.graphics.drawable.** { *; }
    

    So I was right in guessing that the issue with Signed APK is related to proguard. I'm now able to see the vector animations playing on pre-lollipop devices as well.