我刚刚使用了proguard,但我试图通过反射实例化的类不起作用.
我有一个界面
Algorithm
Run Code Online (Sandbox Code Playgroud)
我通过这样的课程
AlgorithmFactory.SomeClassThatExtendsAlgorithmImpl.class
Run Code Online (Sandbox Code Playgroud)
该类实例化如下
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 …Run Code Online (Sandbox Code Playgroud)