Start a new topic
Answered

Data not being fetched on signed APK?

Hi, 


I have developed an Android app that takes data from a Kinvey database, and displays it on screen. My app works perfectly when I run it from Android Studio, however, when I generate a signed APK, and test the app, it doesn't seem to fetch any data from the Kinvey Database. 


My app has a feature to submit data also. And the submitting feature seems to work perfectly. However, the app isn't fetching anything. I generated a log from my phone, and this is what shows up when I open the signed APK:


01-07 00:47:19.672 12622 12622 I ContentValues: Failed to fetch jokes

01-07 00:47:20.021 356 356 W auditd : type=1400 "ipacm""/dev/socket/ipacm_log_file"

01-07 00:47:20.021 356 356 W auditd : type=1400 "ipacm""/dev/socket/ipacm_log_file"

01-07 00:47:20.021 356 356 W auditd : type=1400 "ipacm""/dev/socket/ipacm_log_file"

01-07 00:47:20.021 356 356 W auditd : type=1400 "ipacm""/dev/socket/ipacm_log_file"

01-07 00:47:20.267 9550 9639 D ClClient: Not sending keepalive. Current connection state=STOPPED


The exception above is being caused by the following function: 


// The exception from the log is coming from this function

/** Function to retrieve all verified jokes from database **/

void getJokes(final boolean communityJokes){
Query latestQuery = mKinveyClient.query();
latestQuery.greaterThanEqualTo("verified", 1);
latestQuery.addSort("_kmd", AbstractQuery.SortOrder.DESC);

AsyncAppData<JokeEntity> all_jokes = mKinveyClient.appData("jokes", JokeEntity.class);
all_jokes.get(latestQuery, new KinveyListCallback<JokeEntity>() {
@Override
public void onSuccess(JokeEntity[] result) {
processJokes(result, communityJokes);
}
@Override
public void onFailure(Throwable error) {
Log.i(TAG, "Failed to fetch jokes");
}
});
}


Any help would be appreciated. Thanks!


Best Answer

I've found a solution! 


When I was writing my Entity class, I got a warning from the Android Studio linter  on my empty public entity constructor, telling me that the "Access can be package local." So, I clicked a button and it automatically changed from 

public myEntity() {}
to
myEntity() {} 

I discovered the problem when I was reading through the Kinvey documentation and it mentioned that "GenericJson classes must have a public empty constructor" Everything now works as expected on signed, and unsigned APK's. Thanks for your help!  

Hello Tas-had Saq,


Thanks for posting this issue. We are looking into it and will get back with you soon with more information.


I do have some questions. 


When you created the APK and installed it on the device, was it a brand new installation or were you installing over a previous version?


Is your app connecting via WiFi or your carrier?


Is this problem repeatable every time and if so, does it always fail in the same way? It sounds like it is but I just want to be sure.


Regards,


Billy Gee

Kinvey

Hello Tash-had Saq,


I just spoke with Engineering and it will be helpful if we could have you reproduce this problem and then provide us with a network dump (if possible) and the full local logs.


We look forward to hearing back from you.


Regards,


Billy Gee

Kinvey



Hi Billy,


Thanks for the prompt response! 


1. When you created the APK and installed it on the device, was it a brand new installation or were you installing over a previous version?


I tested the issue both ways; once by installing the APK as an update to the version on the Play store, and another as a clean install. The issue persists both ways. 


2. Is your app connecting via WiFi or your carrier?


Wi-Fi. 


3. Is this problem repeatable every time and if so, does it always fail in the same way? It sounds like it is but I just want to be sure.


Yes. I have tested it on two different devices, one running Android 5.1 and the other running android 6.1. I get the same issue every time. 


Since this forum is public, I've sent you an e-mail containing device and network logs from when I open the app. 


Let me know if you have any other questions or need anything else like an APK. 


Thank you,

Tash-had 


Hey Billy, 


I'm curious to know if there are any updates? 


Thanks! 

Hi Billy, 


I have tracked down the issue. Fetching data seems to raise a KinveyException with the reason "Unable to parse the JSON in the response" and the explanation being "java.lang.IlligalArgumentException." Any way I can get through this? 


Thanks

Answer

I've found a solution! 


When I was writing my Entity class, I got a warning from the Android Studio linter  on my empty public entity constructor, telling me that the "Access can be package local." So, I clicked a button and it automatically changed from 

public myEntity() {}
to
myEntity() {} 

I discovered the problem when I was reading through the Kinvey documentation and it mentioned that "GenericJson classes must have a public empty constructor" Everything now works as expected on signed, and unsigned APK's. Thanks for your help!  

Hello Tash-had Saq,


Thank you for sending the logs. I have reviewed them and will include them in an escalating to Engineering. I did notice that the Android logs and the Network logs occurred at different times on the 7th and this means that the network logs will not be relatable to the Android logs.


In the network logs, it appears that you have received all the data from the Jokes collection that you were asking for from the perspective of the logs. I did find a problem problem in the server logs that I'm looking into with Engineering. The fact that all the requested data from the Jokes collection arrived and was logged locally but you don't get the response and are receiving the JSON parse error instead would seem to indicate something is wrong once the request is received by the app.


I am continuing to work with Engineering.  I will update this post as soon as I know more.


Regards,


Billy Gee

Kinvey, Inc.


MLIBZ-1608

Hi Billy, 


I've found the solution and have submitted it. I think it's awaiting approval on the forum. 


Thanks!

Tash-had

Hello Tash-had Saq,


Thank you very much for letting us know that you have solved the problem. 


As you continue to work on your application, please reach out to us when you need further assistance. We are happy to help.


Regards,


Billy Gee

Kinvey, Inc.

Login or Signup to post a comment