根据《第一行代码 第2版》编写BroadcastPractice时,出现如下报错:
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not download annotation.jar (androidx.annotation:annotation:1.0.2)
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download annotation.jar (androidx.annotation:annotation:1.0.2)
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download annotation.jar (androidx.annotation:annotation:1.0.2)
Show Details
Affected Modules: app
app图标显示叉号(app配置有问题)
软件:Android Studio 3.5
尝试更改过依赖为 implementation 'androidx.appcompat:appcompat:+',更换网络,换成国内源等方法,一直出现同样的报错。
无报错即可。
修改gradle script下的build.gradle文件为以下内容
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven{ url 'https://maven.aliyun.com/repository/google'}
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
maven{ url 'https://maven.aliyun.com/repository/public'}
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
jcenter()
//google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
```java
```
1.1.0,1.2.0,1.3.0换个版本试一试
你的整体版本都比较老了,建议都升级到最新版。最近网络屏蔽的厉害,很多外网都无法访问,有条件的可以翻一翻,没条件的试一试阿里云的仓库。