无法解析符号“支持"(使用 Android Studio,遵循入门指南) [英] Cannot resolve symbol 'support' (using Android Studio, following getting started guide)

查看:42
本文介绍了无法解析符号“支持"(使用 Android Studio,遵循入门指南)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始使用 Android 开发.我遵循了这个入门指南并使用了Android Studio(不是日食).

I am getting started with Android development. I have followed this Getting Started guide and use Android Studio (not eclipse).

我在我的设备上运行了 Hello World,到目前为止一切顺利.但是..

I ran Hello World on my device, so far so good. But..

添加此导入时出现问题:(按照指南的指示)

Problem starts when adding this import: (as instructed by the guide)

import android.support.v4.app.NavUtils;  // cannot resolve symbol 'support'

这行似乎需要它(注释它并自动解析导入不起作用)

Seems its needed by this line (commenting it and auto-resolving the import didnt work)

NavUtils.navigateUpFromSameTask(this);

支持导入是红色下划线,鼠标悬停告诉我无法解析符号'支持'

The support import is red underlined, mouseover tells me Cannot resolve symbol 'support'

构建当然也行不通.我看过类似问题的答案,例如;建议清除缓存并重新启动(尝试过),建议以管理员身份运行 SDK Manager 并更新(尝试过),以及其他一些似乎特定于 Eclipse 的问题/解决方案.

Build wont work either ofcourse. I have seen answers to similar questions such as; suggesting clearing cache and retarting (tried that), suggesting running SDK Manager as Administrator and updating (tried that), and some other problems/solutions that seem eclipse specific.

我是 Android 开发和 IDE 的新手.如何在 Android Studio v0.2.9 中修复此问题?

I am new to Android development and the IDE. How about fixing this in Android Studio v0.2.9 ?

我的 build.gradle 文件的内容

Contents of my build.gradle file

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }
}

dependencies {

    // You must install or update the Support Repository through the SDK manager to use this dependency.
    // The Support Repository (separate from the corresponding library) can be found in the Extras category.
    // compile 'com.android.support:appcompat-v7:18.0.0'
}

推荐答案

像下面这样修改你的 gradle 文件,然后尝试它是否有效.

Modify your gradle file like below and try if it works.

......

    dependencies {
       compile 'com.android.support:support-v4:18.0.0'

        // You must install or update the Support Repository through the SDK manager to use this dependency.
        // The Support Repository (separate from the corresponding library) can be found in the Extras category.
        // compile 'com.android.support:appcompat-v7:18.0.0'
    }

这篇关于无法解析符号“支持"(使用 Android Studio,遵循入门指南)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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