Android Studio and android.support.v4.app.Fragment: cannot resolve symbol

后端 未结 22 2711
眼角桃花
眼角桃花 2020-12-01 06:03

I am tryng out Android Studio instead of Eclipse. I install it and then start a completely new project and follow the wizard. I add no code of my own.

Then, I right-

相关标签:
22条回答
  • 2020-12-01 06:30

    I found that if you have comments in your build.gradle it may break when you try to add a new support library. So make sure you check your build.gradle and see if it looks alright manually.

    0 讨论(0)
  • 2020-12-01 06:30

    For me the cause of problem was broken class path:

    Library Gradle: com.android.support:support-v4:28.0.0@aar has broken classes path:   
    /Users/YOUR_USER/.gradle/caches/transforms-1/files-1.1/support-v4-28.0.0.aar/0f378acce70d3d38db494e7ae5aa6008/res
    

    So only removing transforms-1 folder and further Gradle Sync helped.

    0 讨论(0)
  • 2020-12-01 06:31

    1> File -> invalidate caches 2> Build-> Rebuild

    its work for me

    0 讨论(0)
  • 2020-12-01 06:32

    enter image description hereI found a shortcut: File - Project Structure - Tab:Dependencies Click on the green + sign, select support-v4 (or any other you need), click OK.

    now go to your gradle file and see that is been added

    0 讨论(0)
  • 2020-12-01 06:32

    To downplay the "magic" of this issue a little bit. You need an Internet connection after you make those changes. If for some reason required libraries cannot by downloaded, instead of giving an appropriate message (like "Failed to fetch libraries") you will simply get the same build error. Was struggling with this for an hour before realizing that my company's VPN blocked the repo.

    0 讨论(0)
  • 2020-12-01 06:35

    I got the same problem since I updated to latest version of Android Studio 0.3.7. So you can try with my stuffs.

    Ensure you have updated to latest version Android Support Repository - 3 Android Support Library - 19

    As your attachment picture above, you did it already. Then adding the following setting to your build.gradle

    dependencies {
        compile 'com.android.support:support-v4:19.0.0'
    }
    

    One more thing: Please make sure your Android SDK is targeting to right SDK folder

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