如何将android gradle项目依赖项下载到自定义文件夹?

时间:2014-12-22 08:37:02

标签: android gradle android-sdk-tools

如何将android gradle项目依赖项下载到自定义文件夹?

我无法在Windows下的工作环境中保存或读取我的主文件夹中的* .exe文件(由于安全原因和公司政策)

当我尝试在IDE Android项目中构建或导入时,如何解决gradle抛出的异常?

我尝试将Gradle用户置于家中,但它没有帮助。

Caused by: java.io.FileNotFoundException: \\{my-company-url-for-user-home}\android-sdk-windows\SDK Manager.exe (Access is denied)
    at org.rauschig.jarchivelib.IOUtils.copy(IOUtils.java:50)
    at org.rauschig.jarchivelib.CommonsArchiver.extract(CommonsArchiver.java:83)
    at org.rauschig.jarchivelib.Archiver$extract.call(Unknown Source)
    at com.jakewharton.sdkmanager.internal.SdkDownload.download(SdkDownload.groovy:57)
    at com.jakewharton.sdkmanager.internal.SdkDownload$download$0.call(Unknown Source)
    at com.jakewharton.sdkmanager.internal.Downloader$Real.download(Downloader.groovy:8)
    at com.jakewharton.sdkmanager.internal.Downloader$download.call(Unknown Source)
    at com.jakewharton.sdkmanager.internal.SdkResolver.downloadSdk(SdkResolver.groovy:95)
    at com.jakewharton.sdkmanager.internal.SdkResolver$downloadSdk$1.callCurrent(Unknown Source)
    at com.jakewharton.sdkmanager.internal.SdkResolver.resolve(SdkResolver.groovy:87)
    at com.jakewharton.sdkmanager.internal.SdkResolver$resolve$0.call(Unknown Source)
    at com.jakewharton.sdkmanager.internal.SdkResolver.resolve(SdkResolver.groovy:17)
    at com.jakewharton.sdkmanager.internal.SdkResolver$resolve.call(Unknown Source)
    at com.jakewharton.sdkmanager.SdkManagerPlugin$_apply_closure1.doCall(SdkManagerPlugin.groovy:27)
    at com.jakewharton.sdkmanager.SdkManagerPlugin$_apply_closure1.doCall(SdkManagerPlugin.groovy)
    at com.jakewharton.sdkmanager.SdkManagerPlugin.time(SdkManagerPlugin.groovy:45)
    at com.jakewharton.sdkmanager.SdkManagerPlugin$time$0.callCurrent(Unknown Source)
    at com.jakewharton.sdkmanager.SdkManagerPlugin.apply(SdkManagerPlugin.groovy:26)
    at com.jakewharton.sdkmanager.SdkManagerPlugin.apply(SdkManagerPlugin.groovy)
    at org.gradle.api.internal.plugins.DefaultPluginContainer.providePlugin(DefaultPluginContainer.java:110)
    at org.gradle.api.internal.plugins.DefaultPluginContainer.addPluginInternal(DefaultPluginContainer.java:69)
    at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:35)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:117)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:85)
    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:130)
    at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:41)
    at org.gradle.api.Project$apply$2.call(Unknown Source)
    at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
    at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
    at build_1nbccshuhk647b9aqa26vge5lo.run(C:\Projects\Android\core\build.gradle:1)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
    ... 54 more

2 个答案:

答案 0 :(得分:1)

要收集所有依赖项,您只需“复制”代表所需依赖项的配置。

例如,要复制所有编译时和运行时依赖项,您可以执行以下操作:

task copyToLib(type: Copy) {
    into "$buildDir/output/lib"
    from configurations.runtime
}

您还可以使用gradle.user.home系统属性或--gradle-user-home命令行属性

答案 1 :(得分:0)

我在阅读调试日志时找到了解决方案:

设置ANDROID_HOME环境变量

13:18:32.382 [DEBUG] [com.jakewharton.sdkmanager.internal.SdkResolver] Missing l
ocal.properties.
13:18:32.395 [DEBUG] [com.jakewharton.sdkmanager.internal.SdkResolver] Missing A
NDROID_HOME.
13:18:32.406 [LIFECYCLE] [com.jakewharton.sdkmanager.internal.SdkResolver] Andro
id SDK not found. Downloading...
13:18:32.425 [DEBUG] [com.jakewharton.sdkmanager.internal.SdkDownload] Downloadi
ng SDK from http://dl.google.com/android/android-sdk_r23-windows.zip.