AndlyticsProject / andlytics

Google Play - Android Market statistics app
Other
536 stars 181 forks source link

Need to be able to choose whether to auto-refresh or not when loading the main activity #598

Open viralypatel opened 10 years ago

viralypatel commented 10 years ago

Need to be able to choose whether to auto-refresh or not when loading the main activity.

With too many apps all you every get to see is the updating spinner. A way to make it refresh only on demand (probably by setting a flag via preferences) would be something nice.

nelenkov commented 10 years ago

If you have that many apps, it shouldn't take you too long to put together a pull request that fixes this, right? Easiest is to make the auto-refresh time configurable (currently hard-coded at 15 mins, IIRC). Code contributions are always welcome.

viralypatel commented 10 years ago

Have never used GIT before. Let me give it a try. :-)

On Fri, Mar 14, 2014 at 8:17 PM, Nikolay Elenkov notifications@github.comwrote:

If you have that many apps, it shouldn't take you too long to put together a pull request that fixes this, right? Easiest is to make the auto-refresh time configurable (currently hard-coded at 15 mins, IIRC). Code contributions are always welcome.

Reply to this email directly or view it on GitHubhttps://github.com/AndlyticsProject/andlytics/issues/598#issuecomment-37654462 .

viralypatel commented 10 years ago

I forked the master branch and cloned locally. Builds and installs fine but I'm getting an authentication failed error. Anything extra need to be done?

Viral (Sent from mobile. Please ignore typos.) On 18-Mar-2014 5:22 pm, "Viral Patel" viral.y.patel@gmail.com wrote:

Have never used GIT before. Let me give it a try. :-)

On Fri, Mar 14, 2014 at 8:17 PM, Nikolay Elenkov <notifications@github.com

wrote:

If you have that many apps, it shouldn't take you too long to put together a pull request that fixes this, right? Easiest is to make the auto-refresh time configurable (currently hard-coded at 15 mins, IIRC). Code contributions are always welcome.

Reply to this email directly or view it on GitHubhttps://github.com/AndlyticsProject/andlytics/issues/598#issuecomment-37654462 .

nelenkov commented 10 years ago

Please fork the dev branch. Right now it should be very close to master, but new things go there. As for the authentication error, nothing special, check that you have a recent Google Play Services version and try logging into the dev console through Chrome.

viralypatel commented 10 years ago

Tried doing the above but the problem persists. Following is the logcat. Any idea what may be going wrong?

03-19 16:09:15.066: E/Main(31641): Error while requesting developer console : com.github.andlyticsproject.console.v2.AccountManagerAuthenticator.authenticateInternal(AccountManagerAuthenticator.java:178) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.console.v2.AccountManagerAuthenticator.authenticate(AccountManagerAuthenticator.java:66) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:348) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:327) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:102) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:449) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:1) 03-19 16:09:15.066: E/Main(31641): android.os.AsyncTask$2.call(AsyncTask.java:288) 03-19 16:09:15.066: E/Main(31641): java.util.concurrent.FutureTask.run(FutureTask.java:237) 03-19 16:09:15.066: E/Main(31641): java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 03-19 16:09:15.066: E/Main(31641): java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 03-19 16:09:15.066: E/Main(31641): java.lang.Thread.run(Thread.java:811) 03-19 16:09:15.076: E/Main(31641): Error while requesting developer console : Couldn't get developer account ID. 03-19 16:09:15.076: E/Main(31641): com.github.andlyticsproject.console.AuthenticationException: Couldn't get developer account ID. 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.AccountManagerAuthenticator.authenticateInternal(AccountManagerAuthenticator.java:178) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.AccountManagerAuthenticator.authenticate(AccountManagerAuthenticator.java:66) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:348) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:327) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:102) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:449) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:1) 03-19 16:09:15.076: E/Main(31641): at android.os.AsyncTask$2.call(AsyncTask.java:288) 03-19 16:09:15.076: E/Main(31641): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 03-19 16:09:15.076: E/Main(31641): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 03-19 16:09:15.076: E/Main(31641): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 03-19 16:09:15.076: E/Main(31641): at java.lang.Thread.run(Thread.java:811)

On Tue, Mar 18, 2014 at 7:27 PM, Nikolay Elenkov notifications@github.comwrote:

Please fork the dev branch. Right now it should be very close to master, but new things go there. As for the authentication error, nothing special, check that you have a recent Google Play Services version and try logging into the dev console through Chrome.

Reply to this email directly or view it on GitHubhttps://github.com/AndlyticsProject/andlytics/issues/598#issuecomment-37934893 .

viralypatel commented 10 years ago

as regards to GPS i have V4.2.43 ... I guess that is the latest and should not be a problem. Let me know if otherwise.

viralypatel commented 10 years ago

oops sorry fixed it now ... the gps library was faulty. now working.

On Wed, Mar 19, 2014 at 4:11 PM, Viral Patel viral.y.patel@gmail.comwrote:

Tried doing the above but the problem persists. Following is the logcat. Any idea what may be going wrong?

