Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALARM_COUNT expected Integer but value was a java.lang.Long - GPSLogger stops #337

Closed
ciakpey opened this issue Jul 27, 2015 · 24 comments
Closed

Comments

@ciakpey
Copy link
Contributor

ciakpey commented Jul 27, 2015

The app doesn't work anymore for me, it logs the first point, and some passive points but doesn't wake after the delay it should.
When I debug the code, the problem is

07-28 00:12:01.286  23747-23747/com.mendhak.gpslogger W/Bundle﹕ Key android.intent.extra.ALARM_COUNT expected Integer but value was a java.lang.Long.  The default value 0 was returned.
07-28 00:12:01.287  23747-23747/com.mendhak.gpslogger W/Bundle﹕ Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
            at android.os.BaseBundle.getInt(BaseBundle.java:800)
            at android.os.BaseBundle.getInt(BaseBundle.java:782)
            at com.mendhak.gpslogger.GpsLoggingService.HandleIntent(GpsLoggingService.java:283)
            at com.mendhak.gpslogger.GpsLoggingService.onStartCommand(GpsLoggingService.java:165)
            at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2924)
            at android.app.ActivityThread.access$2100(ActivityThread.java:155)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1415)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5343)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

So problem in conversion line at com.mendhak.gpslogger.GpsLoggingService.HandleIntent(GpsLoggingService.java:283)

@mendhak
Copy link
Owner

mendhak commented Jul 27, 2015

If you change that line from

if(bundle.getInt(Intent.EXTRA_ALARM_COUNT) != 0){

to

if(intent.getIntExtra(Intent.EXTRA_ALARM_COUNT,0) != 0){

Does it work?

Also, what's your phone/OS?

@ciakpey
Copy link
Contributor Author

ciakpey commented Jul 27, 2015

No, same error,
But if I delete the if statement it works

@mendhak
Copy link
Owner

mendhak commented Jul 27, 2015

OK very unusual, the alarm manager is simply what the OS delivers to the application. It should always be integer.

What phone and OS are you using?

@ciakpey
Copy link
Contributor Author

ciakpey commented Jul 27, 2015

I run android studio on arch linux, with a moto g lolilop phone.
I try to debug the app, but before I was using the version of the play store, and that wasn't working

@mendhak
Copy link
Owner

mendhak commented Aug 1, 2015

So I haven't been able to find anything on this. Everything points to this field being an int so there's no reason for it to behave differently. I tested this on a coworker's MotoG, no problem. If you are still debugging this it might be worth changing the line to bundle.getLong(Intent.EXTRA_ALARM_COUNT) and setting a breakpoint; then adding a watch to see what that value actually is.

I had a thought that the value might be 231-1, but that would require over 68 years of pending alarms. I'm pretty sure Android hasn't existed that long. That value might hold some clue.

@ciakpey
Copy link
Contributor Author

ciakpey commented Aug 1, 2015

Thanks for your efforts,
If I debug the value of b|undle.getInt(Intent.EXTRA_ALARM_COUNT)
I get 0 and the logging doesn't work and I still have the same error

W/Bundle﹕ Key android.intent.extra.ALARM_COUNT expected Integer but 
value was a java.lang.Long.  The default value 0 was returned.
08-01 10:29:13.759  19627-19627/com.luap.gpslogger W/Bundle﹕ Attempt to 
cast generated internal exception:
     java.lang.ClassCastException: java.lang.Long cannot be cast to 
java.lang.Integer

If I changed getInt to GetLong, I have now

 W/Bundle﹕ Key android.intent.extra.ALARM_COUNT expected Integer but 
value was a java.lang.Long.  The default value 0 was returned.
08-01 10:14:00.172  12872-12872/com.luap.gpslogger W/Bundle﹕ Attempt to 
cast generated internal exception:
     java.lang.ClassCastException: java.lang.Long cannot be cast to 
java.lang.Integer

They say they returned 0, but when I watch it, it is 1, (but the logging
works)

In both case it is the same error, weird!

@naoliv
Copy link

naoliv commented Aug 14, 2015

I am seeing the same problem here:

08-14 13:54:53.708 W/Bundle  ( 2445): Key android.intent.extra.ALARM_COUNT expected Integer but value was a java.lang.Long.  The default value 0 was returned.
08-14 13:54:53.713 W/Bundle  ( 2445): Attempt to cast generated internal exception:
08-14 13:54:53.713 W/Bundle  ( 2445): java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
08-14 13:54:53.713 W/Bundle  ( 2445):   at android.os.BaseBundle.getInt(BaseBundle.java:800)
08-14 13:54:53.713 W/Bundle  ( 2445):   at android.os.BaseBundle.getInt(BaseBundle.java:782)
08-14 13:54:53.713 W/Bundle  ( 2445):   at com.mendhak.gpslogger.GpsLoggingService.HandleIntent(GpsLoggingService.java:278)
08-14 13:54:53.713 W/Bundle  ( 2445):   at com.mendhak.gpslogger.GpsLoggingService.onStartCommand(GpsLoggingService.java:160)
08-14 13:54:53.713 W/Bundle  ( 2445):   at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2896)
08-14 13:54:53.713 W/Bundle  ( 2445):   at android.app.ActivityThread.access$2100(ActivityThread.java:148)
08-14 13:54:53.713 W/Bundle  ( 2445):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1390)
08-14 13:54:53.713 W/Bundle  ( 2445):   at android.os.Handler.dispatchMessage(Handler.java:102)
08-14 13:54:53.713 W/Bundle  ( 2445):   at android.os.Looper.loop(Looper.java:135)
08-14 13:54:53.713 W/Bundle  ( 2445):   at android.app.ActivityThread.main(ActivityThread.java:5312)
08-14 13:54:53.713 W/Bundle  ( 2445):   at java.lang.reflect.Method.invoke(Native Method)
08-14 13:54:53.713 W/Bundle  ( 2445):   at java.lang.reflect.Method.invoke(Method.java:372)
08-14 13:54:53.713 W/Bundle  ( 2445):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
08-14 13:54:53.713 W/Bundle  ( 2445):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)

