Android Studio 和 android.support.v4.app.Fragment:无法解析符号 [英] Android Studio and android.support.v4.app.Fragment: cannot resolve symbol

查看:48
本文介绍了Android Studio 和 android.support.v4.app.Fragment:无法解析符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Android Studio 而不是 Eclipse.我安装它,然后启动一个全新的项目并按照向导进行操作.我没有添加自己的代码.

然后,我右击创建一个新组件,一个新的 Fragment:

并选择一个新片段:

一旦我这样做,我就会看到编译错误:

...所以我开始搜索并发现 这么说.重新编译和所有这些之后,错误仍然存​​在.然后我直接引用 .jar 文件,如下所示:

再次重新编译 yada yada,但这也无济于事.

这种行为对我来说似乎很奇怪.我在这里错过了什么?这是 SDK 管理器视图:

那么,我错过了什么?谢谢 =)

解决方案

此问题的症状通常是从命令行构建工作正常(这意味着您的 build.gradle 文件已设置右上)但您会在 IDE 中遇到语法高亮错误.按照以下步骤解决问题:从通常位于 IDE 顶部的工具栏中单击 工具,然后导航到 Android,然后导航到 同步项目使用 Gradle 文件 按钮.我们意识到 IDE 不能只顾自己而不是强迫您在正确的时间手动同步是不太理想的;我们正在 https://code.google.com 中跟踪这方面的进展/p/android/issues/detail?id=63151

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:

and choose a new fragment:

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

... 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:

but I change that to

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

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:

So, what am I missing? Thanks =)

解决方案

The symptom of this problem is usually that the build works fine from the command line (which means your build.gradle file is set up right) but you get syntax highlighting errors in the IDE. Follow This Steps To Solve The Problem: Click on Tools from the toolbar usually at the top part of your IDE, and then navigate to Android then navigate to Sync Project with Gradle Files button. We realize it's less than ideal that the IDE can't just take care of itself instead of forcing you to manually sync at the right time; we're tracking progress on this in https://code.google.com/p/android/issues/detail?id=63151

这篇关于Android Studio 和 android.support.v4.app.Fragment:无法解析符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