Prime Sinadad
Prime Sinadad

Reputation: 23

How to resolve 'Cannot resolve symbol' in android sdk 28 import statements

In Android Studio 3.1.4, as I'm reading some class definitions from android SDK 28, I observe that many import statements cannot be resolved. For example, the class MediaRecorder.java located at AppData\Local\Android\Sdk\sources\android-28\android\media\MediaRecorder.java has import statement import android.annotation.NonNull where instead it should be this: android.support.annotation.NonNull. Many of the sdk classes have import statements errors like this. What suggestions do you propose? Thank you

Upvotes: 0

Views: 1192

Answers (1)

TheWanderer
TheWanderer

Reputation: 17824

Ignore it.

The @NonNull annotation exists in the framework, but is hidden, meaning it doesn't exist in the SDK. When you look at the source code for MediaRecorder, Android Studio complains that android.annotation.NonNull doesn't exist, because as far as it knows, it doesn't.

@NonNull source: notice it has the @hide tag.

You'll notice that many methods classes and other annotations in the framework's source code are marked red because, like NonNull, they're hidden and don't exist in the SDK.

Upvotes: 1

Related Questions