Cannot resolve symbol AppCompatActivity - Support v7 libraries aren't recognized?

后端 未结 25 1485
情深已故
情深已故 2020-12-07 18:39

I\'m trying to figure out why the heck my Android studio isn\'t recognizing the AppCompat v7 library correctly. The import statement below shows up as gray and says there\'s

相关标签:
25条回答
  • 2020-12-07 18:49

    1.Delete the .idea folder
    2.Close and reopen the project
    3.File - > Sync Project With Gradle Files

    This worked for me

    0 讨论(0)
  • 2020-12-07 18:49

    The issue could be import reference,
    try changing it. From:

    import android.support.v7.app.AppCompatActivity;
    


    To:

    import androidx.appcompat.app.AppCompatActivity;
    
    0 讨论(0)
  • 2020-12-07 18:49

    I just commented it and used androidx and now it's working all good!

    import androidx.appcompat.app.AppCompatActivity;
    // import android.support.v7.app.AppCompatActivity;
    
    0 讨论(0)
  • Okay, I fixed it by rebuilding it for doing a ./gradlew clean assemble for the fourth time... Android Studio is a weird thing

    0 讨论(0)
  • 2020-12-07 18:52

    If the given solutions does not work, create a new project with 'KOTLIN' as the language even if your work is on java. Then replace the 'main' folder of the new project with the 'main' folder of the old.

    0 讨论(0)
  • 2020-12-07 18:53

    If you have already tried

    1. Invalidating caches and restarting
    2. Cleaning/rebuilding the project
    3. ./gradlew clean assemble
    4. added implementation
      "com.android.support:support-v4:23.1.1"
      "com.android.support:appcompat-v7:23.1.1"
      "com.android.support:support-annotations:23.1.1"
    5. Corrected import to android.support.v7.app.AppCompatActivity;
    6. Corrected any existing androidx imports

    Still facing issue then please read below

    Finally found the solution

    I tried everything mentioned in all the answers and failed.

    Go to gradle.properties make these flags false

    android.useAndroidX=false

    //Automatically convert third-party libraries to use AndroidX

    android.enableJetifier=false

    The above flags were

    "true ,for me and hence gradle won't download v7 components"

    0 讨论(0)
提交回复
热议问题