proguard 6 beta2 getDeclaredField not found
Java class file shrinker, optimizer, obfuscator, and preverifier
Brought to you by:
guardsquare
Android Project
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.WindowDecorActionBar;
import java.lang.reflect.Field;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
Field showHideAnimationEnabledField = WindowDecorActionBar.class.getDeclaredField("mShowHideAnimationEnabled");
showHideAnimationEnabledField.setAccessible(true);
showHideAnimationEnabledField.setBoolean(getSupportActionBar(), false);
} catch (NoSuchFieldException e) {
// should not happen.
throw new AssertionError(e);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
proguard config
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 1
-allowaccessmodification
-dontpreverify
# The remainder of this file is identical to the non-optimized version
# of the Proguard configuration file (except that the other file has
# flags to turn off optimization).
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-dontwarn android.support.**
-keep class android.support.annotation.Keep
-keep @android.support.annotation.Keep class * {*;}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <init>(...);
}
-keep class android.support.v4.app.Fragment{
*;
}
-keep class android.support.v4.app.FragmentActivity{
*;
}
-keep class android.support.v7.view.ContextThemeWrapper { *; }
-keep class android.support.v7.widget.TintContextWrapper { *; }
-keep class com.meituan.android.hydra.SignatureChecker { *; }
here is build dump
import android.os.Bundle;
import android.support.v7.app.c;
import android.support.v7.app.r;
import java.lang.reflect.Field;
public class MainActivity extends c {
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView((int) R.layout.activity_main);
try {
Field declaredField = r.class.getDeclaredField("mShowHideAnimationEnabled");
declaredField.setAccessible(true);
declaredField.setBoolean(b(), false);
} catch (NoSuchFieldException e) {
throw new AssertionError(e);
} catch (IllegalAccessException e2) {
e2.printStackTrace();
}
}
}
r class not exist mShowHideAnimationEnabled
Thanks for your detailed report. This is a regression indeed. It has now been fixed for the upcoming DexGuard 6.0 beta3.