can't resolve AppCompatActivity

后端 未结 30 1703
星月不相逢
星月不相逢 2020-12-04 17:43

After renaming application package name, Android Studio displayed this error can\'t resolve symbol AppCompatActivity

Things I tried: <

相关标签:
30条回答
  • 2020-12-04 18:26

    Lets get going step by step: first clean project by using

    Build->Clean

    if this doesn't helps then use your second weapon

    File>Invalidate Caches/Restart...

    But the real problem begins when all the above options doesn't works so use your ultimate weapon close project and go to project location directory and delete

    .idea

    You can open your project now again. This worked for me and problem comes most often when you are working with VCS. And this problem is not associated with android component classes but also to the libraries, both shows the same error.

    0 讨论(0)
  • 2020-12-04 18:26

    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-04 18:26

    I tried deleting the .idea folder, Clean Build, Validate Caches / Restart, changing Build Tools vers... None of them worked for me.

    I solved this error with selecting the red underlined codes then pressing Alt+Enter and selecting the Import Class option. It changes the imports to **androidx.core.*******. If you do this to all your red underlined codes your errors should have resolved.

    0 讨论(0)
  • 2020-12-04 18:28

    This usually happens when you open any old project. Open your Build.gradle (app module) file and update the dependencies to the latest version which you can find in any recently created project or create a new project and copy the dependencies. Sync and then clean your project.

    EX: Older versions--> compile 'com.android.support:appcompat-v7:24' Update to latest version--> implementation 'com.android.support:appcompat-v7:28.1.1'

    0 讨论(0)
  • 2020-12-04 18:30

    Deleting the ".idea" folder worked for me. As mentioned above by Vikas Kumar

    Then I using this to fix the "SDK location error"

    0 讨论(0)
  • 2020-12-04 18:30

    If the methods via gradle file / "Invalidate caches" do not work, use this way:

    1. Navigate in your project to the .idea folder
    2. Just Rename the libraries folder
    3. Restart Android Studio. It will recreate the libraries folder and work again.
    0 讨论(0)
提交回复
热议问题