相关疑难解决方法(0)

Android中的Proguard和反射

我刚刚使用了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)

java reflection obfuscation android proguard

34
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

java ×1

obfuscation ×1

proguard ×1

reflection ×1