簡體   English   中英

錯誤:將字節碼轉換為dex時出錯:多個dex文件定義

[英]Error:Error converting bytecode to dex: Multiple dex files define

我有這個問題可以幫助我:

Error:Error converting bytecode to dex:

原因:com.android.dex.DexException:多個dex文件定義Lcom / google / android / gms / auth / api / signin / internal / zzf; ...

FAILURE:構建因異常而失敗。

  • 出了什么問題:任務執行失敗':app:transformClassesWithDexForDebug'。

    com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:執行java進程時出錯main class com.android.dx.command.Main with arguments {--dex --num-threads = 4 --output D:\\ Projectos \\ Chat_Final \\ app \\ build \\ intermediates \\ transforms \\ dex \\ debug \\ folders \\ 1000 \\ 1f \\ main D:\\ Projectos \\ Chat_Final \\ app \\ build \\ intermediates \\ pre-dexed \\ debug \\ classes_9fd79174a0a6dc23209652a8a58b3e02e9146491.jar D:\\ Projectos \\ Chat_Final \\ app \\ build \\ intermediates \\ pre-dexed \\ debug \\ bolts-applinks-1.4。 0_7536087ced7b51cacc52bdfc4ca05ab61d61e0c3.jar D:\\ Projectos \\ Chat_Final \\ app \\ build \\ intermediates \\ pre-dexed \\ debug \\ jackson-databind-2.2.2_c79be971c56bd1cdc38488184cf71a5146b761ff.jar D:\\ Projectos \\ Chat_Final \\ app \\ build \\ intermediates \\ pre-dexed \\ debug \\ classes_3b9a81b892f55e63da37657bf33b2ce2fe9ca8b0.jar

我的build.glade

    packagingOptions {
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
}

}

/ * packagingOptions {exclude'META-INF / LICENSE'//如果你使用firebase //包括下面的行//排除'META-INF / LICENSE-FIREBASE.txt'排除'META-INF / NOTICE'} * /

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'
    })
    testCompile 'junit:junit:4.12'


    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    //compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'


    compile 'com.android.support:appcompat-v7:25.0.1'

    compile 'com.firebase:firebase-client-android:2.4.0'
    compile 'com.google.firebase:firebase-core:10.2.6'
    compile 'com.google.firebase:firebase-auth:10.2.6'
    compile 'com.google.firebase:firebase-database:10.2.6'
    compile 'com.google.firebase:firebase-storage:10.2.6'
    compile 'com.google.firebase:firebase-messaging:10.2.6'
    compile 'com.firebaseui:firebase-ui-database:0.6.0'
    compile 'com.firebaseui:firebase-ui-storage:0.6.0'


    compile 'com.firebaseui:firebase-ui-auth:0.6.0'
    //compile 'com.android.support:multidex:1.0.0'

    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.bumptech.glide:glide:3.7.0'


    compile 'com.squareup.okhttp3:okhttp:3.6.0'

    //Notification

    compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)'




    compile 'com.google.android.gms:play-services-gcm:10.2.6'

    compile 'com.google.android.gms:play-services-location:10.2.6'



}

申請插件:'com.google.gms.google-services'

如果你的minSdkVersion設置為21或更高 ,你需要做的就是在app-level build.gradle文件中將multiDexEnabled設置為true ,如下所示:

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 25
        multiDexEnabled true
    }
    ...
}

但是,如果您的minSdkVersion設置為20或更低 ,則必須使用multidex支持庫,如下所示:

修改app級build.gradle文件以啟用multidex並將multidex庫添加為依賴項,如下所示:

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 25
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

像這樣創建一個Application類:

public class MyApplication extends MultiDexApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

在Manifest中添加此應用程序類。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your package name">
    <application
        android:name=".MyApplication" >
        ...
    </application>
</manifest>

您也可以查看以下鏈接:

https://developer.android.com/studio/build/multidex.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 將字節碼轉換為dex時出錯:多個dex文件,Android Studio 3.0 將字節碼轉換為dex時出錯:多個dex文件定義了Landroid/arch/lifecycle/LiveData$LifecycleBoundObserver; 錯誤:將字節碼轉換為dex時出錯:原因:com.android.dex.DexException:多個dex文件定義了Lcom / example / admin / myapplication / MainActivity; Android Studio:將字節碼轉換為 dex 時出錯:多個 dex 文件定義了 Ljavax/mail/internet/ParameterList$ToStringBuffer; 錯誤:將字節碼轉換為 dex 時出錯:原因:com.android.dex.DexException:多個 dex 文件定義了 Lokhttp3/internal/http/RealResponseBody; 將字節碼轉換為dex時出錯:原因:com.android.dex.DexException:多個dex文件定義了Lcom / RNFetchBlob / RNFetchBlobConst; 將字節碼轉換為dex時出錯 錯誤:將字節碼轉換為dex時出錯:原因:com.android.dex.DexException:多個dex文件定義了Lcom / google / android / gms / internal / zzee; 錯誤:將字節碼轉換為dex時出錯:原因:com.android.dex.DexException:多個dex文件定義了Lcom / google / android / gms / common / api / zza; Gradle 構建錯誤將字節碼轉換為 dex 時出錯:原因:com.android.dex.DexException:多個 dex 文件定義 Landroid/arch/lifecycle/liveData$1
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM