简体   繁体   English

Android Studio无法解析Gradle项目

[英]Android Studio Can't resolve Gradle project

When moving to a new computer I have lost a drive and now am using a different file path for my programming assets. 移至新计算机时,我丢失了驱动器,现在正在为编程资产使用其他文件路径。

When I start up one of my previous working projects in Android Studio I run into an issue with Gradle. 当我在Android Studio中启动以前的工作项目之一时,遇到了Gradle的问题。

It reads as follows. 其内容如下。 Gradle 'Timer' project refresh failed: Can't resolve Gradle project. Gradle'Timer'项目刷新失败:无法解析Gradle项目。 Reason: given path (E:\\Media\\Documents\\Dropbox\\Programming\\Android\\AndroidStudioProjects\\Timer\\build.gradle) doesn't point to a file 原因:给定路径(E:\\ Media \\ Documents \\ Dropbox \\ Programming \\ Android \\ AndroidStudioProjects \\ Timer \\ build.gradle)未指向文件

My new gradle path is 'C:\\Programs\\gradle\\gradle-1.6' and when I go to Gradle settings in my project it says that it detects this, however after hitting 'ok' and saving/reloading the project the same error persists. 我的新gradle路径是'C:\\ Programs \\ gradle \\ gradle-1.6',当我在我的项目中进入Gradle设置时,它说它检测到了这个,但是在点击'ok'并保存/重新加载项目之后,同样的错误仍然存​​在。

I have GRADLE_HOME set in the environmental variables. 我在环境变量中设置了GRADLE_HOME。 Other projects that are built on this system work however do give this following error "Could not execute build using Gradle distribution ' http://services.gradle.org/distributions/gradle-1.6-bin.zip '." 但是,基于此系统构建的其他项目确实会出现以下错误:“无法使用Gradle分发执行构建” http://services.gradle.org/distributions/gradle-1.6-bin.zip '。“

Am I missing a configuration step somewhere? 我错过了某处的配置步骤吗?

Thanks 谢谢

I just ran into this problem when moving to a new computer. 移至新计算机时,我只是遇到了这个问题。

What I did was choose to import a project (using build.gradle as import file) rather than open a project. 我所做的是选择导入项目(使用build.gradle作为导入文件)而不是打开项目。 When prompted about gradle information I didn't supply a gradle home but selected to use the gradle wrapper. 当提示有关gradle信息时,我没有提供gradle home,而是选择使用gradle包装器。

Thanks for your suggestion oceansize42, but actually that didn't help me fix my problem as it reoccurred after I restarted Android Studio. 感谢您的建议oceansize42,但实际上这并没有帮助我解决我重新启动Android Studio后重新出现的问题。

After some more searching,I found two files with references back to my old drive. 经过更多搜索后,我找到了两个文件,这些文件的引用可以追溯到我的旧驱动器。

.idea\\workspace.xml and .idea\\gradle.xml .idea \\ workspace.xml和.idea \\ gradle.xml

workspace.xml contained an option "KEY_STORE_PATH" that had an old path. workspace.xml包含一个具有旧路径的选项“ KEY_STORE_PATH”。 gradle.xml contained my issue "externalProjectPath" that was giving me the error. gradle.xml包含我的问题“ externalProjectPath”,这给了我错误。

Changing both of these and then restarting fixed my issue completely. 更改这两个然后重新启动完全解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM