java.lang.NoClassDefFoundError retrofit2.Utils

后端 未结 11 1385
梦毁少年i
梦毁少年i 2020-12-30 10:40

I\'m using Retrofit to handle the Serverside Data from Mobile. After Implementing retrofit, I am Getting the below Exception.

What am I doing wrong?

相关标签:
11条回答
  • 2020-12-30 11:23

    With these many library saddles up, it must have exceded the infamous 64k method limit, you need to enable your app for multidex. Here is how you do it. https://developer.android.com/tools/building/multidex.html

    0 讨论(0)
  • 2020-12-30 11:24

    It's Gradle bulid configure issue i also got same issue Some times

    In Gradle your using

    compile 'com.google.android.gms:play-services:8.4.0'
    

    Enire Google Playservice Lib can you change into which are the lib's using in your project

    Example

    com.google.android.gms:play-services-gcm:8.4.0 
    com.google.android.gms:play-services-maps:8.4.0
    com.google.android.gms:play-services-auth:8.4.0
    

    Refer This URl https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project

    0 讨论(0)
  • 2020-12-30 11:28

    Did you add the following proguard rules?

    -dontwarn retrofit2.**
    -keep class retrofit2.** { *; }
    -keepattributes Signature
    -keepattributes Exceptions
    

    Documentation: http://square.github.io/retrofit/

    0 讨论(0)
  • 2020-12-30 11:31
    mRetrofit = new Retrofit.Builder()
                        .baseUrl(AppConstance.APP_URL)
                        .addConverterFactory(ScalarsConverterFactory.create())
                        .addConverterFactory(GsonConverterFactory.create())
                        .client(getOkHttpClient())
                        .build();
    

    REWRITE TO

    OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    mRetrofit = new Retrofit.Builder()
                            .baseUrl(AppConstance.APP_URL)
                            .addConverterFactory(GsonConverterFactory.create())
                            .client(httpClient)
                            .build();
    
    0 讨论(0)
  • 2020-12-30 11:37

    Try using the same lib version for base retrofit lib and the converters.

    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.retrofit2:converter-scalars:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    
    0 讨论(0)
提交回复
热议问题