如何解决为什么我在从 1.0.0-alpha 升级到 1.0.0 后收到“ApolloParseException”?
我目前正在将旧项目的 Apollo 版本从 1.0.0-alpha 升级到 1.0.0。
升级后出现此异常
com.apollographql.apollo.exception.ApolloParseException: Failed to parse http response
at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor.parse(ApolloParseInterceptor.java:101)
at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor$1.onResponse(ApolloParseInterceptor.java:53)
at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor$1$1.onResponse(ApolloServerInterceptor.java:106)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.io.EOFException: End of input
at com.apollographql.apollo.internal.json.BufferedSourceJsonReader.nextNonWhitespace(BufferedSourceJsonReader.java:946)
at com.apollographql.apollo.internal.json.BufferedSourceJsonReader.doPeek(BufferedSourceJsonReader.java:332)
at com.apollographql.apollo.internal.json.BufferedSourceJsonReader.beginObject(BufferedSourceJsonReader.java:169)
at com.apollographql.apollo.response.OperationResponseParser.parse(OperationResponseParser.java:82)
at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor.parse(ApolloParseInterceptor.java:87)
at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor$1.onResponse(ApolloParseInterceptor.java:53)
at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor$1$1.onResponse(ApolloServerInterceptor.java:106)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
但是在我升级之前一切都很好。由于 Firebase Crashlytics 迁移,我升级了 Gradle,因此我从 Alpha 版升级到了 1.0 稳定版。
Apollo alpha 在新 Gradle 中抛出构建错误。所以我升级到 1.0 并构建成功
但是打开应用后,我得到了这个异常
这里的奥秘是 =>
okHTTP 日志拦截器打印响应 JSON,它也有效且正确。
但是 Apollo 无法解析它
为什么 apollo 在正确接收时无法解析 JSON?
限制 一件可悲的是,由于使用了很多旧包,我无法升级到最新的 apollo 版本,因为旧包与新 Gradle 6+ 不兼容,而 apollo 最新版本需要新 Gradle。
请帮帮我
信息:
- 阿波罗版本:1.0(1.0 alpha 之前)
- Gradle 构建工具:3.6.4
- 梯度:5.6.4
- 科特林:1.3.72
示例查询
#Get Profile Details
query GetProfile {
userAccount {
result {
userId
profileId
firstName
lastName
displayName
gender
dateOfBirth
iosDOB
email
userBanStatus
phoneNumber
preferredLanguage
preferredLanguageName
preferredCurrency
location
info
createdAt
picture
country
loginUserType
isAddedList
verification {
id
isEmailConfirmed
isFacebookConnected
isGoogleConnected
isIdVerification
isPhoneVerified
}
userData {
type
}
verificationCode
countryCode
loginUserType
isAddedList
}
status
errorMessage
}
}
响应(来自 okhttp 记录器):
{
"data": {
"userAccount": {
"__typename": "WholeAccount","result": {
"__typename": "UserAccount","userId": "2bced470-49b7-11eb-a6aa-89804552bd8c","profileId": 28,"firstName": "Ragesh","lastName": "Antony","displayName": "Ragesh Antony","gender": null,"dateOfBirth": "6-1993-3","iosDOB": "6-3-1993","email": "ragesh@yopmail.com","userBanStatus": null,"phoneNumber": null,"preferredLanguage": null,"preferredLanguageName": null,"preferredCurrency": null,"location": null,"info": null,"createdAt": "1609233662000","picture": "52cd186f3f176cd981a4085887cd019d.jpeg","country": null,"loginUserType": "Guest","isAddedList": false,"verification": {
"__typename": "UserVerifiedInfo","id": 28,"isEmailConfirmed": true,"isFacebookConnected": false,"isGoogleConnected": false,"isIdVerification": false,"isPhoneVerified": false
},"userData": {
"__typename": "UserType","type": "email"
},"verificationCode": null,"countryCode": null
},"status": 200,"errorMessage": null
}
}
}
====
阿波罗配置模块:
https://gist.github.com/RageshAntony/86686ebb9557698d8569acec6fc04b42
请帮我解决这个问题
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。