android - 无法在颤振中合并dex
问题描述
嗨,我正在开发应用程序。当我试图构建颤振时,我得到了一个错误Unable to merge dex
。
应用程序构建.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.xyz"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
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'
implementation 'com.google.firebase:firebase-core:16.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.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
有谁知道如何在颤振中解决它?
解决方案
尝试在 app build.gradle 中添加这个
android {
defaultConfig {
multiDexEnabled true
}
}
改变
classpath 'com.google.gms:google-services:4.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
到
classpath 'com.google.gms:google-services:4.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
并在 Android Studio 中打开项目并清理、重建或简单地运行 flutter clean 命令
推荐阅读
- c++ - 防止在静态库中隐式实例化 std::string/std::wstring
- javascript - 更改 sidenav 视图
- vue.js - 在 vue 中使用 d3.js
- php - 如何为返回空结果的现有单行输出查询
- android - 什么是android中aab(android app bundle)的仅资产模块和按需功能?
- c# - 带有“+”号且字符之间没有空格的参数值在响应 URL 中得到 404 Not Found
- python - 重组熊猫数据框
- java - 使用 txt 文件中的数据创建对象
- windows-10 - 在 Windows 10 中运行 .sh 文件
- flutter - 圆边,但 Inkwell customborder 中的尖角矩形