I am trying to call a PUT
method on my Retrofit
instance:
Response<UpdateUserProfileResponse> response = App.getService().updateUserProfile(//A good 26 parameters).execute();
The parameters in the updateUserProfile()
are a mixture of String, Boolean and one List<MyObject>
. When I call this method, I get the following error:
Throwing new exception 'length=238; index=1366' with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=238; index=1366
06-28 21:53:12.458 3928-6610/com.subby.development A/art: art/runtime/thread.cc:1329] at retrofit2.Response
Update
I found the issue. There are two RealmList<BackgroundString>
which are causing the issue. When I evaluate both RealmLists, I get:
Unable to evaluate the expression method threw 'java.lang.IllegalStateException' exception.
For anyone else stumbling upon this question, the actual issue most likely is this: https://issuetracker.google.com/issues/37078190
i.e. Instant Run on Marshmallow/23 (and maybe even 24) has issues in the android runtime. Android 8/26+ have an official fix, but for most people disabling Instant Run should be sufficient.
also re:
https://github.com/square/retrofit/issues/1486
https://github.com/square/retrofit/issues/1506
Throwing new exception 'length=1120; index=2310' with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=1120; index=2310
It's working fine in Android Nougat and Oreo but i was facing the issue in Marshmallow.I just fixed it by turning off the "Instant run". Do it by going to
File->Settings -> Build, Execution, Deployment -> Instant Run and disable the instant run option
I am also facing same issue:
Disable Instant Run
solves the problem.
Follow path below:
Setting ->Build,Execution,Development -> Instant Run
If you are using this in background thread or any new Handler().postDelayed() then use this API call in UI Thread.
runOnUiThread(new Runnable() {
@Override
public void run() {
APIClient.getAPIService().getEffects(Constants.apiKey).enqueue(new Callback<POJOCLASS>() {
@Override
public void onResponse(Call<POJOCLASS> call, Response<POJOCLASS> response) {
if (response.body().error.msg == null) {
}
}
@Override
public void onFailure(Call<POJOCLASS> call, Throwable t) {
}
});
}
});
try this code
wrap your code into try catch block, like i did for example
Call<JsonObject> call = null;
try
{
call = apiService.getUserList(getUsersListRequestModel);
}
catch (Exception e)
{
e.printStackTrace();
}
}