Use jsonreader setlenient true

Я использую модификацию для моего проекта. когда я пытаюсь получить доступ к своему веб-сервису, в onFailure я получаю JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $ на LogCat.i можете получить ответ от POSTMAN

это ответ почтальона

OnCreate Обновить

Ответ службы PHP

UpdateOrderResponse Модуль класса

Обновить

я добавил gson.setLenient() для модернизации. как ниже

затем получил еще одну ошибку onFailure это Expected BEGIN_OBJECT but was STRING at line 1 , я также добавил HttpLoggingInterceptor и проверил мой LogCat.it, показывая мне

Решение

Поскольку вы используете GSON для анализа своего ответа, нам нужно использовать теги @SerializedName и @Expose в классе модели.
Пожалуйста, замените ваш UpdateOrderResponse следующим кодом:

What is this error ? How can I fix this? My app is running but can’t load data. And this is my Error: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $

This is my fragment :

always this error not about your json , it could become from your wrong request , for better handle first check your request in postman if you got response then compare your json response with your model if nothing is wrong then this error come from your wrong request , also it could happened when your response not josn (in some case response maybe is html)

10 Answers 10

This is a well-known issue and based on this answer you could add setLenient :

Now, if you add this to your retrofit, it gives you another error:

This is another well-known error you can find answer here (this error means that your server response is not well-formatted); So change server response to return something:

Читайте также:  Python scipy optimize minimize

For better comprehension, compare your response with Github api.

Suggestion: to find out what’s going on to your request/response add HttpLoggingInterceptor in your retrofit.

Based on this answer your ServiceHelper would be:

Comments

Copy link Quote reply

perchibald commented Jun 9, 2018

Description

Devices and Versions

Your Rocket.Chat.Android version: (e.g. 2.3.1)
Your Rocket.Chat Server version: (e.g. 0.65.1-develop)

Mobile device model and OS version: (e.g. "Xiaomi Redmi Note 4X — Android 7.0")

Steps to reproduce

when sending a file, an error pops up.
"Use JsonReader.setLenient(true) to accept malformed JSON at path$"

This comment has been minimized.

Copy link Quote reply

filipedelimabrito commented Jun 12, 2018

@perchibald What kind of file were you sending?

This comment has been minimized.

Copy link Quote reply

perchibald commented Jun 13, 2018

This comment has been minimized.

Copy link Quote reply

rafaelks commented Jun 14, 2018

@perchibald What’s your server URL?

This comment has been minimized.

Copy link Quote reply

perchibald commented Jun 14, 2018

This comment has been minimized.

Copy link Quote reply

bnngld commented Jun 20, 2018

I have this same error when attempting to upload any files from my phone to Rocket.Chat.

Devices and Versions:

Rocket.Chat Android Version 2.4
Rocket.Chat Service Version .65.2
Mobile Device Model and OS Version: Pixel 2 XL Android P Build # PPP3.180510.008

This is also happening on other phones in my department that are not running the Android P Dev Preview.

This comment has been minimized.

Copy link Quote reply

bnngld commented Jun 26, 2018

This comment has been minimized.

Copy link Quote reply

Читайте также:  Unity getcomponent vs inspector field performance

filipedelimabrito commented Jun 26, 2018

@bnngld As soon as we got news/fixes we’ll cite or reference it here.

This comment has been minimized.

Copy link Quote reply

filipedelimabrito commented Jul 21, 2018

We’re able to send any file format successfully now. Also, just for information, before sending a file a dialog is show and you can send that with a description too.

This comment has been minimized.

Copy link Quote reply

fromage9747 commented Sep 30, 2018

I get this issue on the Android app with video files only. They are not very big either. Even having a description included still causes the issue

This comment has been minimized.

Copy link Quote reply

reetp commented Sep 30, 2018

@fromage9747
Test on latest version 0.70.0 with the latest app and if the bug still exists open a new bug and reference this one please.

This comment has been minimized.

Copy link Quote reply

fromage9747 commented Oct 1, 2018

@reetp Confirmed that I am running the latest version of the Mobile APP and the server. I tested this again on the legacy app and the video upload works without any issue. The issue is present in the latest Mobile APP. I will create a new bug and reference this one.

This comment has been minimized.

Copy link Quote reply

luckenbach commented Nov 19, 2018

I have a end user also getting this on a 0.70.4 when attempting to send pictures

This comment has been minimized.

Copy link Quote reply

vampirismtrueblood commented Nov 25, 2018

I’m having the exact same issue . I cannot upload any kind of file . using the Normal Android way, I need to select File Upload way.
Also . I cannot Upload from Recent files . I need to navigate to images after I click the ‘+’ sign on the app.
I’m using latest EVERYTHING.
Specs:
Note 8: Android 8.0.0
Android app: V 3.1.1 Nov 5, 2018
Server:
Ver: 0.71.1
Commit: e73dc78ffda9555fb98465ed94632473e6d63240

Читайте также:  Samsung s4 zoom разборка

This comment has been minimized.

Copy link Quote reply

rafaelks commented Nov 25, 2018

@vampirismtrueblood Please check this comment to see the solution: #1862 (comment).

This comment has been minimized.

Copy link Quote reply

vampirismtrueblood commented Nov 25, 2018

@rafaelks, thanks for the response, however I highly doubt I’m hitting max_body on nginx . I’ll give it a try though ..

The reason being that

  1. It’s working great on older app version
  2. The same file could be uploaded using "Images" category as opposed to using "Recent" . Seems like perms problem.

Also notice that I can upload file using Non-Android way . I.e you’re always given an option to upload file the "Normal way" or the "File upload way" .
I’ll feedback once I get to it though.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *