简体   繁体   English

Android Studio:无法同步Gradle项目

[英]Android Studio: Failed to sync Gradle project

Gradle sync failed: Cause: failed to find target with hash string 'android-18' in: C:\\Users\\Android\\sdk Consult IDE log for more details Gradle同步失败:原因:无法在以下位置找到带有哈希字符串'android-18'的目标:C:\\ Users \\ Android \\ sdk有关更多详细信息,请参阅IDE日志。

I am finding this error every time, when importing a project into android studio. 将项目导入android studio时,每次都会发现此错误。

进入Android SDK管理器并为API 18安装平台SDK。或者,进入项目设置并更改目标API和构建工具的版本,使其与您已经安装的版本相同。

I am finding this error every time, when importing a project into android studio. 将项目导入android studio时,每次都会发现此错误。

For addressing this issue, you may want to change SDK level of the imported project to whatever you'd like. 为了解决此问题,您可能需要将导入项目的SDK级别更改为所需的任何值。 (However you should mak sure your chosen SDK level meets features used by the library) (但是,您应该确保所选的SDK级别符合库使用的功能)

For this, you should open build.gradle file of that project and change SDK level there. 为此,您应该打开该项目的build.gradle文件并在那里更改SDK级别。

defaultConfig {
    minSdkVersion 4
    targetSdkVersion /* SDK LEVEL */
}

Another option would be installing SDK level 18 via SDK manager. 另一种选择是通过SDK Manager安装SDK级别18。

For handling this issue, you have to update the gradle version in build.gradle of your project to latest gradle version of your android studio. 为了处理此问题,您必须将项目的build.gradle中的gradle版本更新为android studio的最新gradle版本。 After that if android studio terminal shows any of the following then 1) install the missing platform(s) or 2) install build tools or 3) Fix Gradle wrapper and re-import project do that and sync your project. 之后,如果android studio终端显示以下任内容,则1)安装缺少的平台2)安装构建工具3)修复Gradle包装器并重新导入项目 ,然后执行此操作并同步您的项目。

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

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