Я только что использовал proguard, но классы, которые я пытаюсь создать через отражение, не работают.
У меня есть интерфейс
Algorithm
Пропускаю такие классы
AlgorithmFactory.SomeClassThatExtendsAlgorithmImpl.class
Класс создается таким образом
public ArrayList<Algorithm> getAlgorithms(Context cnx) {
ArrayList<Algorithm> list = new ArrayList<Algorithm>();
for(Class<? extends Algorithm> alg: algorithms) {
try {
Constructor<? extends Algorithm> c = alg.getConstructor(Context.class);
list.add(c.newInstance(cnx));
} catch (IllegalArgumentException e) {
Log.e(TAG, "IllegalArgumentException", e);
throw new IllegalStateException("There was a problem creating the Algorithm class");
} catch (InvocationTargetException e) {
Log.e(TAG, "InvocationTargetException", e);
throw new IllegalStateException("There was a problem creating the Algorithm class");
} catch (InstantiationException e) {
Log.e(TAG, "InstantiationException", e);
throw new IllegalStateException("There was a problem creating the Algorithm class");
} catch (IllegalAccessException e) {
Log.e(TAG, "IllegalAccessException", e);
throw new IllegalStateException("There was a problem creating the Algorithm class");
} catch (SecurityException e) {
Log.e(TAG, "SecurityException", e);
throw new IllegalStateException("There was a problem creating the Algorithm class");
} catch (NoSuchMethodException e) {
Log.e(TAG, "NoSuchMethodException", e);
throw new IllegalStateException("There was a problem creating the Algorithm class");
}
}
return list;
}
Вот мой proguard.cnf
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
public static *** w(...);
public static *** e(...);
}