Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

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

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-click to create a new component, a new Fragment:

enter image description here

and choose a new fragment:

enter image description here

and as soon as I do, I see compile errors:

enter image description here

... so I start googling and find out that I need to install and reference support library 4, and that I do. When I check the build.gradle (whatver that is, new to me coming from Eclipse), I see:

enter image description here

but I change that to

enter image description here

because they said so here. After recompiling and all that, the error is still there. I then reference the .jar-file directly, like this:

enter image description here

and again do recompile yada yada, but that doesnt help either.

This behaviour seems very strange to me. What am I missing here? This is the SDK Manager view:

enter image description here

So, what am I missing? Thanks =)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

DID NOT WORK:

I have already had the following dependency in my build.gradle

implementation 'com.android.support:support-v13:26.0.2'

I have tried all of the following,

  • Invalidate Caches/Restart
  • Sync project with gradle files
  • Clean project
  • Rebuild project
  • gradlew clean

But, none of them worked for me.

SOLUTION:

Finally, I solved it by deleting "/.idea/libraries", and then synced with gradle and built again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...