My app doesn't post data to server when I run the release version (signed, Proguard packed). But if I run it directly from ADT, I see the data on the server.
It's weird because it just the same code, one is signed and the other is direct execution. Here is the Code (using org.springframework.web.client.RestTemplate
):
private static String URL = "https://myappserver.com/abcservice/";
public ResponseEntity<String> sendMessage(UserMessage us) {
private RestTemplate template = getTemplate();
HttpEntity<UserMessage> reqEntity = new HttpEntity<UserMessage>(us, headers);
ResponseEntity<String> result =
template.postForEntity(URL, reqEntity, String.class);
return result;
}
Below are the 2 scenarios:
Case 1: Works Good
- Run the App directly from ADT (Run as: Android Application)
- User taps a button, which will invoke
sendMessage(..)
method. - Controller (on Server) gets the request and the data (
UserMessage
). - An entry with UserMessage is created.
- Server send a 201 response (request has been fulfilled), to the app.
Case 2: PROBLEM
- Pack the app (Android Tools -> Export Signed Application Package..)
- Install it on device through command line (adb install xxx.apk)
- Start the app.
- User taps a button, which will invoke
sendMessage(..)
method. - Controller (on Server) gets the request but no data.
- An entry with empty UserMessage is created.
- Server send a 201 response (request has been fulfilled), to the app.
I have tried to log both on my device and web server, I can confirm that empty data is received for Case 2, and I'm not able to figure out why it doesn't send data when I pack it?
Does packed/released (Signed +Proguard) apps behave differently, compared to debug packaging?