【问题标题】:why upgrading firestore version to 17.1.0 makes a problem in the Multidex?为什么将 Firestore 版本升级到 17.1.0 会导致 Multidex 出现问题?
【发布时间】:2018-08-31 02:44:20
【问题描述】:

当我使用 firestore 版本 11.8.0 时,我的应用程序运行良好,但总是有关于 firestore 版本的警告,它要求我升级最新版本 17.1.0 升级版本后,应用程序显示错误,android studio一直告诉我 //Cannot fit requested classes in a single dex file. Try supplying a main-dexlist. 不知道为什么firebase存储的版本跟Multidex有关系? 这是我的构建等级。

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.moham.trial"
        minSdkVersion 19
        targetSdkVersion 28
        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(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-firestore:17.1.0'
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.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'

implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc01'


implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.android.support:cardview-v7:28.0.0-rc02'

implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'

}
apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 与问题分享您的build.Gradle
  • 你现在可以检查一下,我已经用 build gradle 更新了这个问题,谢谢
  • 测试用例尝试使用 27.1.1 而不是 28.0.0-rc02
  • 刚刚试了一下,同样的错误
  • 使用classpath 'com.google.gms:google-services:4.0.1'

标签: android firebase google-cloud-firestore android-multidex


【解决方案1】:

构建 android 应用程序会将应用程序编译为 DEX 文件形式的字节码(可执行代码)。编译后的字节码文件(DEX 文件)只支持 64K(65,536)种方法,才需要拆分成 DEX 文件。

添加 firestore 库会增加很多方法并导致超出此限制,因此需要 multiDexEnabled true 才能将其拆分为多个文件。

您可以在以下位置找到更多信息:https://developer.android.com/studio/build/multidex

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-12
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 2023-04-01
    • 2016-09-06
    • 2018-02-16
    • 1970-01-01
    相关资源
    最近更新 更多