and nothing is recorded.

My phone (a Moto G 2nd gen with lollipop too):

build.brand: motorola
build.cpu_abi: armeabi-v7a
build.cpu_abi2: armeabi
build.device: titan_udstv
build.hardware: qcom
build.manufacturer: motorola
build.model: XT1069
build.product: titan_retbr_dstv
version.codename: REL
version.incremental: 27
version.release: 5.0.2
version.sdk_int: 21

@mendhak
Copy link
Owner

mendhak commented Aug 14, 2015

Two Moto Gs, similar problems. Hmm.

Was your device asleep for a while when this happens?

@mendhak mendhak changed the title Doesn't work anymore ALARM_COUNT expected Integer but value was a java.lang.Long - GPSLogger stops Aug 14, 2015
mendhak added a commit that referenced this issue Aug 14, 2015
@naoliv
Copy link

naoliv commented Aug 14, 2015

What I always do: start gpslogger, close it (it keeps running in background) and then I lock the phone.
I have recorded this last logcat and I can send it to you, if you want.

mendhak added a commit that referenced this issue Aug 14, 2015
@mendhak
Copy link
Owner

mendhak commented Aug 14, 2015

Thanks but no need for that, the documentation says one thing, the phone does something else. 😭

I've put a try catch around that bit, it's the best I can do. Here is a test APK if you want to try it.

https://www.dropbox.com/s/m74rez6qlserqfe/gpslogger-65-logview.apk?dl=0

Note that this is from my working branch so... there may be a few features not yet released.

@naoliv
Copy link

naoliv commented Aug 14, 2015

Will test it and get back to you later.

@ciakpey
Copy link
Contributor Author

ciakpey commented Aug 14, 2015

I have this error:

08-14 21:48:11.479    2805-2805/? W/Bundle﹕ Key android.intent.extra.ALARM_COUNT expected Integer but value was a java.lang.Long.  The default value 0 was returned.
08-14 21:48:11.482      854-854/? V/AlarmManager﹕ done {18c71ddb, *walarm*:com.mendhak.gpslogger/.GpsLoggingService} [6ms]
08-14 21:48:11.485    2805-2805/? W/Bundle﹕ Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
            at android.os.BaseBundle.getInt(BaseBundle.java:800)
            at android.os.BaseBundle.getInt(BaseBundle.java:782)
            at com.mendhak.gpslogger.GpsLoggingService.HandleIntent(GpsLoggingService.java:283)
            at com.mendhak.gpslogger.GpsLoggingService.onStartCommand(GpsLoggingService.java:163)
            at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2924)
            at android.app.ActivityThread.access$2100(ActivityThread.java:155)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1415)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5343)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

The error appears only one time in the logs, after that nothing seems to happen and no point are recorded

@naoliv
Copy link

naoliv commented Aug 14, 2015

Indeed, still seeing this:

