googlesamples/androidtv-sample-inputs

PersistableBundle.putBoolean crashes on API 21

Fleker opened this issue · 0 comments

When running this project on an old ADT-1 (API version 21), I noticed it crashes when I try to sync the channels. When I look at the EpgSyncJobService class, the two lines (330-331):

persistableBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
persistableBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);

have putBoolean highlighted in red and provide the message: "Call requires API 22 (current min is 21): android.os.BaseBundle#putBoolean" (This call seems to available back to API 1 according to the API Reference: https://developer.android.com/reference/android/os/BaseBundle.html#putBoolean(java.lang.String, boolean) )

It seems like I can call those two lines only if the API version is above 21, and I can submit a PR for that. The two settings don't seem to be essential for the task to run.

Stacktrace is below:

01-25 01:37:04.928 15675-15675/com.example.android.sampletvinput E/AndroidRuntime: FATAL EXCEPTION: main
                                                                               Process: com.example.android.sampletvinput, PID: 15675
                                                                               java.lang.IllegalAccessError: Method 'void android.os.BaseBundle.putBoolean(java.lang.String, boolean)' is inaccessible to class 'com.google.android.media.tv.companionlibrary.EpgSyncJobService' (declaration of 'com.google.android.media.tv.companionlibrary.EpgSyncJobService' appears in /data/app/com.example.android.sampletvinput-1/base.apk)
                                                                                   at com.google.android.media.tv.companionlibrary.EpgSyncJobService.requestImmediateSync(EpgSyncJobService.java:330)
                                                                                   at com.google.android.media.tv.companionlibrary.EpgSyncJobService.requestImmediateSync(EpgSyncJobService.java:298)
                                                                                   at com.example.android.sampletvinput.rich.RichSetupFragment.onScanStarted(RichSetupFragment.java:67)
                                                                                   at com.google.android.media.tv.companionlibrary.ChannelSetupFragment.onStart(ChannelSetupFragment.java:187)
                                                                                   at android.app.Fragment.performStart(Fragment.java:2077)
                                                                                   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:922)
                                                                                   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
                                                                                   at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1049)
                                                                                   at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:1874)
                                                                                   at android.app.Activity.performStart(Activity.java:5955)
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
                                                                                   at android.app.ActivityThread.access$800(ActivityThread.java:144)
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                   at android.os.Looper.loop(Looper.java:135)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5221)
                                                                                   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:899)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)