0

我在一个月前完成了这个游戏,直到今天一切正常。我在线收到错误:

odgovorNormalized = Normalizer.normalize(konResenje, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "");

如果我转到清单文件并将 API 级别更改为任何内容,即使更改为 6,我也不会再收到错误消息。直到我更改代码中的某些内容。

我刚刚记得我今天将项目的编码更改为拉丁文。我不知道这是否与此有关。

直到今天一切正常。

4

1 回答 1

6

The error is picked up by the static code analysis tools. Yes, it will compile, Yes, it will run. Yes, it will crash during runtime on any device with API < 9.

The proper thing to do is switch on the API:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        /* Use Normalizer normally */
    } else {
        /* Fall back on some default behavior */
    }

You can suppress errors like this, but always make sure you've fixed them first:

    @SuppressLint("NewApi")
    public void methodThatUsesNewAPI() {}
于 2013-07-31T21:50:03.190 回答