android.support.v7.app.ActivityCompat not found
It seems the ActivityCompat class is no longer in the android.support.v7.app class. I had to change my import to android.support.v4.app.ActivityCompat. However for AppCompatActivity and AlertDialog I can use v7.
Cannot resolve symbol 'ActivityCompat' and 'content'
You have to use androidx classes:
Add the dependency:
and change your import:
import android.support.v4.app.ActivityCompat -> import androidx.core.app.ActivityCompat
import android.support.v4.content.ContextCompat -> import androidx.core.content.ContextCompat
Also remove in your
build.gradle the support libraries dependencies:
How to fix cannot access ActivityCompat class file for android.support.v4.app.ActivityCompat not found error in android?
If you are not added the support library, please add support library com.android.support:support-v4.
Add the following line to your app/build.gradle file:
replace the YOUR_TARGET_VERSION with your target version,
And rebuild the project.
Cannot resolve symbol AppCompatActivity - Support v7 libraries aren't recognized?
Okay, I fixed it by rebuilding it for doing a ./gradlew clean assemble for the fourth time... Android Studio is a weird thing
ionic capacitor build cannot find symbol android.support.v4.app.ActivityCompat
This can be fixed by running:
npm install jetifier
npx cap sync android
... which changed the import reference from:
Cannot Resolve symbol ActivityCompat
Try Using this,
Can not resolve symbol annotation design ActivityCompat v7
Thanks everyone for the answers.
As it turns out, during project setup time I used the "basic activity" as a template for fast setup. But I later realized in the "basic activity" in newer version of Android Studio uses AndroidX instead of Android Suppor library. And all my code is based on the legacy android library.
In the file
gradle.properties file(located in the base directory of your project same as gradlew), change
If you have all the dependency right and rebuild and cleared cache several times, still the android support library doesn't work. And if you have a newer version of android studio. It's possible that
gradle.properties are wrong.
The Import android.support.v7 cannot be resolved
Go to your project in the navigator, right click on properties.
Go to the Java Build Path tab on the left.
Go to the libraries tab on top.
Click add external jars.
Go to your ADT Bundle folder, go to sdk/extras/android/support/v7/appcompat/libs.
Select the file android-support-v7-appcompat.jar
Go to order and export and check the box next to your new jar.