自从我升级了 gradle 包装器版本和构建工具版本后,我在 Android 库项目上运行“gradlew lint”时遇到了问题。
我之前使用的是 gradlew 版本 1.3.0 和 buildToolsVersion 23.0.0,运行 lint 时没有出现任何问题。
升级我的 gradlew 版本和 buildTools 版本后,我在运行“gradlew lint”时开始出现此错误
我使用的是gradlew版本
classpath 'com.android.tools.build:gradle:2.3.3'
然后在我正在使用的 build.gradle (应用程序)上
compileSdkVersion 25
buildToolsVersion '25.0.0'
我的播放服务版本是
compile 'com.google.android.gms:play-services:8.1.0'
根据 lint 结果,这是错误输出
Incompatible Gradle Versions
../../build.gradle: All com.android.support libraries must use
the exact same version specification
(mixing versions can lead to runtime crashes).
Found versions 26.0.0-alpha1, 22.2.0.
Examples include com.android.support:support-compat:26.0.0-alpha1
and com.android.support:appcompat-v7:22.2.0
我有一种直觉,这个问题是由 play-services 和 android buildTools 版本引起的,但我不知道如何修复它。
现在,当我运行“./gradlew -q依赖项应用程序:依赖项--configuration编译”时
我从播放服务部分得到这个
+--- com.google.android.gms:play-services:8.1.0
| +--- com.google.android.gms:play-services-ads:8.1.0
| | +--- com.google.android.gms:play-services-basement:8.1.0
| | | \--- com.android.support:support-v4:22.2.0 -> 26.0.0-alpha1
| | | +--- com.android.support:support-compat:26.0.0-alpha1
| | | | \--- com.android.support:support-annotations:26.0.0-alpha1 -> 23.0.1
| | | +--- com.android.support:support-media-compat:26.0.0-alpha1
| | | | +--- com.android.support:support-annotations:26.0.0-alpha1 -> 23.0.1
| | | | \--- com.android.support:support-compat:26.0.0-alpha1 (*)
| | | +--- com.android.support:support-core-utils:26.0.0-alpha1
| | | | +--- com.android.support:support-annotations:26.0.0-alpha1 -> 23.0.1
| | | | \--- com.android.support:support-compat:26.0.0-alpha1 (*)
| | | +--- com.android.support:support-core-ui:26.0.0-alpha1
| | | | +--- com.android.support:support-annotations:26.0.0-alpha1 -> 23.0.1
| | | | \--- com.android.support:support-compat:26.0.0-alpha1 (*)
| | | \--- com.android.support:support-fragment:26.0.0-alpha1
| | | +--- com.android.support:support-compat:26.0.0-alpha1 (*)
| | | +--- com.android.support:support-core-ui:26.0.0-alpha1 (*)
| | | \--- com.android.support:support-core-utils:26.0.0-alpha1 (*)
注意:我只显示了 play-services 部分,因为这是我从 Lint 结果中看到的,我认为这是唯一有用的部分。
谁能告诉我应该将哪个版本的播放服务与 buildToolsVersion 25 和compileSdkVersion 25 一起使用?
谢谢!
应用程序构建.gradle
import com.android.build.gradle.LibraryPlugin
import org.aspectj.bridge.IMessage
import org.aspectj.bridge.MessageHandler
import org.aspectj.tools.ajc.Main
apply plugin: 'com.android.library'
android {
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
buildConfigField "String", "APP_VERSION", "\"1.0-SNAPSHOT\""
}
release {
buildConfigField "String", "APP_VERSION", "\"1.0-SNAPSHOT\""
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-rules-app.pro'
}
}
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:23.0.1'
}
}
sourceSets {
defaultConfig {
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath 'org.aspectj:aspectjtools:1.8.9'
}
}
repositories {
maven {
url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
}
maven {
url "https://maven.java.net/content/groups/public/"
}
}
apply plugin: 'com.neenbedankt.android-apt'
def dbflow_version = "3.1.1"
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.0.1'
apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}"
compile 'com.github.Raizlabs.DBFlow:dbflow-sqlcipher:3.1.1@aar'
compile 'net.zetetic:android-database-sqlcipher:3.5.1'
compile 'org.xerial:sqlite-jdbc:3.7.2'
compile 'commons-io:commons-io:2.4'
compile 'commons-collections:commons-collections:3.2.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.guava:guava:18.0'
compile 'com.scottyab:aescrypt:0.0.1'
compile([group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.3.2'],
[group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.3.2'],
[group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.3.2'])
compile 'org.aspectj:aspectjrt:1.8.9'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'org.slf4j:slf4j-api:1.7.21'
compile('com.github.tony19:logback-android-classic:1.1.1-6') {
exclude group: 'com.google.android', module: 'android'
}
compile 'com.sun.mail:android-mail:1.5.5'
compile 'com.sun.mail:android-activation:1.5.5'
compile 'org.xwalk:xwalk_core_library:20.50.533.12'
testCompile 'junit:junit:4.12'
testCompile group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '3.9.0'
testCompile 'org.powermock:powermock:1.6.5'
testCompile 'org.powermock:powermock-module-junit4:1.6.5'
testCompile 'org.powermock:powermock-api-mockito:1.6.5'
testCompile 'org.robolectric:robolectric:3.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
}
最佳答案
Found versions 26.0.0-alpha1, 22.2.0. Examples include com.android.support:support-compat:26.0.0-alpha1 and com.android.support:appcompat-v7:22.2.0
您正在使用具有不同版本支持库的库。
特别是,您正在使用 com.android.support:appcompat-v7:22.2.0
和 com.android.support:support-compat:26.0.0-alpha1
。
使用支持库 v.26 和 google play 服务库 v.11.2.0 以特定方式更新到最新版本。
compile 'com.google.android.gms:play-services:8.1.0'
另请记住,support libraries v26 和 google play services v.11.2.0 需要 compileSdkVersion 26
和 google maven 存储库 url“https://maven.google.com”
.
如果您想排除 com.android.support
库,您可以使用:
compile ('com.google.android.gms:play-services:11.2.2'){
exclude group: 'com.android.support'
}
关于安卓 : gradlew lint error "Incompatible Gradle Versions",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46272125/