skip to Main Content

I recently upgraded Android Studio to Arctic Fox | 2020.3.1 Patch 2. Whenever I use this code, it is highlighted as error (red underlines).

cursor.getColumncursor.getString(cursor.getColumnIndex(DataContract.WeightEntry.COLUMN_SYNC_STATUS));

Screenshot of highlighted code:
enter image description here
This is found in all the places where the getColumnIndex() function is used.

However, even if code is highlighted as an error, the compiler shows build success and the code runs fine.

Problem: Due to red underlines, it is causing a bad coding experience. I would like to know if this is a bug or something is wrong with my Android Studio settings. I have tried steps like:

  • Importing project again
  • Invalidating caches and restart
  • Deleting .idea folder to reset settings

2

Answers


  1. This is a known issue, right click and from the context actions select Suppress which will add @SuppressLint("Range") (easiest fix/get-around).

    I find it not feasible in my scenario to add those supresslint annotations when you have around 10-50 columns in a single table.That annotation will repeat a lot many times.

    The @Suppress("Range") can be placed at various levels of scope you can also use Analyze/Inspect Code and edit the profile e.g.

    enter image description here

    To then find the respective code filter on the warning e.g. Range in this case :-

    enter image description here

    Refer to https://developer.android.com/studio/write/lint

    Login or Signup to reply.
  2. Just replace
    cursor.getColumncursor.getString(cursor.getColumnIndex(DataContract.WeightEntry.COLUMN_SYNC_STATUS));

    as
    cursor.getColumncursor.getString(cursor.getColumnIndexOrThrow(DataContract.WeightEntry.COLUMN_SYNC_STATUS));

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search