我试图在我的PUT
实例上调用Retrofit
方法:
Response<UpdateUserProfileResponse> response = App.getService().updateUserProfile(//A good 26 parameters).execute();
updateUserProfile()
中的参数是String,Boolean和一个List<MyObject>
的混合。当我调用此方法时,我收到以下错误:
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
更新
我发现了这个问题。有两个RealmList<BackgroundString>
引起了这个问题。当我评估两个RealmLists时,我得到:
Unable to evaluate the expression method threw 'java.lang.IllegalStateException' exception.
对于其他任何绊倒这个问题的人来说,实际问题很可能就是:https://issuetracker.google.com/issues/37078190即Marshmallow上的Instant Run / 23(甚至可能是24)在android运行时出现问题。 Android 8/26 +有官方修复,但对于大多数人来说,禁用Instant Run应该足够了。
还重新: https://github.com/square/retrofit/issues/1486 https://github.com/square/retrofit/issues/1506
投掷新的例外'长度= 1120; index = 2310',带有意外的挂起异常:java.lang.ArrayIndexOutOfBoundsException:length = 1120;指数= 2310
它在Android Nougat和Oreo中运行良好,但我在Marshmallow遇到了这个问题。我只是通过关闭“即时运行”来修复它。通过转到文件 - >设置 - >构建,执行,部署 - >即时运行并禁用即时运行选项来执行此操作
我也面临同样的问题:
禁用Instant Run
解决了这个问题。
按照以下路径:
设置 - >构建,执行,开发 - >
Instant Run
如果您在后台线程或任何新的Handler()。postDelayed()中使用它,那么在UI线程中使用此API调用。
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 catch块中,就像我做的那样
Call<JsonObject> call = null;
try
{
call = apiService.getUserList(getUsersListRequestModel);
}
catch (Exception e)
{
e.printStackTrace();
}
}