无法解决:com.android.support:appcompat-v7:27.+(依赖性错误) [英] Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)
本文介绍了无法解决:com.android.support:appcompat-v7:27.+(依赖性错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Android Studio中遇到此问题.
I am having this issue in Android studio.
Error:Failed to resolve: com.android.support:appcompat-v7:27.+
<a href="install.m2.repo">Install Repository and sync project</a><br><a href="open.dependency.in.project.structure">Show in Project Structure
dialog</a>
我的Android Studio充满错误,Android Studio无法识别库.整个屏幕看起来像这样.
My Android Studio is full of error android studio cannot identify libraries. The whole screen looks like this.
这是我的Gradle
代码:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.example.hp.temp"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.+'
}
推荐答案
找到根build.gradle
文件并在allprojects
标记
repositories {
mavenLocal()
mavenCentral()
maven { // <-- Add this
url 'https://maven.google.com/'
name 'Google'
}
}
最好使用特定版本而不是可变版本
It's better to use specific version instead of variable version
compile 'com.android.support:appcompat-v7:27.0.0'
如果您使用的是适用于Gradle 3.0.0或更高版本的Android插件
repositories {
mavenLocal()
mavenCentral()
google() //---> Add this
}
并以这种方式注入依赖项:
and inject dependency in this way :
implementation 'com.android.support:appcompat-v7:27.0.0'
这篇关于无法解决:com.android.support:appcompat-v7:27.+(依赖性错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文