仅当启用 proguard 时,JSONArray 才不是字符串异常

Gle*_*des 6 obfuscation android json exception proguard

JSONArray.getString(1);其中 ["n​​ame",null] 是 json 数组,JSONArray[1] not a string只有在启用 proguard 时才会抛出异常。

我在我的 proguard 规则中遗漏了什么吗?

Tam*_*ynh 0

您是否尝试过这些方法:

/**
 * Returns the value at {@code index} if it exists, coercing it if
 * necessary. Returns the empty string if no such value exists.
 */
public String optString(int index)
Run Code Online (Sandbox Code Playgroud)

或者

/**
 * Returns the value at {@code index} if it exists, coercing it if
 * necessary. Returns {@code fallback} if no such value exists.
 */
public String optString(int index, String fallback)
Run Code Online (Sandbox Code Playgroud)

似乎没有返回null字符串