08-14 20:16:17.393 W/Bundle  ( 8535): Key android.intent.extra.ALARM_COUNT expected Integer but value was a java.lang.Long.  The default value 0 was returned.
08-14 20:16:17.402 W/Bundle  ( 8535): Attempt to cast generated internal exception:
08-14 20:16:17.402 W/Bundle  ( 8535): java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
08-14 20:16:17.402 W/Bundle  ( 8535):   at android.os.BaseBundle.getInt(BaseBundle.java:800)
08-14 20:16:17.402 W/Bundle  ( 8535):   at android.os.BaseBundle.getInt(BaseBundle.java:782)
08-14 20:16:17.402 W/Bundle  ( 8535):   at com.mendhak.gpslogger.GpsLoggingService.HandleIntent(GpsLoggingService.java:283)
08-14 20:16:17.402 W/Bundle  ( 8535):   at com.mendhak.gpslogger.GpsLoggingService.onStartCommand(GpsLoggingService.java:163)
08-14 20:16:17.402 W/Bundle  ( 8535):   at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2896)
08-14 20:16:17.402 W/Bundle  ( 8535):   at android.app.ActivityThread.access$2100(ActivityThread.java:148)
08-14 20:16:17.402 W/Bundle  ( 8535):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1390)
08-14 20:16:17.402 W/Bundle  ( 8535):   at android.os.Handler.dispatchMessage(Handler.java:102)
08-14 20:16:17.402 W/Bundle  ( 8535):   at android.os.Looper.loop(Looper.java:135)
08-14 20:16:17.402 W/Bundle  ( 8535):   at android.app.ActivityThread.main(ActivityThread.java:5312)
08-14 20:16:17.402 W/Bundle  ( 8535):   at java.lang.reflect.Method.invoke(Native Method)
08-14 20:16:17.402 W/Bundle  ( 8535):   at java.lang.reflect.Method.invoke(Method.java:372)
08-14 20:16:17.402 W/Bundle  ( 8535):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
08-14 20:16:17.402 W/Bundle  ( 8535):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)

@mendhak
Copy link
Owner

mendhak commented Aug 15, 2015

(Deleted my previous comment please see this instead):

Did the log file show a Received a weird EXTRA_ALARM_COUNT message just before the block you pasted?

Let's try again - new APK: https://dl.dropboxusercontent.com/u/51905631/gpslogger-65-logview3.apk

To be sure it's the right version, the General menu version should show GPSLogger version 65-logview3

mendhak added a commit that referenced this issue Aug 15, 2015
@ciakpey
Copy link
Contributor Author

ciakpey commented Aug 15, 2015

Nop I don't have that in the log file

On 15/08/2015 09:08, mendhak wrote:

(Deleted my previous comment please see this instead):

Did the log file show a |Received a weird EXTRA_ALARM_COUNT| message
just before the block you pasted?

Let's try again - new APK:
https://dl.dropboxusercontent.com/u/51905631/gpslogger-65-logview3.apk

To be sure it's the right version, the General menu version should
show |GPSLogger version 65-logview3|


Reply to this email directly or view it on GitHub
#337 (comment).

@mendhak
Copy link
Owner

mendhak commented Aug 15, 2015

Do you have the right version - General menu should say "GPSLogger version 65-logview3"

@ciakpey
Copy link
Contributor Author

ciakpey commented Aug 15, 2015

yes of course,
But the debug information we posted are from logcat, not from the
logfile that gpslogger create (in fact in this logfile there are almost
no information)

On 15/08/2015 11:19, mendhak wrote:

Do you have the right version - General menu should say "GPSLogger
version 65-logview3"


Reply to this email directly or view it on GitHub
#337 (comment).

@mendhak
Copy link
Owner

mendhak commented Aug 16, 2015

If you are still playing with the code, can you try this, go and change

if(bundle.getInt(Intent.EXTRA_ALARM_COUNT) != 0){

to

if(bundle.get(Intent.EXTRA_ALARM_COUNT) != "0"){

This treats the value like an object, compares to string.

@naoliv
Copy link

naoliv commented Aug 16, 2015

I can't compile the APK but I can test without any problem if you create one.

@mendhak
Copy link
Owner

mendhak commented Aug 16, 2015

OK I've uploaded a new APK:

https://www.dropbox.com/s/4btz34gowc4ja77/gpslogger-65-logview4.apk?dl=0

Make sure that the version says GPSLogger version 65-logview4. If it fails, logcat should show Received a weird EXTRA_ALARM_COUNT value. Cannot continue.

mendhak added a commit that referenced this issue Aug 16, 2015
@ciakpey
Copy link
Contributor Author

ciakpey commented Aug 16, 2015

Haha that makes sens, but now it works !!
no more error, it just works as expected, but I agree with you the
behavior is very weird!
Thanks a lot !

On 16/08/2015 20:21, mendhak wrote:

OK I've uploaded a new APK:

https://www.dropbox.com/s/4btz34gowc4ja77/gpslogger-65-logview4.apk?dl=0

Make sure that the version says |GPSLogger version 65-logview4|. If it
fails, logcat should show |Received a weird EXTRA_ALARM_COUNT value.
Cannot continue.|


Reply to this email directly or view it on GitHub
#337 (comment).

@naoliv
Copy link

naoliv commented Aug 16, 2015

Seems good too.

@mendhak
Copy link
Owner

mendhak commented Aug 16, 2015

OK if that works I'll just... leave it in there for the next release. I even had a hunt through the Android source code to see what's going on - it's an int. It insists it's an int. Theoretically nothing should be different in MotoG Lollipop.

They should do an X-Files episode on this.

@mendhak
Copy link
Owner

mendhak commented Aug 16, 2015

v66 released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants