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

ART Runtime ArrayIndexOutOfBoundsException when instantiating Call object #1486

Closed
danmikita opened this Issue Jan 18, 2016 · 23 comments

Comments

@danmikita

danmikita commented Jan 18, 2016

This is a crazy error I am getting that I am having an incredibly difficult time debugging. I have determined that it is thrown when trying to instantiate the Call object itself, and not when calling enqueue.

This error also doesn't occur on all of my Calls either, just on one in particular. This is what made me think it was something I was personally doing wrong, but I can't find the problem, which leads me to believe there might just be a problem with Call? If I'm crazy let me know.

Thank you in advance!

The error:

01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344] Throwing new exception 'length=248; index=1273' with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=248; index=1273
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void com.lifeisgreaterthan.checkblocks.activity.FindEventActivity.postStory() (FindEventActivity.java:46)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void com.lifeisgreaterthan.checkblocks.activity.FindEventActivity$$ViewBinder$1.doClick(android.view.View) (FindEventActivity$$ViewBinder.java:17)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void butterknife.internal.DebouncingOnClickListener.onClick(android.view.View) (DebouncingOnClickListener.java:22)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at boolean android.view.View.performClick() (View.java:5204)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void android.view.View$PerformClick.run() (View.java:21153)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:739)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void android.os.Looper.loop() (Looper.java:148)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:5417)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:726)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344]   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:616)
01-17 21:52:18.466 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/thread.cc:1344] 
01-17 21:52:18.676 21705-21711/com.lifeisgreaterthan.checkblocks W/art: Suspending all threads took: 170.654ms
01-17 21:52:18.711 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/barrier.cc:90] Check failed: count_ == 0 (count_=-1, 0=0) Attempted to destroy barrier with non zero count
01-17 21:52:18.711 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/runtime.cc:366] Runtime aborting --- recursively, so no thread-specific detail!
01-17 21:52:18.711 21705-21705/com.lifeisgreaterthan.checkblocks A/art: art/runtime/runtime.cc:366] 
01-17 21:52:18.711 21705-21705/com.lifeisgreaterthan.checkblocks A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 21705 (han.checkblocks)

Retrofit API:

@POST("/_ah/api/story/v1/create")
    Call<CreateStoryResponse> createStory(@Query("event_id") String eventId);

Where I am calling it:

