我在我的应用程序中有以下代码:
public static final boolean DEBUG = true;
public static final boolean REL = !DEBUG;
private static final String DEBUG_OR_RELEASE = (REL) ? "RELEASE_VER" : "DEBUG_VER";
我原以为Java编译器会完全从通过Proguard导出的.apk文件中消除"DEBUG_VER"字符串,但是当我检查.apk文件时,我发现其中有"DEBUG_VER"字符串。
为什么?我错过了什么?我做错了什么?
DEBUG_OR_RELEASE = (REL) ? "DEBUG_VER" : "DEBUG_VER"
无论 REL 是 true 还是 false,都会得到相同的字符串 DEBUG_VER。你有注意到吗? - Ravi BhattDEBUG_OR_RELEASE = (REL) ? "RELEASE_VER" : "DEBUG_VER"
将会把DEBUG_VER赋值给DEBUG_OR_RELEASE字符串。 - Ravi Bhatt