AS环境配置踩坑经历

遇到的bug

Unable to resolve dependency for ':app@debug/compileClasspath'

这是由于配置文件的依赖是通过Google下载的,然而该下载被墙了!
[解决办法]:

在整个工程的build.gradle中添加以下框内代码:

1
2
3
4
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
}
maven { url 'http://repo1.maven.org/maven2' }

app下的build.gradle配置如下:

buildToolsVersion 需要和你的sdk安装目录 ~\sdk\build-tools文件里面已有的版本对应

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.administrator.myapplication"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

implementation ‘com.android.support:appcompat-v7:26.+’ 中v7:26.+表示使用的sdk版本

1
2
3
4
5
6
7
8
9
10
11
12
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.4'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
// androidTestImplementation 'com.android.support.test:runner:1.0.1'
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'


}

若配置后还没解决问题,依然报错

打开 C:/Users/(用户名)/.gradle/gradle.properties
把http代理的配置注释掉,例如:

## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Sep 29 23:37:12 CST 2018

#systemProp.http.proxyHost=mirrors.neusoft.edu.cn
#systemProp.https.proxyPort=80
#systemProp.https.proxyHost=mirrors.neusoft.edu.cn
#systemProp.http.proxyPort=80

More info: 参考该问题的csdn博客


-------------本文结束感谢您的阅读-------------
感谢您的支持,我会继续努力的!
0%