eventFeedController.getSmashHoundApi().createStory("5695159920492544").enqueue(new Callback<CreateStoryResponse>() {
            @Override
            public void onResponse(retrofit.Response<CreateStoryResponse> response, Retrofit retrofit) {
                RequestBody media;

                if (eventFeedController.getCurrentMediaFileType() == CameraHelper.MEDIA_TYPE_IMAGE) {
                    media = RequestBody.create(MediaType.parse("image/jpeg"), eventFeedController.getCurrentMediaFile());
                    uploadImage(response.body().getUploadUrl(), media);
                } else {
                    media = RequestBody.create(MediaType.parse("video/mp4"), eventFeedController.getCurrentMediaFile());
                    uploadVideo(response.body().getUploadUrl(), media);
                }
            }
@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Jan 18, 2016

Collaborator

What's on line 46 of FindEventActivity? This doesn't appear to have anything to do with Retrofit.

Collaborator

JakeWharton commented Jan 18, 2016

What's on line 46 of FindEventActivity? This doesn't appear to have anything to do with Retrofit.

@danmikita

This comment has been minimized.

Show comment
Hide comment
@danmikita

danmikita Jan 18, 2016

@JakeWharton Line 46 is: eventFeedController.getSmashHoundApi().createStory("5695159920492544").enqueue(new Callback<CreateStoryResponse>() {

danmikita commented Jan 18, 2016

@JakeWharton Line 46 is: eventFeedController.getSmashHoundApi().createStory("5695159920492544").enqueue(new Callback<CreateStoryResponse>() {

@danmikita

This comment has been minimized.

Show comment
Hide comment
@danmikita

danmikita Jan 18, 2016

@JakeWharton Like I said in my original message, I really don't think it has to do with retrofit either...but this stack trace only appears when I instantiate my Call object. Ultimately, I feel like I am doing something wrong with the call object. But I'm just not seeing it...its unfortunate that the logcat is so unhelpful.

danmikita commented Jan 18, 2016

@JakeWharton Like I said in my original message, I really don't think it has to do with retrofit either...but this stack trace only appears when I instantiate my Call object. Ultimately, I feel like I am doing something wrong with the call object. But I'm just not seeing it...its unfortunate that the logcat is so unhelpful.

@letos

This comment has been minimized.

Show comment
Hide comment
@letos

letos Jan 18, 2016

Perhaps it will help.
I had the same error and fixed it by switching gradle plugin version from '2.0.0-alpha5' to lower.
So take look at your project configuration.

letos commented Jan 18, 2016

Perhaps it will help.
I had the same error and fixed it by switching gradle plugin version from '2.0.0-alpha5' to lower.
So take look at your project configuration.

@danmikita

This comment has been minimized.

Show comment
Hide comment
@danmikita

danmikita Jan 18, 2016

I love the open source community...so helpful.

@letos What version did you change yours to? com.android.tools.build:gradle:2.0.0-alpha5 ?

danmikita commented Jan 18, 2016

I love the open source community...so helpful.

@letos What version did you change yours to? com.android.tools.build:gradle:2.0.0-alpha5 ?

@sergeyfitis

This comment has been minimized.

Show comment
Hide comment
@sergeyfitis

sergeyfitis Jan 18, 2016

I have same issue. After downgrade gradle version to alpha3 it fixed.

sergeyfitis commented Jan 18, 2016

I have same issue. After downgrade gradle version to alpha3 it fixed.

@letos

This comment has been minimized.

Show comment
Hide comment
@letos

letos Jan 18, 2016

danmikita, 'com.android.tools.build:gradle:2.0.0-alpha3'

letos commented Jan 18, 2016

danmikita, 'com.android.tools.build:gradle:2.0.0-alpha3'

@danmikita

This comment has been minimized.

Show comment
Hide comment
@danmikita

danmikita Jan 18, 2016

@letos @sergeyfitis You guys rock! Thank you! Is there a place to file an issue with alpha-5?

danmikita commented Jan 18, 2016

@letos @sergeyfitis You guys rock! Thank you! Is there a place to file an issue with alpha-5?

@sergeyfitis

This comment has been minimized.

Show comment
Hide comment
@sergeyfitis

sergeyfitis Jan 18, 2016

Is there a place to file an issue with alpha-5?

I don't know.

sergeyfitis commented Jan 18, 2016

Is there a place to file an issue with alpha-5?

I don't know.

@letos

This comment has been minimized.

Show comment
Hide comment
@letos

letos Jan 18, 2016

Is there a place to file an issue with alpha-5?

I don't know.

Same here.

letos commented Jan 18, 2016

Is there a place to file an issue with alpha-5?

I don't know.

Same here.

@danmikita

This comment has been minimized.

Show comment
Hide comment
@danmikita

danmikita Jan 18, 2016

I created a bug in the AOSP bug tracker. Thanks for your help! https://code.google.com/p/android/issues/detail?id=199105

danmikita commented Jan 18, 2016

I created a bug in the AOSP bug tracker. Thanks for your help! https://code.google.com/p/android/issues/detail?id=199105

@danmikita danmikita closed this Jan 18, 2016

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Jan 18, 2016

Collaborator

Cool, thanks 👍

Collaborator

JakeWharton commented Jan 18, 2016

Cool, thanks 👍

@aleksandrTmk

This comment has been minimized.

Show comment
Hide comment
@aleksandrTmk

aleksandrTmk Jan 22, 2016

Seeing same issue that points to retrofit. Using alpha 3 did not help.
Added comment onto the bug tracker.

We only see this issue when instant run in enabled.
Disable instant run or build from command line and everything works fine.

I also removed the api call causing crash for funsies.. No crash and all other calls
work correctly even with instant run enabled.

Perplexed.

aleksandrTmk commented Jan 22, 2016

Seeing same issue that points to retrofit. Using alpha 3 did not help.
Added comment onto the bug tracker.

We only see this issue when instant run in enabled.
Disable instant run or build from command line and everything works fine.

I also removed the api call causing crash for funsies.. No crash and all other calls
work correctly even with instant run enabled.

Perplexed.

huhx0015 added a commit to huhx0015/GitYourRxIssues that referenced this issue Jan 30, 2016

* Fixed a hard crash issue with API 23 devices by reverting the gradl…
…e build to 2.0.0-beta3. This is needed or compiled APKs that are installed on API 23 devices will crash when Retrofit is utilized. See issue here:

- square/retrofit#1486
- https://code.google.com/p/android/issues/detail?id=199105
* Removed AsyncTasks, as they are not needed. Using Retrofit's enqueue method instead.
* Removed API 23 workaround and IssuesUtil class.
@mbox

This comment has been minimized.

Show comment
Hide comment
@mbox

mbox May 20, 2016

I'm seeing the same problem (crash on instantiating the Call object) using gradle:2.1.0. Disabling instant run makes it work again.

So looks like an interaction between Call and Instant run

mbox commented May 20, 2016

I'm seeing the same problem (crash on instantiating the Call object) using gradle:2.1.0. Disabling instant run makes it work again.

So looks like an interaction between Call and Instant run

@plugie

This comment has been minimized.

Show comment
Hide comment
@plugie

plugie May 28, 2016

I use gradle 2.1.0. The problem only appear on my marshmallow device. But when I use emulator, the problem doesn't appear

plugie commented May 28, 2016

I use gradle 2.1.0. The problem only appear on my marshmallow device. But when I use emulator, the problem doesn't appear

@localhostEU

This comment has been minimized.

Show comment
Hide comment
@localhostEU

localhostEU Jun 2, 2016

Try to disable Instant run.

localhostEU commented Jun 2, 2016

Try to disable Instant run.

@jweaver

This comment has been minimized.

Show comment
Hide comment
@jweaver

jweaver Jun 6, 2016

I was having this same problem. I upgraded the gradle plugin to 2.2.0-alpha2 and it seems to have gone away.

The 2.2.x line of development might fix this. Not sure. I know alpha2 works for me in my situation.

https://bintray.com/android/android-tools/com.android.tools.build.gradle/

classpath 'com.android.tools.build:gradle:2.2.0-alpha2'

I'd recommend folks give that a try. And you can keep using instant run.

jweaver commented Jun 6, 2016

I was having this same problem. I upgraded the gradle plugin to 2.2.0-alpha2 and it seems to have gone away.

The 2.2.x line of development might fix this. Not sure. I know alpha2 works for me in my situation.

https://bintray.com/android/android-tools/com.android.tools.build.gradle/

classpath 'com.android.tools.build:gradle:2.2.0-alpha2'

I'd recommend folks give that a try. And you can keep using instant run.

@swanhtet1992

This comment has been minimized.

Show comment
Hide comment
@swanhtet1992

swanhtet1992 Jun 18, 2016

This is insane.

I was having this similar problem and thought that it was the Facebook Graph API error. For me, downgrading gradle version didn't solve the problem too.

I had to disable Instant Run and it magically solved now.

06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344] Throwing new exception 'length=127; index=1954' with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=127; index=1954
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void co.base.activity.RegisterActivity.registerSeller(org.json.JSONObject) (RegisterActivity.java:193)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void co.base.activity.RegisterActivity.access$100(co.base.activity.RegisterActivity, org.json.JSONObject) (RegisterActivity.java:53)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void co.base.activity.RegisterActivity$2.onCompleted(org.json.JSONObject, com.facebook.GraphResponse) (RegisterActivity.java:142)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void com.facebook.GraphRequest$1.onCompleted(com.facebook.GraphResponse) (GraphRequest.java:304)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void com.facebook.GraphRequest$5.run() (GraphRequest.java:1368)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:739)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void android.os.Looper.loop() (Looper.java:148)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:5417)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:726)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:616)

swanhtet1992 commented Jun 18, 2016

This is insane.

I was having this similar problem and thought that it was the Facebook Graph API error. For me, downgrading gradle version didn't solve the problem too.

I had to disable Instant Run and it magically solved now.

06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344] Throwing new exception 'length=127; index=1954' with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=127; index=1954
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void co.base.activity.RegisterActivity.registerSeller(org.json.JSONObject) (RegisterActivity.java:193)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void co.base.activity.RegisterActivity.access$100(co.base.activity.RegisterActivity, org.json.JSONObject) (RegisterActivity.java:53)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void co.base.activity.RegisterActivity$2.onCompleted(org.json.JSONObject, com.facebook.GraphResponse) (RegisterActivity.java:142)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void com.facebook.GraphRequest$1.onCompleted(com.facebook.GraphResponse) (GraphRequest.java:304)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void com.facebook.GraphRequest$5.run() (GraphRequest.java:1368)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:739)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void android.os.Looper.loop() (Looper.java:148)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:5417)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:726)
06-18 12:42:34.302 1920-1920/co.base.debug A/art: art/runtime/thread.cc:1344]   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:616)
@jfblanco

This comment has been minimized.

Show comment
Hide comment
@jfblanco

jfblanco Jun 24, 2016

Hi everyone, I have fixed this bug disabling "Instant Run", but: Is there any solution that doesn't means disable a good feature of Android Studio, or using a workarround?

It happens with MarshMallow devices. Could it be a permissions problem?

Thank for your comments, It was a huge help.

jfblanco commented Jun 24, 2016

Hi everyone, I have fixed this bug disabling "Instant Run", but: Is there any solution that doesn't means disable a good feature of Android Studio, or using a workarround?

It happens with MarshMallow devices. Could it be a permissions problem?

Thank for your comments, It was a huge help.

@Joisar

This comment has been minimized.

Show comment
Hide comment
@Joisar

Joisar Jul 2, 2016

I found it working fine even with "Insta Run" when I use @post annotation with @field annotation instead of @query .
I guess @query should be used with @get only.

@JakeWharton Please let me know if I am wrong about it.

Thanks,
Mehul.

Joisar commented Jul 2, 2016

I found it working fine even with "Insta Run" when I use @post annotation with @field annotation instead of @query .
I guess @query should be used with @get only.

@JakeWharton Please let me know if I am wrong about it.

Thanks,
Mehul.

@rohitsuratekar

This comment has been minimized.

Show comment
Hide comment
@rohitsuratekar

rohitsuratekar Jul 17, 2016

Same error here ! Any solution yet ?
Disabling "Instant Run" works but it is increasing development time.

rohitsuratekar commented Jul 17, 2016

Same error here ! Any solution yet ?
Disabling "Instant Run" works but it is increasing development time.

@andreykadatsky

This comment has been minimized.

Show comment
Hide comment
@andreykadatsky

andreykadatsky Jul 26, 2016

The same issue...

andreykadatsky commented Jul 26, 2016

The same issue...

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Jul 26, 2016

Collaborator

This is a build system problem, not a Retrofit problem. There is a bug filed in the appropriate place.

Collaborator

JakeWharton commented Jul 26, 2016

This is a build system problem, not a Retrofit problem. There is a bug filed in the appropriate place.

@square square locked and limited conversation to collaborators Jul 26, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.