mymikemiller / a-simple-lastfm-scrobbler

Automatically exported from code.google.com/p/a-simple-lastfm-scrobbler
GNU General Public License v3.0
0 stars 0 forks source link

ClassCastException: java.lang.Long error on playback resume or pause #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Press Play/Pause button in Music Player
2. adb logcat lists these errors everytime the play/pause button is pressed

I/ActivityManager(  139): Starting activity: Intent {
cmp=com.android.music/.MediaPlaybackActivity }
I/ActivityManager(  139): Displayed activity
com.android.music/.MediaPlaybackActivity: 496 ms (total 496 ms)
I/ActivityManager(  139): Start proc com.adam.aslfms for broadcast
com.adam.aslfms/.receiver.AndroidMusicReceiver: pid=7
73 uid=10038 gids={3003, 1015}
W/AudioFlinger(  120): write blocked for 92 msecs
I/ActivityManager(  139): Process com.android.vending (pid 641) has died.
D/SLSPlayStatusReceiver(  773): Action received was:
com.android.music.playstatechanged
W/Bundle  (  773): Key id expected Integer but value was a java.lang.Long.
 The default value -1 was returned.
W/Bundle  (  773): Attempt to cast generated internal exception:
W/Bundle  (  773): java.lang.ClassCastException: java.lang.Long
W/Bundle  (  773):      at android.os.Bundle.getInt(Bundle.java:855)
W/Bundle  (  773):      at
com.adam.aslfms.receiver.AndroidMusicReceiver.parseIntent(AndroidMusicReceiver.j
ava:60)
W/Bundle  (  773):      at
com.adam.aslfms.receiver.AbstractPlayStatusReceiver.onReceive(AbstractPlayStatus
Receiver.java
:78)
W/Bundle  (  773):      at
android.app.ActivityThread.handleReceiver(ActivityThread.java:2605)
W/Bundle  (  773):      at
android.app.ActivityThread.access$3100(ActivityThread.java:118)
W/Bundle  (  773):      at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1884)
W/Bundle  (  773):      at android.os.Handler.dispatchMessage(Handler.java:99)
W/Bundle  (  773):      at android.os.Looper.loop(Looper.java:123)
W/Bundle  (  773):      at
android.app.ActivityThread.main(ActivityThread.java:4320)
W/Bundle  (  773):      at java.lang.reflect.Method.invokeNative(Native Method)
W/Bundle  (  773):      at java.lang.reflect.Method.invoke(Method.java:521)
W/Bundle  (  773):      at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
W/Bundle  (  773):      at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
W/Bundle  (  773):      at dalvik.system.NativeStart.main(Native Method)
D/ScrobblingService(  773): State: RESUME
D/Handshaker(  773): Handshaking: Last.fm
D/dalvikvm(  773): GC freed 3184 objects / 229728 bytes in 121ms
I/Handshaker(  773): Handshake succeeded!: Last.fm
D/NPNotifier(  773): Notifying now playing: Last.fm
D/NPNotifier(  773): Last.fm: Track [mArtist=Frank Legree, mAlbum=Rhythm
Heaven Domestic and Overseas Editions Complete
Vocal Collection, mTrack=Staff Credits (That's Paradise), mDuration=180,
mMbId=, mMusicApp=MusicAPI [clashWithScrobbleDr
oid=1, enabled=1, id=1, msg=null, name=Android Music Player,
pkg=com.android.music], mQueued=false, mRowId=-1, mSource=P
, mTimePlayed=0, mTracknr=, mUnknownDuration=true, mWhen=1265769397]
I/NPNotifier(  773): Nowplaying success: Last.fm
D/dalvikvm(  773): GC freed 1569 objects / 572688 bytes in 114ms
D/SLSPlayStatusReceiver(  773): Action received was:
com.android.music.playstatechanged
W/Bundle  (  773): Key id expected Integer but value was a java.lang.Long.
 The default value -1 was returned.
W/Bundle  (  773): Attempt to cast generated internal exception:
W/Bundle  (  773): java.lang.ClassCastException: java.lang.Long
W/Bundle  (  773):      at android.os.Bundle.getInt(Bundle.java:855)
W/Bundle  (  773):      at
com.adam.aslfms.receiver.AndroidMusicReceiver.parseIntent(AndroidMusicReceiver.j
ava:60)
W/Bundle  (  773):      at
com.adam.aslfms.receiver.AbstractPlayStatusReceiver.onReceive(AbstractPlayStatus
Receiver.java
:78)
W/Bundle  (  773):      at
android.app.ActivityThread.handleReceiver(ActivityThread.java:2605)
W/Bundle  (  773):      at
android.app.ActivityThread.access$3100(ActivityThread.java:118)
W/Bundle  (  773):      at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1884)
W/Bundle  (  773):      at android.os.Handler.dispatchMessage(Handler.java:99)
W/Bundle  (  773):      at android.os.Looper.loop(Looper.java:123)
W/Bundle  (  773):      at
android.app.ActivityThread.main(ActivityThread.java:4320)
W/Bundle  (  773):      at java.lang.reflect.Method.invokeNative(Native Method)
W/Bundle  (  773):      at java.lang.reflect.Method.invoke(Method.java:521)
W/Bundle  (  773):      at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
W/Bundle  (  773):      at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
W/Bundle  (  773):      at dalvik.system.NativeStart.main(Native Method)
D/ScrobblingService(  773): State: RESUME
D/ScrobblingService(  773): Won't queue track, not played long enough: 3429
vs 30000
D/ScrobblingService(  773): Track [mArtist=Frank Legree, mAlbum=Rhythm
Heaven Domestic and Overseas Editions Complete Vo
cal Collection, mTrack=Staff Credits (That's Paradise), mDuration=180,
mMbId=, mMusicApp=MusicAPI [clashWithScrobbleDroi
d=1, enabled=1, id=1, msg=null, name=Android Music Player,
pkg=com.android.music], mQueued=false, mRowId=-1, mSource=P,
mTimePlayed=3429, mTracknr=, mUnknownDuration=true, mWhen=1265769397]
D/skia    (  480): purging 6K from font cache [1 entries]
D/dalvikvm(  480): GC freed 2908 objects / 153976 bytes in 128ms
D/skia    (  139): purging 102K from font cache [12 entries]
D/dalvikvm(  139): GC freed 12203 objects / 665632 bytes in 210ms
D/SLSPlayStatusReceiver(  773): Action received was:
com.android.music.playstatechanged
W/AudioFlinger(  120): write blocked for 96 msecs
W/Bundle  (  773): Key id expected Integer but value was a java.lang.Long.
 The default value -1 was returned.
W/Bundle  (  773): Attempt to cast generated internal exception:
W/Bundle  (  773): java.lang.ClassCastException: java.lang.Long
W/Bundle  (  773):      at android.os.Bundle.getInt(Bundle.java:855)
W/Bundle  (  773):      at
com.adam.aslfms.receiver.AndroidMusicReceiver.parseIntent(AndroidMusicReceiver.j
ava:60)
W/Bundle  (  773):      at
com.adam.aslfms.receiver.AbstractPlayStatusReceiver.onReceive(AbstractPlayStatus
Receiver.java
:78)
W/Bundle  (  773):      at
android.app.ActivityThread.handleReceiver(ActivityThread.java:2605)
W/Bundle  (  773):      at
android.app.ActivityThread.access$3100(ActivityThread.java:118)
W/Bundle  (  773):      at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1884)
W/Bundle  (  773):      at android.os.Handler.dispatchMessage(Handler.java:99)
W/Bundle  (  773):      at android.os.Looper.loop(Looper.java:123)
W/Bundle  (  773):      at
android.app.ActivityThread.main(ActivityThread.java:4320)
W/Bundle  (  773):      at java.lang.reflect.Method.invokeNative(Native Method)
W/Bundle  (  773):      at java.lang.reflect.Method.invoke(Method.java:521)
W/Bundle  (  773):      at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
W/Bundle  (  773):      at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
W/Bundle  (  773):      at dalvik.system.NativeStart.main(Native Method)
D/ScrobblingService(  773): State: RESUME
D/ScrobblingService(  773): Won't queue track, not played long enough:
13965 vs 30000
D/ScrobblingService(  773): Track [mArtist=Frank Legree, mAlbum=Rhythm
Heaven Domestic and Overseas Editions Complete Vo
cal Collection, mTrack=Staff Credits (That's Paradise), mDuration=180,
mMbId=, mMusicApp=MusicAPI [clashWithScrobbleDroi
d=1, enabled=1, id=1, msg=null, name=Android Music Player,
pkg=com.android.music], mQueued=false, mRowId=-1, mSource=P,
mTimePlayed=13965, mTracknr=, mUnknownDuration=true, mWhen=1265769397]
D/dalvikvm(  752): GC freed 4500 objects / 329024 bytes in 260ms
D/NetworkLocationProvider(  139): onCellLocationChanged [5102,44403]
D/SLSPlayStatusReceiver(  773): Action received was:
com.android.music.playstatechanged
W/Bundle  (  773): Key id expected Integer but value was a java.lang.Long.
 The default value -1 was returned.
W/Bundle  (  773): Attempt to cast generated internal exception:
W/Bundle  (  773): java.lang.ClassCastException: java.lang.Long
W/Bundle  (  773):      at android.os.Bundle.getInt(Bundle.java:855)
W/Bundle  (  773):      at
com.adam.aslfms.receiver.AndroidMusicReceiver.parseIntent(AndroidMusicReceiver.j
ava:60)
W/Bundle  (  773):      at
com.adam.aslfms.receiver.AbstractPlayStatusReceiver.onReceive(AbstractPlayStatus
Receiver.java
:78)
W/Bundle  (  773):      at
android.app.ActivityThread.handleReceiver(ActivityThread.java:2605)
W/Bundle  (  773):      at
android.app.ActivityThread.access$3100(ActivityThread.java:118)
W/Bundle  (  773):      at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1884)
W/Bundle  (  773):      at android.os.Handler.dispatchMessage(Handler.java:99)
W/Bundle  (  773):      at android.os.Looper.loop(Looper.java:123)
W/Bundle  (  773):      at
android.app.ActivityThread.main(ActivityThread.java:4320)
W/Bundle  (  773):      at java.lang.reflect.Method.invokeNative(Native Method)
W/Bundle  (  773):      at java.lang.reflect.Method.invoke(Method.java:521)
W/Bundle  (  773):      at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
W/Bundle  (  773):      at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
W/Bundle  (  773):      at dalvik.system.NativeStart.main(Native Method)
D/ScrobblingService(  773): State: RESUME
D/ScrobblingService(  773): Won't queue track, not played long enough:
16944 vs 30000
D/ScrobblingService(  773): Track [mArtist=Frank Legree, mAlbum=Rhythm
Heaven Domestic and Overseas Editions Complete Vo
cal Collection, mTrack=Staff Credits (That's Paradise), mDuration=180,
mMbId=, mMusicApp=MusicAPI [clashWithScrobbleDroi
d=1, enabled=1, id=1, msg=null, name=Android Music Player,
pkg=com.android.music], mQueued=false, mRowId=-1,
mSource=P,mTimePlayed=16944, mTracknr=, mUnknownDuration=true,
mWhen=1265769397]

What is the expected output? What do you see instead?
Not to see ClassCastException errors?

What version of the product are you using? On what operating system?
v1.2.6 of SLS on CyanogenMod-4.2.14.1, T-Moblie G1

Please provide any additional information below.

Original issue reported on code.google.com by logan.gba on 10 Feb 2010 at 2:47

GoogleCodeExporter commented 9 years ago
Yes, I've encountered this problem myself, and I'll relese a version of SLS 
soon that
will have a fix for it. It isn't critical though, as scrobbling still functions 
properly.

The reason this ClassCastException is thrown is that in early versions of 
Android
(e.g. 1.5) the default music player broadcasts the AudioStore id as an int, but 
in
later versions (e.g. 2.1) it broadcasts it as a long. And apparently the Bundle 
class
doesn't automatically convert ints to longs, or vice versa.

(Which it probably shouldn't, but it's kind of inconsiderate of the Android
developers to change the type just like that - although perhaps I shouldn't 
depend on
such things).

So, a fix will be released soon.

Original comment by tgwizard on 10 Feb 2010 at 6:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Oh btw, thanks for the bug report!

Original comment by tgwizard on 10 Feb 2010 at 6:20

GoogleCodeExporter commented 9 years ago
Should now be fixed in v1.2.7. Sorry it took so long.

Original comment by tgwizard on 28 Feb 2010 at 11:14