我正在运行安装在公司系统上且已连接到公司代理的Android Studio 3.3。每当我尝试执行Make Project
时,都会出现以下错误:
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-rc02.
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:design:28.0.0-rc02.
我尝试了以下操作:
Settings > Appearance & Behavior > System Settings > HTTP Proxy
中设置主机名(xx.x.x.xxx),端口(8080),登录名和密码,并选中Proxy authentication
。
Check Connection
并输入http://www.google.com时,它向我显示此错误:Problem with connection: Connection reset
。在浏览器(Google Chrome)中输入代理凭据后,我便可以访问此URL。如下所示修改了我的build.gradle
,以解决存储库错误。还选中了Enable embedded Maven repository
下的Settings > Build, Execution, Deployment > Gradle > Android Studio
。
使用KeyStore Explorer将顶级证书添加到Android Embedded JRE的cacerts
文件中。我正在使用与Android Studio捆绑在一起的嵌入式JDK。
gradle-wrapper.properties
文件中。我还尝试在IntelliJ IDEA Community 2018.3.3
上运行http请求代码,并配置相同的代理设置。该代码在我的个人计算机上(在开放网络上)没有错误地运行,但是当我在公司系统(连接到代理)上运行相同的代码时,出现了Connection timed out: connect
错误。
这可能表明问题源自IntelliJ,因为Android Studio是基于IntelliJ的。不能选择在公司系统上切换到开放网络。
注意:我可以从浏览器访问Google's Maven Repository,所以我认为代理服务器不会阻止URL。
与喷气机有关的问题:https://youtrack.jetbrains.com/issue/IDEA-153423
如何解决公司系统的Android Studio上的依赖项错误?
我的主要build.gradle
中的相关代码:
buildscript {
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
allprojects {
repositories {
maven { url "https://maven.google.com"}
mavenLocal()
mavenCentral()
maven { url "http://jcenter.bintray.com"}
google()
jcenter()
}
}
我的应用build.gradle
中的相关代码:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
我的应用gradle-wrapper.properties
中的相关代码:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-4.10.1-all.zip
systemProp.proxySet="true"
systemProp.http.keepAlive="true"
systemProp.http.proxyHost=<xx.x.x.xxx>
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=<username>
systemProp.http.proxyPassword=<password, has $ character in it>
systemProp.https.keepAlive="true"
systemProp.https.proxyHost=<xx.x.x.xxx>
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=<username>
systemProp.https.proxyPassword=<password, has $ character in it>