Skip to content Skip to sidebar Skip to footer

Android: Library Project With Retrofit Results In Noclassdeffounderror

I'm trying to build an android library project which uses OkHttp and Retrofit to grant access to our REST-backend. It seems to be working as long as I use api instead of implementa

Solution 1:

As per official retrofit github link :

https://github.com/square/retrofit

Retrofit requires at minimum Java 7 or Android 2.3.

If you are using ProGuard you need to add the following options:

# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain service method parameters.
-keepclassmembernames,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}
# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# My personal proguard configuration for ratrofit2
-dontwarn okio.**
-dontwarn javax.annotation.**
-dontwarn retrofit2.Platform$Java8

please check once your configuration if there is any mistake :

app-> build.gradle

// retrofit gson

implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

If there is more error you can share your error log to explain you what exactly problem is.

Post a Comment for "Android: Library Project With Retrofit Results In Noclassdeffounderror"