我正在将Facebook SDK用于一个Android项目,并且在将support-v4库编译到我的项目时遇到问题。我得到的错误是:Could not find com.android.support:support-v4:13.0.0
我已经使用SDK安装了Android支持存储库。

令我感到困扰的是,似乎gradle不会尝试使用本地Maven存储库进行查找。在工作机器上运行gradlew.bat assembleDebug --debug时,我得到:

19:01:23.803 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting configuration <PROJECT>.facebook-android-sdk-3.14.1:facebook:unspecified(_debugCompile). 669
19:01:23.803 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Visiting dependency <PROJECT>.facebook-android-sdk-3.14.1:facebook:unspecified(_debugCompile) -> com.android.support:support-v4:13.0.+(dependency: com.android.support#support-v4;13.0.+ {compile=[default]})
19:01:23.804 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver] Attempting to resolve module 'com.android.support:support-v4:13.0.+' using repositories [BintrayJCenter, maven, maven2]

在不工作的计算机上,我得到:
...
23:27:41.642 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver] Attempting to resolve module 'com.android.support:support-v4:20.0.0' using repositories [BintrayJCenter]

其他相关信息:
ANDROID_HOME=C:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk

Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd\;C:\apache-ant-1.9.3-bin\apache-ant-1.9.3\bin\;C:\Program Files\Java\jdk1.7.0_67\bin;C:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\tools;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI\wbin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\PSTools;C:\apache-maven-3.0.3-bin\apache-maven-3.0.3\bin;C:\Program;C:\NUnit-2.6.3\NUnit-2.6.3\bin\

最佳答案

事实证明,ANDROID_HOME路径不正确。我以为是:
ANDROID_HOME=C:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk
但实际上是:
ANDROID_HOME=C:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\tools
一旦我关闭了当前的命令提示符并打开了一个新的提示符,它就可以正常工作。

09-07 23:26