My Android application uses AndroidAnnotations and Spring Rest Template. When creating a debug build, it runs fine. When I create a release build however, the REST call does not work. Below are some relevant snippets from my code and build configuration.
Activity
public class MyActivity extends Activity {
@Bean
protected MyService myService;
@Background
protected void fetchData() {
try {
data = myService.getData();
} catch (DataAccessException dae) {
Log.e(getClass().getSimpleName(), dae.getMessage(), dae);
}
}
}
Service
@EBean
public class MyService {
@RestService
protected MyRestClient myRestClient;
public Data getData() {
return myRestClient.getData();
}
}
RestClient
@Rest(converters = { GsonHttpMessageConverter.class },
interceptors = { AuthenticationInterceptor.class, UserAgentInterceptor.class },
rootUrl = "https://myhost/rest")
public interface MyShiftRestClient {
@Get("/data")
Data getData();
}
ProGuard configuration
-dontwarn org.apache.http.annotation.Immutable
-dontwarn org.apache.http.annotation.NotThreadSafe
-dontwarn org.springframework.**
-keep class com.mypackage.** {
public protected private *;
}
-keepclassmembers public class org.springframework.** {
public *;
}
When running the obfuscated app, the Data object that is returned by MyRestClient
is an empty object, i.e. it is initialised but none of its instance variables have any values. I guess it has to do with my ProGuard configuration, that's why I added the last configuration statement, but it had no effect. There is no Exception being logged.
Try to keep members of Data class too. Data class properties must be untouched to allow Gson converter fill it, as it is done based on property names.
Good luck.