简体   繁体   English

android studio中的同步项目失败

[英]Sync project in android studio failed

I'm totally new in android programming and by now just trying to run a "Hello World" program: But I couldn't!我是 android 编程的新手,现在只是尝试运行“Hello World”程序:但我做不到! This is what I've done till now:这是我到目前为止所做的:

Previously I had android-studio-ide-171.4443003-windows installed on my laptop, and I installed all SDK Tools from SDK manager.以前我在我的笔记本电脑上安装了 android-studio-ide-171.4443003-windows,我从 SDK 管理器安装了所有 SDK 工具。 But every time I wanted to sync a project it end up with this error:但是每次我想同步一个项目时都会出现这个错误:

ERROR: Could not find com.android.tools.build:gradle:3.5.0.错误:找不到 com.android.tools.build:gradle:3.5.0。 Searched in the following locations: - file:/C:/Users/Pro/.android/manual-offline-m2/android-gradle-plugin-3.5.0-beta01/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom - file:/C:/Users/Pro/.android/manual-offline-m2/android-gradle-plugin-3.5.0-beta01/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar - file:/C:/Users/Pro/.android/manual-offline-m2/gmaven_stable/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom - file:/C:/Users/Pro/.android/manual-offline-m2/gmaven_stable/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom -在以下位置搜索:-file:/C:/Users/Pro/.android/manual-offline-m2/android-gradle-plugin-3.5.0-beta01/com/android/tools/build/gradle/3.5。 0/gradle-3.5.0.pom - 文件:/C:/Users/Pro/.android/manual-offline-m2/android-gradle-plugin-3.5.0-beta01/com/android/tools/build/gradle /3.5.0/gradle-3.5.0.jar - 文件:/C:/Users/Pro/.android/manual-offline-m2/gmaven_stable/com/android/tools/build/gradle/3.5.0/gradle- 3.5.0.pom - 文件:/C:/Users/Pro/.android/manual-offline-m2/gmaven_stable/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar - Z5E056C500A1C4B6A7110B50D807 ://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom - https://dl.google.com/dl/android /maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.0/gradle -3.5.0.pom - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar Required by: project: Open File https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.jar要求:项目:打开文件

then I updated my android studio to android-studio-ide-191.5791312-windows32, and again it get that error.然后我将我的 android 工作室更新为 android-studio-ide-191.5791312-windows32,再次出现该错误。 so I download android-gradle-plugin-3.5,0-beta01 and gmaven_stable from android developer site and as the site said.所以我从 android 开发者网站下载了 android-gradle-plugin-3.5,0-beta01 和 gmaven_stable ,正如网站所说。 I extracted them and copy the content into [my home directory]\.android\manual-offline-m2, and then restart android studio, but the problem still exist!我把它们解压并复制到[我的主目录]\.android\manual-offline-m2,然后重启android studio,问题依旧存在!

Then I went to Settings > Build, Execution, Deployment > Gradle and checked the "Offline work" and specified the "Service directory path" as "[my home directory]/.android/manual-offline-m2/android-gradle-plugin-3.5.0-beta01" and again tried to sync the project, but sync got new error:然后我转到设置>构建,执行,部署> Gradle并检查“离线工作”并将“服务目录路径”指定为“[我的主目录]/.android/manual-offline-m2/android-gradle-plugin -3.5.0-beta01" 并再次尝试同步项目,但同步出现新错误:

ERROR: No cached version of com.android.tools.build:gradle:3.5.0 available for offline mode.错误:没有 com.android.tools.build:gradle:3.5.0 的缓存版本可用于离线模式。

now I'm totally confused and don't know what should I do to solve this problem.现在我完全糊涂了,不知道该怎么做才能解决这个问题。 If anybody help me I will really appreciate that.如果有人帮助我,我将非常感激。

Open android studio go to your project -> build.gradle -> edit this code打开 android studio go 到您的项目 -> build.gradle -> 编辑此代码

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
}
}

Try lowering your build.gradle version to classpath 'com.android.tools.build:gradle:3.4.2'尝试将 build.gradle 版本降低到类路径 'com.android.tools.build:gradle:3.4.2'

I think your android studio does not support that kind of classpath version.我认为您的 android 工作室不支持那种类路径版本。

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

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