Android - 签名APK - 动画矢量无法正常工作

时间:2016-09-01 18:36:05

标签: android vector proguard android-vectordrawable signed-apk

我遇到的问题是我使用矢量drawables和动画矢量drawables。到目前为止,在API级别15 +上,一切都运行良好和顺畅。

今天当我准备发布更新时,我构建了一个签名的APK并进行了最后一轮测试,令人惊讶的是所有的矢量动画都停止了工作。我只看到普通的矢量图像,但没有应用于其路径的矢量动画。 它仅适用于 Android M 平台。它没有任何其他平台,甚至没有 Lollipop 。 所有这些都在开发版本上工作正常,我真的不明白,我无法找到可能的原因。我唯一想到的就是proguard-rules.pro文件,因为这是区分开发版已签名版本的唯一因素。 有人可以请点亮并帮我解决这个问题。我现在非常坚持发布,无法在任何地方找到解决方案。

我在矢量上使用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>

我正在使用gradle 1.5.0。这就是我的build.gradle文件的某些相关部分 -

    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'
}

真的很感谢你的帮助。提前谢谢!

1 个答案:

答案 0 :(得分:1)

找到解决方案。只需在proguard添加一行。

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

所以我猜错了签名APK的问题与proguard有关。我现在能够看到在棒棒糖前设备上播放的矢量动画。

您也可以在play store上查看我的应用:)

相关问题