Android Studio and android.support.v4.app.Fragment

2019-01-13 19:43发布

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 =)

19条回答
趁早两清
2楼-- · 2019-01-13 20:34

Do sth. modification (just to gradle sync) over app level build.gradle and sync. Again, redo what you changed in build.gradle and sync. It should fix your problem.

查看更多
登录 后发表回答