Android Studio 0.4.2工作正常,今天我打开它,几乎所有东西都是红色的,自动完成已经停止工作。我看了一下导入,AS似乎告诉我它找不到android.support。V4(为我提供了删除未使用的导入的选项)。(android.support。V7似乎没问题)。

我尝试过的事情:

重建项目 清理项目 同步Gradle文件 关闭项目,关闭AS,重新启动/重新开放 文件>无效缓存/重启 检查Lint,没有发现任何明显的东西 在SDK管理器中仔细检查所有支持库是否是最新的 检查我的构建。Gradle,虽然没有变化,它和往常一样,它一直工作的方式。

下面是相关信息:

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

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.0'

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.0.0'
    compile 'com.android.support:gridlayout-v7:19.0.0'
    compile 'com.android.support:appcompat-v7:19.0.0'
    compile 'com.google.android.gms:play-services:4.0.30'
    compile project(':libraries:facebook')
    compile files('libs/core.jar')
}

当我点击“与Gradle同步”并打开“项目设置”时,我得到一个红色错误,告诉我我有重复的库引用,并删除未使用的。

我的项目编译和运行良好,但我真的需要自动完成工作!!有人有什么建议吗?


当前回答

Be aware that the name of files and specially folders can result in this error. For instance, if you have a folder "Helpers" and the package for files in this folder is "com.whatever.helpers" it won't result in any compilation error but will cause the Android studio fail to load the symbols in that folder. One typical reason for that is when you name a folder with first capital letter, commit it on Git and later change the folder name to all lower case. The Git system won't recognize the change resulting in a discrepancy between the local and remote repositories that only the new repository clones will be affect by.

其他回答

请检查您的项目路径是否有特殊字符,如!(感叹号)。

在我遇到的一个类似的问题中,这是根本原因——因为许多Java应用程序似乎不容忍这样的特殊字符(例如,从终端执行'gradlew clean'将失败并抛出RunTimeException.)。 网上发布的其他解决方案都对我没有帮助。但是,一旦我把!从路径和做了一个干净的构建,Android Studio神奇地工作。

对我来说,这是build.gradle中的一个“progaard”构建条目。我删除了整个构建部分,然后进行了重新同步,问题解决了。

我也遇到过类似的问题,但我在我的情况下遵循了以下步骤:-

1)在项目内部的。idea文件夹下打开modules.xml。 2).检查相同的iml文件是否有两个条目。 3).删除一个重复的条目并关闭android studio或重新构建gradle文件。

在我的例子中,它起作用了。 希望能有所帮助

我尝试清理项目,然后使缓存无效,这两种方法都不起作用。对我有用的是注释掉构建中的所有依赖项。Gradle (app),然后同步,然后再次取消依赖项的注释,然后再次同步。鲍勃是你的叔叔。

我使用共享首选项,但Android工作室抱怨编辑器符号。然后,我补充道

import android.content.SharedPreferences.Editor;

符号现在很酷。