【发布时间】:2018-03-01 04:16:35
【问题描述】:
我正在尝试在 View 的画布上为圆圈 (ShapeDrawables) 设置动画。该应用程序的调试版本运行没有问题。但是,发布的版本不显示圆圈或动画。我在 Gradle 中尝试了以下操作
apply plugin: 'com.android.application'
android {
config {
}
}
compileSdkVersion 27
defaultConfig {
applicationId "xxx.xxx.xxx"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.TestInterface.runner.AndroidJUnitRunner"
android.defaultConfig.vectorDrawables.useSupportLibrary true
}
buildTypes {
release {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
jniDebuggable false
}
} }
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:gridlayout-v7:27.0.2'
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2' }
在我的proguard-rules.pro 中有以下标志
-dontobfuscate
-keep class android.support.graphics.drawable.** { *; }
-keep class android.graphics.drawable.** { *; }
-keep class android.animation.** { *; }
我检查了 APK 分析器以确保我的圈子(包装 ShapedDrawable)上的 getter 和 setter 没有被混淆。我什至使用 APK 分析器来生成 proguard 保留规则。
仅运行 Release Build 时,Logcat 显示 W/PropertyValuesHolder: Method getDiameter() with type null not found on target class class xxx.xxx.xxx.CircleAnimator$CirleHolder。但我检查了 APK 分析器,这些都没有被混淆......
添加动画的代码如下:
private void newCircleAnimation(){
int size = circles.size();
ObjectAnimator animator = ObjectAnimator.ofFloat(circles.get(size - newAnimationCount), "diameter", getEndSize());
animator.setDuration(getAnimationDuration());
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
CircleHolder tempCircle = (CircleHolder) ((ObjectAnimator) animation).getTarget();
// Have to check first in case it was removed with reset()
if (circles.contains(tempCircle)){
circles.remove(tempCircle);
}
animationCount--;
}
});
animator.start();
animationCount++;
}
我不确定从调试版本到发布版本还有什么不同。任何帮助将不胜感激。
【问题讨论】:
标签: android android-animation android-drawable android-proguard