Android.Support.V7.App.Activitycompat Not Found

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:

implementation "androidx.core:core-ktx:+"

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:

//implementation 'com.android.support:support-compat:+'
//implementation 'com.android.support:appcompat-v7:+'
//implementation 'com.android.support:support-v4:26.1.0'

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.

Steps:

Add the following line to your app/build.gradle file:

implementation 'com.android.support:support-v4:YOUR_TARGET_VERSION'

replace the YOUR_TARGET_VERSION with your target version,
Eg:-

implementation 'com.android.support:appcompat-v7:28.0.0'

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 jetify
npx cap sync android

... which changed the import reference from:

import android.support.v4.app.ActivityCompat;

to:

import androidx.core.app.ActivityCompat;

Reference:
https://forum.ionicframework.com/t/capacitor-cant-build-due-to-androidx-conflicts-at-a-total-loss-on-how-to-fix/185535/16

Cannot Resolve symbol ActivityCompat

Try Using this,

compile 'com.android.support:support-compat:25.0.0'

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

android.useAndroidX=true
android.enableJetifier=true

to

android.useAndroidX=false
android.enableJetifier=false

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

  1. Go to your project in the navigator, right click on properties.

  2. Go to the Java Build Path tab on the left.

  3. Go to the libraries tab on top.

  4. Click add external jars.

  5. Go to your ADT Bundle folder, go to sdk/extras/android/support/v7/appcompat/libs.

  6. Select the file android-support-v7-appcompat.jar

  7. Go to order and export and check the box next to your new jar.

  8. Click ok.



Related Topics



Leave a reply



Submit