android - 添加firebase依赖项时无法合并dex
问题描述
我正在尝试将 Firebase 推送通知添加到应用程序。我从一个带有基本活动的新应用程序开始,但遇到错误
首先,我在 gradle build 期间遇到了以下错误
错误:任务“:app:preDebugAndroidTestBuild”执行失败。
与项目“:app”中的依赖项“com.android.support:support-annotations”冲突。应用程序 (26.1.0) 和测试应用程序 (27.1.1) 的已解决版本不同。有关详细信息,请参见https://d.android.com/r/tools/test-apk-dependency-conflicts.html 。然后我在应用程序级别 build.gradle 中添加了依赖项并解决了问题
implementation 'com.android.support:support-annotations:27.1.1'
- 然后我得到了一些与字体相关的错误,这些错误通过
compileSdkVersion 28
从 app gradle build 中的 26更改得到解决 - 然后我按照步骤将 Firebase 添加到我的项目中。gradle 同步工作正常,但是当我尝试在连接的设备中运行应用程序时,它显示错误:
任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败。com.android.builder.dexing.DexArchiveMergerException:无法合并 dex
我尝试了一些解决方案,但没有一个对我有用。
应用级 build.gradle
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.rakesh.firecast"
minSdkVersion 22
targetSdkVersion 26
versionCode 1
versionName "1.0"
multi
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"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.google.firebase:firebase-core:17.0.0'
}
apply plugin: 'com.google.gms.google-services'
项目级 build.gradle
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
请帮我弄清楚并解决这个问题
解决方案
推荐阅读
- sql - 使用 Like 运算符创建内连接
- spring-boot - 在哪种情况下 kubernates pod 会停止工作?
- angular - 自定义 Ag-Grid 状态栏
- android - 反应原生模块:无法解决:com.google.android.exoplayer:exoplayer-core:2.7.3
- amazon-web-services - AWS ALB 粘性 cookie 问题
- c# - 在 C# 脚本中执行 PowerShell cmdlet
- php - Ajax 数据表值未提取到数据表
- javascript - 将 lodash 与 stenciljs 一起使用
- bash - 根据第二个字段值打印行,不使用循环
- rust - Rust 错误代码 E0495 是什么意思?