通过proguard让一个Enum类的方法

时间:2014-12-17 20:23:39

标签: java android enums proguard

我在控制台中收到此错误:

 [java] Warning: com.mopub.mraid.PostitialMraidWebViewClient: can't find referenced method 'com.mopub.mraid.MraidJavascriptCommand fromJavascriptString(java.lang.String)' in class com.mopub.mraid.MraidJavascriptCommand

我试图通过proguard让课程和方法,但我没有任何成功。我认为描述它的方法是枚举类中的方法吗?我确实不确定。

这是班级:

package com.mopub.mraid;

import android.support.annotation.NonNull;

public enum MraidJavascriptCommand {
    CLOSE("close"),
    EXPAND("expand") {
        @Override
        boolean requiresClick(@NonNull final PlacementType placementType) {
            return placementType == PlacementType.INLINE;
        }
    },
    USE_CUSTOM_CLOSE("usecustomclose"),
    OPEN("open") {
        @Override
        boolean requiresClick(@NonNull final PlacementType placementType) {
            return true;
        }
    },
    RESIZE("resize") {
        @Override
        boolean requiresClick(@NonNull final PlacementType placementType) {
            return true;
        }
    },
    SET_ORIENTATION_PROPERTIES("setOrientationProperties"),
    PLAY_VIDEO("playVideo") {
        @Override
        boolean requiresClick(@NonNull final PlacementType placementType) {
            return placementType == PlacementType.INLINE;
        }
    },
    STORE_PICTURE("storePicture") {
        @Override
        boolean requiresClick(@NonNull final PlacementType placementType) {
            return true;
        }
    },
    CREATE_CALENDAR_EVENT("createCalendarEvent") {
        @Override
        boolean requiresClick(@NonNull final PlacementType placementType) {
            return true;
        }
    },
    UNSPECIFIED("");

@NonNull private final String mJavascriptString;

MraidJavascriptCommand(@NonNull String javascriptString) {
    mJavascriptString = javascriptString;
}

static MraidJavascriptCommand fromJavascriptString(@NonNull String string) {
    for (MraidJavascriptCommand command : MraidJavascriptCommand.values()) {
        if (command.mJavascriptString.equals(string)) {
            return command;
        }
    }

    return UNSPECIFIED;
}

String toJavascriptString() {
    return mJavascriptString;
}

boolean requiresClick(@NonNull PlacementType placementType) {
    return false;
}
}

我尝试过几种不同的写法,但似乎没有什么对我有用:

 -keep class com.mopub.mraid.MraidJavascriptCommand {
    *;
}

1 个答案:

答案 0 :(得分:0)

您显示的源代码中似乎存在缺少的方法。有可能传递给ProGuard的输入包含该类的较旧编译版本,没有该方法。您应该从干净的构建开始,检查输入,并查看ProGuard日志是否包含有关重复类的任何警告。