您好,我的build.gradle
文件有问题:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.dell"
minSdkVersion 19
targetSdkVersion 26
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:design:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-firestore:12.0.1'
implementation 'com.firebaseui:firebase-ui-firestore:3.3.0'
implementation 'hanks.xyz:htextview-library:0.1.5'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Android Studio向我发出此警告:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.0, 26.1.0. Examples include com.android.support:recyclerview-v7:27.1.0 and com.android.support:animated-vector-drawable:26.1.0
有人能帮帮我吗?我不知道该怎么办。我什至尝试将其设置为27版。甚至删除了它,但仍然无法解决我的问题。
我也看到此错误:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
最佳答案
Android Studio警告
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.0, 26.1.0. Examples include com.android.support:recyclerview-v7:27.1.0 and com.android.support:animated-vector-drawable:26.1.0
问题
您的一个依赖项(
com.firebaseui:firebase-ui-firestore:3.3.0
)在com.android.support:recyclerview-v7:27.1.0
上有一个transitive dependency。同时,您在构建文件中手动声明的支持库使用26.1.0
版本。解
将
compileSdkVersion
和targetSdkVersion
更新为27
,并将您的支持库更新为27.1.1
android {
compileSdkVersion 27
defaultConfig {
targetSdkVersion 27
...
}
...
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
...
}
提示(可选)
由于
com.android.support:design
对com.android.support:appcompat-v7
和com.android.support:support-v4
具有传递依赖关系,因此,如果您声明appcompat-v7
依赖关系,则不必手动声明support-v4
或design
依赖关系。
关于android - 使用支持lib依赖性v7:26.1.0时发生Gradle dex问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49806622/