Studio中意外顶级EXCEPTION

Studio中意外顶级EXCEPTION

本文介绍了Android Studio中意外顶级EXCEPTION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个项目我得到这个例外,同时建立文件的gradle

and here is my dependencies

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:3.22.0'
    compile 'com.aviary.android.feather.sdk:aviary-sdk:3.6.3'
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.squareup.okhttp:okhttp:2.2.0'
    compile 'com.squareup.okio:okio:1.1.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/crashlytics.jar')
    compile files('libs/httpmime-4.1.3.jar')
    compile files('libs/jumblr-0.0.8-jar-with-dependencies.jar')
    compile files('libs/signpost-commonshttp4-1.2.1.2.jar')
    compile files('libs/signpost-core-1.2.1.2.jar')
    compile files('libs/simplesocialsharing.jar')
    compile files('libs/gcm.jar') }

I have tried everything but not getting how to exclude this multiple dex files. I have found solution for v4 like this

 configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

so is there any general solution for these kind of errors?

解决方案

As Gabriele says, TopLevel Exception always occur due to conflict of different version of same library.

So now, There are some ways to avoid it:

  1. Use only one version which contains all your required classes. like app compact has all v4 support classes, SO you dont need to import v4 support veresion if you're importing appcompact v7.

  2. You can always exclude a package from the compiled dependencies. For Example:

    //for the package:
    dependencies {
        compile("com.android.support:support-v4:21.0.3") {
              exclude group: 'com.android.support', module: 'support-v4'
        }
    }
    

这篇关于Android Studio中意外顶级EXCEPTION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 06:13