Error: package android.support.annotation Does not exist

I see a lot of posts online, are written half, not specific enough, or do not fit, I tried a lot of myself, finally got the solution.

prerequisite

Android studio 3.5.1 track of

the JDK 1.8 com. The Android. View the build: gradle: 3.5.1 track of migration to the
project androidx

step 1: check to see if build.gradle is configured

search build. If there is a keyword in gradle com. Android. Support: support - annotations
if not, you need to add configuration, the steps as shown in figure

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.android.support:support-annotations:28.0.0"
}

modifier error file

view the file with the error and modify the import package.

import android.support.annotation.IntDef;
import android.support.annotation.WorkerThread;

import androidx.annotation.IntDef;
import androidx.annotation.WorkerThread;

shortcut
Ctrl + Shift + R

import android. Support. The annotation.
with
import androidx. The annotation.

synchronization project Sync


Read More: