Cannot Resolve ContextCompat in Android
I had the same issue and this and a few more posts helped me. With Android studio you have multiple Gradle files.
I got my code to work by adding the dependencies section into Gradle (Module : Library) or the file that has "android {" ...
dependencies {
// other stuff here
compile 'com.android.support:support-v4:23.+'
// update the 23.0.0 to latest version available
}
androidx.core.content.ContextCompat
from AndroidX dependency
implementation 'androidx.appcompat:appcompat:1.1.0'
ContextCompat is part of support library v4. Have you added support library 4 to your project?
android.support.v4.content.ContextCompat
You can include support library to your build.gradle file under app folder if you haven't already
dependencies {
// other stuff here
compile 'com.android.support:support-v4:23.0.0'
// update the 23.0.0 to latest version available
}