[英]Failed to resolve: support-compat ONLY FOR :27.1.1
我有一個帶有這個build.gradle
文件的android模塊:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0.0"
}
}
dependencies {
implementation 'com.android.support:support-compat:27.1.1'
}
並且在Gradle同步過程中收到此錯誤:
無法解決:support-compat
我使用的依賴項標識符完全符合https://developer.android.com/topic/libraries/support-library/packages#v4-compat (當我寫這個問題時)。
有趣的是,問題僅適用於版本27.1.1
! 我測試的所有其他版本( 24.2.0
, 26.0.0
, 27.0.0
甚至27.1.0
)都OK。
此外, 我從此版本( 27.1.1
)測試的所有其他支持庫都可以 。 這里列出了它們:
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:gridlayout-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-annotations:27.1.1'
Screanshot:
如果我在app
模塊或library
模塊中插入依賴項,則沒有區別。
我的項目級build.gradle
文件:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
我的gradle-wrapper.properties
文件:
#Wed Jul 18 14:24:51 IRDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
需要在jcenter()
存儲庫之前列出google()
存儲庫。 我可以通過在交換它們的順序重現該問題allprojects
。
檢查您是否將其包含在app gradle文件的存儲庫部分中。
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
嘗試如下:
buildscript {
...
}
allprojects {
repositories {
google()
//use maven repo
mavenCentral()
maven {
url 'https://jitpack.io'
}
jcenter()
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.