解决android studio项目中Failded to sync Gradle project 'XXXX' Cause:failed to find target with hash string 'android-16'问题

时间:2022-09-16 05:16:15

之前在github上通过import module导入一个项目,结果报错,提示找不到sdk相应的版本xx,而我的compileSdkVersion明明写的是23不是xx,查了半天也没解决。最后只好下载了那个版本的sdk。

今天导入SlidingMenu的module的时候,又遇到了这个问题。

 问题:

解决android studio项目中Failded to sync Gradle project 'XXXX'  Cause:failed to find target with hash string 'android-16'问题

解决android studio项目中Failded to sync Gradle project 'XXXX'  Cause:failed to find target with hash string 'android-16'问题

Cause:failed to find target with hash string 'android-16' in: E:\sony\Android\sdk

failed to find Build Tools revision 19.1.0

而build.gradle文件中的版本号明明是23,不是16,版本号对应不起来,

解决android studio项目中Failded to sync Gradle project 'XXXX'  Cause:failed to find target with hash string 'android-16'问题

项目中有不止一个.gradle文件,是不是导入的module也有?果然如此。

解决:

原因是你导入的module也有build.gradle文件,计算机中缺少这个文件中标记的compileSdkVersion为16的sdk。

是导入的module中build.gradle文件的compileSdkVersion和buildToolsVersion版本号的问题,不是app那个module的build.gradle文件中的版本号的问题。

解决android studio项目中Failded to sync Gradle project 'XXXX'  Cause:failed to find target with hash string 'android-16'问题

修改导入的module的build.gradle中的版本号为你已有的sdk版本号即可。