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

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


当前回答

我使用Android Studio 3.1.4,当我从我的开发分支与较低的api目标移动到另一个分支与目标api Oreo时,我遇到了这样的问题。我尝试了第一个解决方案,它是有效的,但它是相当棘手的,而第二个解决方案没有解决问题。

我的解决方案 当问题再次出现时,我试图稍微修改我的应用程序gradle文件,以便AS要求我同步文件,这做到了。然后我删除了更改。

我想“同步项目与Gradle文件”可能也可以,但我自己还没有尝试过

希望能有所帮助

其他回答

你已经列出了大多数会有帮助的事情,但你可以试试:

退出Android Studio 备份你的项目 删除所有的。iml文件和。idea文件夹 重新启动Android Studio并重新导入项目

顺便说一下,您在Project Structure对话框中看到的错误消息大部分都是伪造的。

更新:

Android Studio 0.4.3在金丝雀更新频道中可用,应该有望解决大部分这些问题。可能会有一些挥之不去的问题;如果你在0.4.3中看到它们,请告诉我们,并试着给我们一组可靠的复制步骤,这样我们就可以确保我们已经照顾到所有的代码路径。

我通过删除设置来解决这个问题。Gradle来自我的模块子项目。这是一个有自己设置的Java Gradle项目。Gradle文件,它搞砸了。

感谢这个家伙:https://stackoverflow.com/a/33978721/425238

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

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.

这些方法在Android Studio 0.5.8中都没有帮助。

我的解决方案是删除~/。AndroidStudioPreview目录(Ubuntu)。对不起,我不知道它在其他操作系统的哪里。这个目录存储临时文件和Android Studio设置,所以我错过了所有的设置。但它确实有效!