![](/img/trans.png)
[英]How to solve the error of different version of libraries in build.gradle?
[英]Error with version of libraries inside Build.Gradle
如果我將implementation 'com.google.android.gms:play-services-analytics:16.0.1'
到我的應用程序build.gradle中,則在該行和implementation 'com.android.support:appcompat-v7:27.1.1'
上都遇到錯誤implementation 'com.android.support:appcompat-v7:27.1.1'
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found versions
27.1.1, 26.1.0. Examples include com.android.support:animated-vector-
drawable:27.1.1 and com.android.support:support-media-compat:26.1.0
All gms/firebase libraries must use the exact same version specification
(mixing versions can lead to runtime crashes). Found versions 16.0.1, 16.0.0,
15.0.1. Examples include com.google.android.gms:play-services-
analytics:16.0.1 and com.google.android.gms:play-services-measurement-
base:16.0.0
我怎么解決這個問題?? 我試圖手動編輯庫的版本,但仍然遇到相同的問題。
這是我的Build.Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.domain.app"
minSdkVersion 15
targetSdkVersion 27
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:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.facebook.stetho:stetho:1.4.2'
implementation 'com.google.android.gms:play-services-analytics:16.0.1'
}
在所有Gradle文件(包括導入的項目)中更改庫的版本。 之后, 清理並重建項目 。 如果仍然收到錯誤,請忽略它,因為它不會影響您的應用程序。
您需要將所有Gradle文件的版本更改為相同版本。 這包括您所有的本地庫以及導入的庫。
您必須在所有Gradle文件(包括導入的項目)中更改該庫的版本( com.android.support:design:27.1.1現在是最新版本),然后必須清理並重建該項目。 然后將所有“編譯”一詞替換為“實現”,因為配置“編譯”已過時,並且已被“實現”和“ api”替換。
所有com.android.support庫都必須使用完全相同的版本規范(混合版本可能導致運行時崩潰)。 找到版本27.1.1、26.1.0。 示例包括com.android.support:animated-vector- drawable:27.1.1和com.android.support:support-media-compat:26.1.0
implementation
而不是compile
。 升級您的版本
implementation 'com.google.android.gms:play-services-analytics:12.0.1'
注意
如果出現相同的問題, v7:27.1.1
v7:26.1.0
降級到v7:26.1.0
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.