无法合并 Dex - Android Studio 3.0
Unable to Merge Dex - Android Studio 3.0
当我在稳定频道中将我的 Android Studio 和 运行 项目更新到 3.0 时,我开始收到以下错误。
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我尝试清理并重建项目,但没有成功。任何帮助将不胜感激。
项目级别build.gradle
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用级别build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.med.app"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resConfigs "auto"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//appcompat libraries
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
//butterknife
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//picasso
compile 'com.squareup.picasso:picasso:2.5.2'
//material edittext
compile 'com.rengwuxian.materialedittext:library:2.1.4'
// Retrofit & OkHttp & and OkHttpInterceptor & gson
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
// FirebaseUI for Firebase Auth
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
}
apply plugin: 'com.google.gms.google-services'
我已经尝试了所有给出的答案,但我无法解决这个错误。请帮忙。
我有同样的问题
我把它解决了:
classpath 'com.google.gms:google-services:3.0.0'
在 buildscript->dependencies
build.gradle
在我的文件中我有:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
首先,我按照之前评论中的建议启用了 multidex。
然后,如果错误仍然存在,请打开 Gradle 控制台(单击 "Messages" 部分左侧的 "Show Console Output" 图标)并单击 link 重新编译有 Debug/Info/Stack 个选项。
这将显示有关错误的更多详细信息。
在我的例子中,错误 "Unable to merge dex" 是由重复条目引起的
在 "com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0".
我从我的项目中手动删除了冲突的库并执行了"Rebuild Project"(强制重新加载库)。这解决了问题。
将显式依赖项添加到 play-services-auth
以及您的 firebase-ui-auth
依赖项:
// FirebaseUI for Firebase Auth
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
compile 'com.google.android.gms:play-services-auth:11.4.2'
这是因为 firebase-ui-auth
对 play-services-auth
具有传递依赖性,必须与 play-services-auth
的相应版本一起使用。请参阅 this explanation。
firebase-ui-auth
|--- com.google.firebase:firebase-auth
|--- com.google.android.gms:play-services-auth
Gradle 构建工具的早期版本不包含传递依赖项,因此现在的版本可能会与其他 play-services
版本冲突。
我的问题已得到解释和回答(以防有人想知道)
当您升级到 Android Studio 3.0 并将 gradle 构建工具版本更新到 3.0.0 时,依赖项的编译现在与早期版本不同。
我最近遇到了同样的问题。我正在使用这些依赖项,这些依赖项在 Gradle 2.3.3 版中运行良好:
implementation 'org.apache.httpcomponents:httpmime:4.3.6'
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
升级到gradle-build-version 3.0.0后,出现同样的错误。深入研究,发现httpmime
的传递依赖与文件httpclient-android
冲突,including.
描述
让我详细解释一下。早些时候,在使用 gradle-tool-version 2.3.3 时,我使用 httpclient-android
来获取和使用名为 org.apache.http.entity.ContentType.java
的 class
扩展 org.apache.httpcomponents:httpmime:4.3.6
的传递依赖项表明它有 org.apache.httpcomponents:httpcore:4.3.6
,这是我想使用的同一个包。但是在编译或同步构建时,它排除了 org.apache.http.entity.ContentType.java
所以我需要添加这个依赖关系,其中包括 ContentType.java
:
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
之后一切正常。
将 gradle-build-version 升级到 3.0.0 后,情况发生了变化。它现在包括所有传递依赖项。因此,在使用带有 gradle-build-tool 版本 3.0.0 的最新 Android Studio 进行编译时,我的 ContentType.java
被编译了两次。一次来自 org.apache.httpcomponents:httpcore:4.3.6
(这是 httpmime
的隐式传递依赖),一次来自我之前使用的 org.apache.httpcomponents:httpclient-android:4.3.5.1
。
要解决此问题,我必须删除现有的 org.apache.httpcomponents:httpclient-android:4.3.5.1
依赖项,因为 httpmime
本身会获取我的应用程序所需的相关 class。
针对我的情况的解决方案:仅使用必需的依赖项并删除 httpclient-android
implementation 'org.apache.httpcomponents:httpmime:4.3.6'
请注意,这正是我的情况。您需要深入研究自己的依赖项并相应地应用解决方案。
我有这个错误:
com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex
并最终改回我的 gradle 以解决此问题。
app\build.gradle
android {
compileSdkVersion 25
//buildToolsVersion '26.0.2'
buildToolsVersion '25.0.3'//<< Changed back to old version before my studio 3.0 update
defaultConfig { ....
.\build.gradle
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' //<< Changed back to old version before my studio 3.0 update
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
它并不理想,因为它是回溯约会,但它对我有用,应该让我到达那里,直到发布可能的补丁。
只需将您的类路径更改为:
类路径'com.android.tools.build:gradle:2.3.3'
并同步您的 Gradle。
希望这会有所帮助。
android {
defaultConfig {
multiDexEnabled true
}
}
将此行添加到 :gradle
文件
我完全按照下面截图中的提示进行操作,将 11.0.4 更改为 11.8.0
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.android.gms:play-services:11.8.0'
效果很好
好像这个错误有很多场景。在我的例子中是 1.8 java 编译在 build.gradle
(app):
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
我删除了,错误消失了
检查 build.gradle(应用程序)中的依赖项
如果您使用 2 个(或更多)具有相同名称和不同版本的库。
例如(在我的例子中):
implementation files('src/main/libs/support-v4-24.1.1.jar')
implementation 'com.android.support:support-v4:27.0.2'
删除一个,然后清理并重建。另请注意 dependencies 在 buildscript.
之外
我将下面的版本从 11.6.0 更改为 11.8.0,它起作用了。
compile 'com.google.android.gms:play-services-ads:11.6.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
有时会发生此错误,当相同的 .jar 库文件存在于 "libs" 文件夹中时,同时我们试图通过在 app [=] 中添加行 "compile " 来获取源代码18=] 文件.
其中任何一个,如果我们删除,我们就可以克服这个错误。
希望这对您有所帮助。
"all gsm libraries"
谢谢,它帮助解决了我的问题,但不仅是 gsm 库,而且所有 google 库都必须具有相同的版本。
我有这个 dexing 错误,因为 com.android.support:recyclerview-v7 的版本与 com.android.support:appcompat-v7
不同
Android studio 在 build.gradle 文件中用红色下划线显示这些行。
我在使用 Firebase UI 数据库时遇到了同样的错误。即使在按照其他答案中的建议启用 multiDex 之后,我仍然收到错误消息。然后我开始知道 Firebase UI 和 Firebase 数据库需要与 Firebase UI GitHub 存储库中给出的版本相同。
添加这个你的gradle:实施'com.android.support:multidex:1.0.0'
清理项目然后 rebuild.this 工作
这也可能为时已晚,但我想我也有答案了。根据我最近的尝试,在编译应用程序时,请确保您没有 jar 文件和同一项目中同一包的'implementation'('compile' for 3.0.1 > gradle)
。就我而言,我在同一个项目中有 implementation 'org.jsoup:jsoup:1.11.2'
和 Jsoup
jar。菜鸟错误,但是,我学到了。
对于那些最近仍在为此苦苦挣扎并添加了组件的人。对我造成的是添加:
编译'android.arch.lifecycle:extensions:1.0.0'
注解处理器 'android.arch.lifecycle:compiler:1.0.0'
修复它的原因是将其更新为
编译'android.arch.lifecycle:extensions:1.1.1'
注释处理器 'android.arch.lifecycle:compiler:1.1.1'
希望对您有所帮助。
通过在 build.gradle(应用程序模块)中添加以下代码为我工作
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:support-v4:26.1.0'
}
我认为这是因为不同的库依赖于同一个子库但是版本不同所以排除一个库的依赖性,如:
api (rootProject.ext.dependencies["bindingRecyclerView"]) {
exclude group: 'com.android.support'
}
这是我的gradle项目
android{
编译SDK版本26
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "net.mobilegts.candyjump"
minSdkVersion 14
targetSdkVersion 23
ndk {
moduleName "player_shared"
}
}
sourceSets {
main {
jni.srcDirs = []
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
就我而言,我必须做三件事:
由于我使用的是 firebase,因此请确保 firebase 和 google 播放服务具有相同的 version.Initially 播放服务具有较低版本。
主要是12.0.1版本帮助
在应用级别设置此 build.gradle
android {
multiDexEnabled true
}
再次在应用级别build.gradle,添加
compileOptions{
sourceCompatibility 1.8
targetCompatibility 1.8
}
这个 link 解决了我的问题。
首先,我将 pubspec.yaml 中的依赖项设置为
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.8.2
和 运行 flutter packages get
在我的 IDE 终端。
我还必须更改最低目标 SDK 版本:
- 打开 android/app/build.gradle,然后找到显示以下内容的行
minSdkVersion 16.
- 将该行更改为 minSdkVersion 21。
- 保存文件。
此外,我必须打开 android/app/build.gradle
,然后将以下行添加为文件的最后一行:
apply plugin: 'com.google.gms.google-services'
接下来,我必须打开 android/build.gradle
,然后在 buildscript 标签内,添加一个新的依赖项:
buildscript {
repositories {
// ...
}
dependencies {
// ...
classpath 'com.google.gms:google-services:3.2.1' // new
}
}
在此之后,我的应用程序终于在 android 模拟器上 运行。
如果您遇到困难,link 有更完整的演练。
奇怪的情况,但是 multiDexEnabled
没有帮助我,但是在删除 Gradle 目录并重建应用程序后问题解决了。
当我在稳定频道中将我的 Android Studio 和 运行 项目更新到 3.0 时,我开始收到以下错误。
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我尝试清理并重建项目,但没有成功。任何帮助将不胜感激。
项目级别build.gradle
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用级别build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.med.app"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resConfigs "auto"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//appcompat libraries
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
//butterknife
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//picasso
compile 'com.squareup.picasso:picasso:2.5.2'
//material edittext
compile 'com.rengwuxian.materialedittext:library:2.1.4'
// Retrofit & OkHttp & and OkHttpInterceptor & gson
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
// FirebaseUI for Firebase Auth
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
}
apply plugin: 'com.google.gms.google-services'
我已经尝试了所有给出的答案,但我无法解决这个错误。请帮忙。
我有同样的问题 我把它解决了:
classpath 'com.google.gms:google-services:3.0.0'
在 buildscript->dependencies
build.gradle
在我的文件中我有:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
首先,我按照之前评论中的建议启用了 multidex。
然后,如果错误仍然存在,请打开 Gradle 控制台(单击 "Messages" 部分左侧的 "Show Console Output" 图标)并单击 link 重新编译有 Debug/Info/Stack 个选项。 这将显示有关错误的更多详细信息。
在我的例子中,错误 "Unable to merge dex" 是由重复条目引起的 在 "com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0".
我从我的项目中手动删除了冲突的库并执行了"Rebuild Project"(强制重新加载库)。这解决了问题。
将显式依赖项添加到 play-services-auth
以及您的 firebase-ui-auth
依赖项:
// FirebaseUI for Firebase Auth
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
compile 'com.google.android.gms:play-services-auth:11.4.2'
这是因为 firebase-ui-auth
对 play-services-auth
具有传递依赖性,必须与 play-services-auth
的相应版本一起使用。请参阅 this explanation。
firebase-ui-auth
|--- com.google.firebase:firebase-auth
|--- com.google.android.gms:play-services-auth
Gradle 构建工具的早期版本不包含传递依赖项,因此现在的版本可能会与其他 play-services
版本冲突。
我的问题已得到解释和回答(以防有人想知道)
当您升级到 Android Studio 3.0 并将 gradle 构建工具版本更新到 3.0.0 时,依赖项的编译现在与早期版本不同。
我最近遇到了同样的问题。我正在使用这些依赖项,这些依赖项在 Gradle 2.3.3 版中运行良好:
implementation 'org.apache.httpcomponents:httpmime:4.3.6'
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
升级到gradle-build-version 3.0.0后,出现同样的错误。深入研究,发现httpmime
的传递依赖与文件httpclient-android
冲突,including.
描述
让我详细解释一下。早些时候,在使用 gradle-tool-version 2.3.3 时,我使用 httpclient-android
来获取和使用名为 org.apache.http.entity.ContentType.java
的 class
扩展 org.apache.httpcomponents:httpmime:4.3.6
的传递依赖项表明它有 org.apache.httpcomponents:httpcore:4.3.6
,这是我想使用的同一个包。但是在编译或同步构建时,它排除了 org.apache.http.entity.ContentType.java
所以我需要添加这个依赖关系,其中包括 ContentType.java
:
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
之后一切正常。
将 gradle-build-version 升级到 3.0.0 后,情况发生了变化。它现在包括所有传递依赖项。因此,在使用带有 gradle-build-tool 版本 3.0.0 的最新 Android Studio 进行编译时,我的 ContentType.java
被编译了两次。一次来自 org.apache.httpcomponents:httpcore:4.3.6
(这是 httpmime
的隐式传递依赖),一次来自我之前使用的 org.apache.httpcomponents:httpclient-android:4.3.5.1
。
要解决此问题,我必须删除现有的 org.apache.httpcomponents:httpclient-android:4.3.5.1
依赖项,因为 httpmime
本身会获取我的应用程序所需的相关 class。
针对我的情况的解决方案:仅使用必需的依赖项并删除 httpclient-android
implementation 'org.apache.httpcomponents:httpmime:4.3.6'
请注意,这正是我的情况。您需要深入研究自己的依赖项并相应地应用解决方案。
我有这个错误:
com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex
并最终改回我的 gradle 以解决此问题。
app\build.gradle
android {
compileSdkVersion 25
//buildToolsVersion '26.0.2'
buildToolsVersion '25.0.3'//<< Changed back to old version before my studio 3.0 update
defaultConfig { ....
.\build.gradle
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' //<< Changed back to old version before my studio 3.0 update
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
它并不理想,因为它是回溯约会,但它对我有用,应该让我到达那里,直到发布可能的补丁。
只需将您的类路径更改为:
类路径'com.android.tools.build:gradle:2.3.3'
并同步您的 Gradle。
希望这会有所帮助。
android {
defaultConfig {
multiDexEnabled true
}
}
将此行添加到 :gradle
文件
我完全按照下面截图中的提示进行操作,将 11.0.4 更改为 11.8.0
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.android.gms:play-services:11.8.0'
效果很好
好像这个错误有很多场景。在我的例子中是 1.8 java 编译在 build.gradle
(app):
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
我删除了,错误消失了
检查 build.gradle(应用程序)中的依赖项 如果您使用 2 个(或更多)具有相同名称和不同版本的库。 例如(在我的例子中):
implementation files('src/main/libs/support-v4-24.1.1.jar')
implementation 'com.android.support:support-v4:27.0.2'
删除一个,然后清理并重建。另请注意 dependencies 在 buildscript.
之外我将下面的版本从 11.6.0 更改为 11.8.0,它起作用了。
compile 'com.google.android.gms:play-services-ads:11.6.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
有时会发生此错误,当相同的 .jar 库文件存在于 "libs" 文件夹中时,同时我们试图通过在 app [=] 中添加行 "compile " 来获取源代码18=] 文件.
其中任何一个,如果我们删除,我们就可以克服这个错误。
希望这对您有所帮助。
"all gsm libraries" 谢谢,它帮助解决了我的问题,但不仅是 gsm 库,而且所有 google 库都必须具有相同的版本。 我有这个 dexing 错误,因为 com.android.support:recyclerview-v7 的版本与 com.android.support:appcompat-v7
不同Android studio 在 build.gradle 文件中用红色下划线显示这些行。
我在使用 Firebase UI 数据库时遇到了同样的错误。即使在按照其他答案中的建议启用 multiDex 之后,我仍然收到错误消息。然后我开始知道 Firebase UI 和 Firebase 数据库需要与 Firebase UI GitHub 存储库中给出的版本相同。
添加这个你的gradle:实施'com.android.support:multidex:1.0.0'
清理项目然后 rebuild.this 工作
这也可能为时已晚,但我想我也有答案了。根据我最近的尝试,在编译应用程序时,请确保您没有 jar 文件和同一项目中同一包的'implementation'('compile' for 3.0.1 > gradle)
。就我而言,我在同一个项目中有 implementation 'org.jsoup:jsoup:1.11.2'
和 Jsoup
jar。菜鸟错误,但是,我学到了。
对于那些最近仍在为此苦苦挣扎并添加了组件的人。对我造成的是添加:
编译'android.arch.lifecycle:extensions:1.0.0' 注解处理器 'android.arch.lifecycle:compiler:1.0.0'
修复它的原因是将其更新为
编译'android.arch.lifecycle:extensions:1.1.1' 注释处理器 'android.arch.lifecycle:compiler:1.1.1'
希望对您有所帮助。
通过在 build.gradle(应用程序模块)中添加以下代码为我工作
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:support-v4:26.1.0'
}
我认为这是因为不同的库依赖于同一个子库但是版本不同所以排除一个库的依赖性,如:
api (rootProject.ext.dependencies["bindingRecyclerView"]) {
exclude group: 'com.android.support'
}
这是我的gradle项目
android{ 编译SDK版本26 buildToolsVersion "27.0.3"
defaultConfig {
applicationId "net.mobilegts.candyjump"
minSdkVersion 14
targetSdkVersion 23
ndk {
moduleName "player_shared"
}
}
sourceSets {
main {
jni.srcDirs = []
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
就我而言,我必须做三件事:
由于我使用的是 firebase,因此请确保 firebase 和 google 播放服务具有相同的 version.Initially 播放服务具有较低版本。 主要是12.0.1版本帮助
在应用级别设置此 build.gradle
android { multiDexEnabled true }
再次在应用级别build.gradle,添加
compileOptions{ sourceCompatibility 1.8 targetCompatibility 1.8 }
这个 link 解决了我的问题。
首先,我将 pubspec.yaml 中的依赖项设置为
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.8.2
和 运行 flutter packages get
在我的 IDE 终端。
我还必须更改最低目标 SDK 版本:
- 打开 android/app/build.gradle,然后找到显示以下内容的行 minSdkVersion 16.
- 将该行更改为 minSdkVersion 21。
- 保存文件。
此外,我必须打开 android/app/build.gradle
,然后将以下行添加为文件的最后一行:
apply plugin: 'com.google.gms.google-services'
接下来,我必须打开 android/build.gradle
,然后在 buildscript 标签内,添加一个新的依赖项:
buildscript {
repositories {
// ...
}
dependencies {
// ...
classpath 'com.google.gms:google-services:3.2.1' // new
}
}
在此之后,我的应用程序终于在 android 模拟器上 运行。
如果您遇到困难,link 有更完整的演练。
奇怪的情况,但是 multiDexEnabled
没有帮助我,但是在删除 Gradle 目录并重建应用程序后问题解决了。