android - 为什么自从我更新 Android Studio 后,我遇到了无法修复的问题?
问题描述
我最近更新了 Android Studio,因为我在构建应用程序时遇到了问题。构建应用程序时出现此错误:
无法获取“ https://www.jitpack.io/com/android/support/support-v4/maven-metadata.xml ”。从服务器收到状态码 401:未授权
在大量无效缓存以及重新启动和重新构建项目之后,错误消失并且工作正常,但是一旦我关闭 Android Studio 并再次打开它,错误就会再次出现。
我在同步 Gradle 文件时也收到此错误:
错误:无法解析“:app@debug/compileClasspath”的依赖关系:无法解析com.android.support:support-v4:22.+。显示详细信息 受影响的模块:app
这是我的构建 Gradle 文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的 Gradle 文件(模块:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.app.myapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.5.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.0'
implementation 'org.nanohttpd:nanohttpd:2.2.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-database:16.1.0'
implementation 'com.google.firebase:firebase-ml-vision:19.0.3'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.melnykov:floatingactionbutton:1.3.0'
implementation 'com.github.vajro:MaterialDesignLibrary:1.6'
implementation 'com.github.devendroid:SquareMenu:1.0.0'
implementation 'org.aviran.cookiebar2:cookiebar2:1.1.1'
//implementation 'com.github.navasmdc:MaterialDesign:1.5@aar' // this was the reason for duplicated value error
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'
}
apply plugin: 'com.google.gms.google-services'
我无法理解出了什么问题。我将不胜感激任何帮助。
解决方案
尝试添加maven { url 'https://maven.google.com' }
和maven { url "https://jitpack.io" } // <-- and try to use this.
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' } // <-- add this.
maven { url "https://jitpack.io" } // <-- and try to use this.
}
}
注意google()
和maven { url 'https://maven.google.com' }
是不同的。
google()
是https://dl.google.com/dl/android/maven2/
。
推荐阅读
- java - Java FX 在 Windows 中工作的 LINUX PC 7.4 RHEL 上不起作用
- python - 带有 sqlalchemy 的 Pandas to_sql:如何为非常大的数据帧加速向 SQL Server 插入行?
- angular - Angular,如何检查 Post 是否完成。ToPromise() 和 subscribe() 不起作用
- python - 使用 Python 进行数据抓取 - 结果为空
- python-3.x - Telethon 有没有办法从聊天中获取消息以及发件人姓名、日期和时间?
- json - InvalidDefinitionException:直接自引用导致循环。尝试将具有成员的类作为 IonValue 序列化为 IonValue
- file - 如何在电子中添加文件资源管理器面板,如 vs 代码
- python - 无法将 .py 文件转换为 .exe 文件
- webstorm - 不要在 Linux 上将 WebStorm 作为 SUDO 启动
- openshift - Jaeger 自动注入的边车无法连接到收集器(?)