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同步”并打开“项目设置”时,我得到一个红色错误,告诉我我有重复的库引用,并删除未使用的。

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


当前回答

我终于找到了这个问题的原因。

实际上,您应该避免将.idea/libraries文件夹推到存储库中。它在Android Studio中创建了一些奇怪的东西,倾向于删除所有下载的库。

如果您有提交历史,只需重新创建所有丢失的库文件并避免再次提交。否则,只需删除整个。idea文件夹,并重新导入到AS。

其他回答

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.

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

Android Studio 1.3

开放模块设置 单击模块菜单下的模块 在属性选项卡中,将源兼容性和目标兼容性设置为您的java版本。

除此之外我什么都没做,这对我很有用。

通过链接,它对我有用。

1)。从android studio左上方的菜单中选择文件选项。

2)。选择选项:“使缓存无效/重新启动..”它将打开一个对话框。

3)。点击第一个带有选项的按钮:“无效并重新启动”

4)。它将关闭工作室并重新启动。开始项目索引。

它解决了我的问题:

File ->失效缓存/重启->失效并重启

来源: https://www.youtube.com/watch?v=FX_gCTpqhwM

在我的多模块项目中,问题在于“com.android”的版本。支持:appcompat-v7”在模块A是“22.0.0”,但在B -“22.2.0”。 解决方案:确保 1. 模块之间的公共库版本相同。 2. 每个模块编译时都没有任何错误(尝试从CLI构建每个模块)。