Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Fragments Introducing Fragments My First Fragment

Dan Valderrama
Dan Valderrama
137 Points

Cannot resolve symbol 'Nullable'.

When I add onCreateView() in the fragment, Android Studio adds '@androidx.annotation.Nullable' above the function instead of '@Nullable'. How can this be fixed?

1 Answer

Hi Dan. AndroidX is the new version of the support library. But you can still use the "old" one. There seems to be a bug when creating fragments so both annotations are displayed, as you experienced. Here's what you can do:

  • Delete all the @androidx.annotation.Nullable annotations, leaving only the @Nullable one.
  • Do File > Invalidate Caches / Restart

If you create a new fragment in your app, @Nullable will be the only annotation used from now on. Unfortunately, you'd have to do this for all the apps you will create using the "old" support library (until they fix it).

Hope that helps :)