【发布时间】:2018-09-11 09:46:41
【问题描述】:
我正在尝试使用retrofit 拨打POST 电话。它在某些设备上运行良好,但在操作系统版本为6.0.1 的 Nexus 5 上崩溃。
但现在我面临一个例外
art/runtime/thread.cc:1344] 抛出新异常 'length=1903; index=3147' 出现意外未决异常: java.lang.ArrayIndexOutOfBoundsException:长度=1903;索引=3147
我知道有很多问题但是对我没有任何帮助。 我按照this、this 和 this 等给定的帖子尝试了所有操作。有些人通过禁用 Instant Run 解决了这个问题。但这对我不起作用。
我正在使用这些依赖项进行改造:
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
这是我的项目级 gradle 文件:
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.0.1'
这是我得到ArrayIndexOutOfBoundsException的API调用
APIClient.getAPIService().getEffects(Constants.apiKey).enqueue(//callback);
这是我声明调用的 API 接口:
@FormUrlEncoded
@POST("/getEffects")
Call<GetEffectResp> getEffects(@Field("apikey") String apikey);
如果有人解决了这个问题,请帮我弄清楚。
TIA
【问题讨论】:
-
也贴出相关代码
-
@VivekMishra 我已经添加了我得到异常 APIClient.getAPIService().getEffects(Constants.apiKey) 的代码。你需要什么让我知道?所以,我可以更新问题。
-
您能分享一下 JSON 响应吗?
-
@AtifAbbAsi 应用在 API 命中前崩溃。
-
@Sunny 其他 API 工作正常吗?
标签: java android retrofit2 indexoutofboundsexception