03-19 16:09:15.066: E/Main(31641): Error while requesting developer console : com.github.andlyticsproject.console.v2.AccountManagerAuthenticator.authenticateInternal(AccountManagerAuthenticator.java:178) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.console.v2.AccountManagerAuthenticator.authenticate(AccountManagerAuthenticator.java:66) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:348) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:327) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:102) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:449) 03-19 16:09:15.066: E/Main(31641): com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:1) 03-19 16:09:15.066: E/Main(31641): android.os.AsyncTask$2.call(AsyncTask.java:288) 03-19 16:09:15.066: E/Main(31641): java.util.concurrent.FutureTask.run(FutureTask.java:237) 03-19 16:09:15.066: E/Main(31641): java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 03-19 16:09:15.066: E/Main(31641): java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 03-19 16:09:15.066: E/Main(31641): java.lang.Thread.run(Thread.java:811) 03-19 16:09:15.076: E/Main(31641): Error while requesting developer console : Couldn't get developer account ID. 03-19 16:09:15.076: E/Main(31641): com.github.andlyticsproject.console.AuthenticationException: Couldn't get developer account ID. 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.AccountManagerAuthenticator.authenticateInternal(AccountManagerAuthenticator.java:178) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.AccountManagerAuthenticator.authenticate(AccountManagerAuthenticator.java:66) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:348) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:327) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:102) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:449) 03-19 16:09:15.076: E/Main(31641): at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:1) 03-19 16:09:15.076: E/Main(31641): at android.os.AsyncTask$2.call(AsyncTask.java:288) 03-19 16:09:15.076: E/Main(31641): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 03-19 16:09:15.076: E/Main(31641): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 03-19 16:09:15.076: E/Main(31641): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 03-19 16:09:15.076: E/Main(31641): at java.lang.Thread.run(Thread.java:811)

On Tue, Mar 18, 2014 at 7:27 PM, Nikolay Elenkov <notifications@github.com

wrote:

Please fork the dev branch. Right now it should be very close to master, but new things go there. As for the authentication error, nothing special, check that you have a recent Google Play Services version and try logging into the dev console through Chrome.

Reply to this email directly or view it on GitHubhttps://github.com/AndlyticsProject/andlytics/issues/598#issuecomment-37934893 .

viralypatel commented 10 years ago

So did a bit of debugging and the issue is not with the json parsing as we had earlier assumed in another issue.

The main issue is here :

"private List fetchAppInfosAndStatistics()"

inside DevConsoleV2.java

following code in this method is where it dies

                    AppStats stats = app.getLatestStats();
        fetchRatings(app, stats);
        stats.setNumberOfComments(fetchCommentsCount(app, Utils.getDisplayLocale()));
        RevenueSummary revenue = fetchRevenueSummary(app);
        app.setTotalRevenueSummary(revenue);

The details are fectched one by one for each app. It is taking close to 6 or 7 seconds for each app on a high speed wifi. I have around 300 apps. So still waiting for the debugger to hit a breakpoint set after fetching the details for all the apps.

I think this is a potential area of improvement. I'll try for alternate options (hoping to find something that lessens the time). Anyone has any pointers to make the situation a bit better in this method?

viralypatel commented 10 years ago

After a long wait, it completed looping through all the apps and then boom! The following error in logcat:

03-19 18:04:22.329: E/Main(7094): Error while requesting developer console : com.github.andlyticsproject.Main.access$0(Main.java:72) 03-19 18:04:22.329: E/Main(7094): com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:490) 03-19 18:04:22.329: E/Main(7094): com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:1) 03-19 18:04:22.329: E/Main(7094): android.os.AsyncTask$2.call(AsyncTask.java:288) 03-19 18:04:22.329: E/Main(7094): java.util.concurrent.FutureTask.run(FutureTask.java:237) 03-19 18:04:22.329: E/Main(7094): java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 03-19 18:04:22.329: E/Main(7094): java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 03-19 18:04:22.329: E/Main(7094): java.lang.Thread.run(Thread.java:811) 03-19 18:04:37.175: E/Main(7094): Error while requesting developer console : Attempt to read from field 'boolean com.github.andlyticsproject.Main.cancelRequested' on a null object reference 03-19 18:04:37.175: E/Main(7094): java.lang.NullPointerException: Attempt to read from field 'boolean com.github.andlyticsproject.Main.cancelRequested' on a null object reference 03-19 18:04:37.175: E/Main(7094): at com.github.andlyticsproject.Main.access$0(Main.java:72) 03-19 18:04:37.175: E/Main(7094): at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:490) 03-19 18:04:37.175: E/Main(7094): at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:1) 03-19 18:04:37.175: E/Main(7094): at android.os.AsyncTask$2.call(AsyncTask.java:288) 03-19 18:04:37.175: E/Main(7094): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 03-19 18:04:37.175: E/Main(7094): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 03-19 18:04:37.175: E/Main(7094): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 03-19 18:04:37.175: E/Main(7094): at java.lang.Thread.run(Thread.java:811)

nelenkov commented 10 years ago

Attaching the debugger makes things very-very slow. You can't realistically test this with the debugger. Put int log statements to see where it takes time and how long. As for getting things one by one, there is another issue about this, latency can be improved a bit by sending multiple simultaneous requests, but it's a bit tricky to get right.

viralypatel commented 10 years ago

Okay, but what was the last error (in my previous post) after all information was fetched. Not quiet being able to figure out the reason for that.

nelenkov commented 10 years ago

It's a NPE so something got nulled out while waiting for the debugger. Maybe the main activity got killed or detached, etc.