简体   繁体   中英

call requires api level 9 (current min is 7) java.text.normalizer#normalize

I finished this game a month ago, and everything worked fine until today. I get error on line:

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

If I go to manifest file and change API level to anything, even to 6, I don't get error anymore. Until I change something in my code.

I've just remembered that I changed encoding of my project to Latin today. I don't know if that has anything to do with this.

Everything worked fine until today.

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() {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM