【问题标题】:Android Studio : Error converting bytecode to dex:Multiple dex files define Ljavax/mail/internet/ParameterList$ToStringBuffer;Android Studio:将字节码转换为dex时出错:多个dex文件定义Ljavax/mail/internet/ParameterList$ToStringBuffer;
【发布时间】:2018-02-23 08:12:14
【问题描述】:

我最近升级到 Android Studio 3.0.1,在运行程序时出现此错误:

我的 build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.mrunal.myadmin"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
    multiDexEnabled true

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

dexOptions {
    javaMaxHeapSize "4g"
    preDexLibraries = false
}
}
 dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.1'
implementation 'javax.mail:javax.mail-api:1.5.3'
implementation 'com.android.support:support-vector-drawable:26.1.0'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation files('libs/mail.jar')
 }
apply plugin: 'com.google.gms.google-services'

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.felicity.myadmin">
<uses-permission android:name="android.permission.INTERNET" />
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:name="android.support.multidex.MultiDexApplication"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Email_Activity"></activity>
</application>
</manifest>

我已经试过了

  • 清理并重建
  • 删除了 jar 的第二次编译

我在 SO 上搜索了很多相关问题,但没有任何帮助。 请大家帮帮我

【问题讨论】:

    标签: android android-studio compiler-errors android-gradle-plugin android-multidex


    【解决方案1】:

    问题解决了,

    我只是换了implementation 'com.android.support:multidex:1.0.1'

    implementation 'com.android.support:multidex:1.0.2' 它有效

    【讨论】:

      【解决方案2】:

      更新您的 multidex 只是临时解决您的问题。如果您在发布 apk 中使用 proguard,同样的问题会再次困扰您。

      问题可能是因为您使用的是同一个库:

      implementation 'javax.mail:javax.mail-api:1.5.3'
      

      implementation files('libs/mail.jar')
      

      只使用一个。

      你也不需要使用:

      implementation files('libs/mail.jar')
      

      如果您正在使用:

      implementation fileTree(include: ['*.jar'], dir: 'libs')
      

      您可能不需要为您的 apk 使用 multidex,因为您的依赖项不超过 65k 限制。

      【讨论】:

        猜你喜欢
        • 2018-04-09
        • 2017-11-11
        • 1970-01-01
        • 1970-01-01
        • 2016-09-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-18
        相关资源
        最近更新 更多