Exception with Android when using ACRA
Asked Answered
S

1

1

My app uses ACRA for error reporting, and I've got a couple of reports from my device with the error: Can only use lower 16 bits for requestCode.. Google shows this error occurring when using startActivityForResult, but I've searched my code a few times and I"m not calling that anywhere.

I'm pretty confused and am wondering how this is impacting users (interestingly enough, the Crash Reports beta doesn't show any errors at all).

Anyone else run into this?

java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MyActivity}:  
java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2120)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:957)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
at android.support.v4.app.g.startActivityForResult(SourceFile:690)
at com.android.e.a.a(Unknown Source)
at com.android.e.e.a(Unknown Source)
at com.android.o.e.a(Unknown Source)
at com.android.o.b.a(Unknown Source)
at com.android.framework.context.d.a(Unknown Source)
at com.android.framework.context.d.onResume(Unknown Source)
at com.android.Kiwi.onResume(Unknown Source)
at com.myapp.MyActivity.onResume(SourceFile)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
at android.app.Activity.performResume(Activity.java:3832)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
... 10 more
java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode
at android.support.v4.app.g.startActivityForResult(SourceFile:690)
at com.android.e.a.a(Unknown Source)
at com.android.e.e.a(Unknown Source)
at com.android.o.e.a(Unknown Source)
at com.android.o.b.a(Unknown Source)
at com.android.framework.context.d.a(Unknown Source)
at com.android.framework.context.d.onResume(Unknown Source)
at com.android.Kiwi.onResume(Unknown Source)
at com.myapp.MyActivity.onResume(SourceFile)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
at android.app.Activity.performResume(Activity.java:3832)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:957)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

Can somebody help me on this?

Spelt answered 17/1, 2013 at 11:23 Comment(1)
Are you using google maps v2? I believe this is a bug associated with it.Rusch
S
9

From the FragmentActivity Source code:

/**
* Modifies the standard behavior to allow results to be delivered to fragments.
* This imposes a restriction that requestCode be <= 0xffff.
*/
@Override
public void startActivityForResult(Intent intent, int requestCode) {
    if (requestCode != -1 && (requestCode&0xffff0000) != 0) {
        throw new IllegalArgumentException("Can only use lower 16 bits for requestCode");
    }
    super.startActivityForResult(intent, requestCode);
}

It seems that your request code can only go upto 0xffff, which translates into 65535 for us base 10 obsessed humans.

Subtropical answered 17/1, 2013 at 11:36 Comment(5)
You're using ACRA in dialog notification mode, I take it. That causes ACRA to call startActivityForResult(), resulting in your exception.Subtropical
Um, ACRA doesn't call #startActivityForResult at any time. At least not in ACRA 4.4.0 and later. But if you show more of your stacktrace above we will see the real culprit. This doesn't seem to have anything to do with ACRA.Bissau
@Bissau I must be mistaken then.Subtropical
I have added the complete stack trace nowSpelt
Hi William, Can you please help me on this?Spelt

© 2022 - 2024 — McMap. All rights reserved.