Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'android.annotation.NonNull' is not public in 'android.annotation'. Cannot be accessed from outside package

'android.annotation.NonNull' is not public in 'android.annotation'. Cannot be accessed from outside package

I get this warning when I try to list data. Does anyone know why?

like image 723
Onur Nebioğlu Avatar asked Jan 25 '23 03:01

Onur Nebioğlu


1 Answers

You're referring to the Android platform's internal annotations, which aren't the ones you want to use for your own code. For your code, you should import the AndroidX versions of those annotations:

androidx.annotation.NonNull

androidx.annotation.Nullable

etc. (note the extra x in androidx vs android)

You'll also want to make sure you have declared a dependency on androidx.annotation:annotation in your build.gradle (see here for the latest version information)

like image 200
Ryan M Avatar answered Jan 30 '23 05:01

Ryan M