question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash on Android - Can only use lower 16 bits for requestCode

See original GitHub issue

The app crashes on Android with the following stack trace:

java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
    at android.support.v4.app.BaseFragmentActivityApi14.checkForValidRequestCode(BaseFragmentActivityApi14.java:79)
    at android.support.v4.app.BaseFragmentActivityApi14.startIntentSenderForResult(BaseFragmentActivityApi14.java:66)
    at android.support.v4.app.FragmentActivity.startIntentSenderForResult(FragmentActivity.java:67)
    at com.google.android.gms.common.api.Status.startResolutionForResult
    at com.google.android.gms.common.api.ResolvableApiException.startResolutionForResult
    at com.google.android.gms.wallet.AutoResolveHelper.zza
    at com.google.android.gms.wallet.AutoResolveHelper.zzb
    at com.google.android.gms.wallet.AutoResolveHelper$zzb.zze
    at com.google.android.gms.wallet.AutoResolveHelper$zzb.zza
    at com.google.android.gms.wallet.AutoResolveHelper$zza.zzbjy
    at com.google.android.gms.wallet.AutoResolveHelper$zza.onComplete
    at com.google.android.gms.tasks.zzf.run
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

FragmentActivity requires the requestCode to be of 16 bits, meaning the range is from 0 to 65535. So when calling AutoResolveHelper.resolveTask, the requestCode passed to it must be between 0 and 65535… but it’s 100500. It works if i change the value to anything less than or equal to 65535.

EDIT: the constant that I’m talking about is LOAD_PAYMENT_DATA_REQUEST_CODE

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
isnifercommented, May 31, 2018

@brilliantjc understood. We will do PR tomorrow or you can do it now

1reaction
brilliantjccommented, May 31, 2018

SO: find this document screen shot 2018-05-31 at 3 24 25 pm

screen shot 2018-05-31 at 3 18 59 pm

change this LOAD_PAYMENT_DATA_REQUEST_CODE to lower than 65535

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can only use lower 16 bits for requestCode - Stack Overflow
The problem has been fixed in the latest version of activity (1.2.7-alpha07). now it's warning you about adding both activity and fragment ...
Read more >
Can only use lower 16 bits for requestCode | by Anum Amin
ActivityResultLauncher Crash — Can only use lower 16 bits for requestCode. I was trying a new way of writing runtime permissions on Android....
Read more >
Can only use lower 16 bits for requestCode - Forums
My app uses ACRA for error reporting, and I've got a couple of reports from kindles with the error: Can only use lower...
Read more >
Can only use lower 16 bits for requestCode-android-Java
[Solved]-Android app crash: java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode-android-Java ... I found some others questions in the ...
Read more >
Android – ACRA exception Can only use lower 16 bits for ... - iTecNote
My app uses ACRA for error reporting, and I've got a couple of reports from my device with the error: Can only use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found