Ali Habbash
Ali Habbash

Reputation: 797

Error converting bytecode to dex Android studio

I'm working on an Android project that uses ElasticSearch. When I try to debug the app, I get this error:

 Error:Error converting bytecode to dex:
 Cause: com.android.dex.DexException: Multiple dex files define 
 Lcom/google/gson/JsonSerializer;

I saw many related questions and solutions, but they do not work. I tried to clean the project then hit debugging, that also does not work. I also tried to clean the project and make the project and there is no errors but, when I hit debugging it again shows the same error.

Upvotes: 2

Views: 176

Answers (1)

PRATEEK BHARDWAJ
PRATEEK BHARDWAJ

Reputation: 2442

 defaultConfig {

        applicationId "com.package_name"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

    }

compile 'com.android.support:multidex:1.0.2'

Problem is saying Class JsonSerializer is found duplicate. So its saying multiple Dex file. Same file is available in your one or more dependency May be it can give solution to you.

press shift two times continuously and find file window will popup and type json serializer. now you can see which two jar files have same class. Now remove any dependency which is not usable.

Upvotes: 1

Related Questions