0

I am trying to make a small example using volley and gson. I have the below posted dependencies in gradle file. but when I make build project, I receive the posted error.

would you please tell m e how to solve it

error:

Error:com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: com.google.gson.stream.MalformedJsonException: Use 
JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: com.google.gson.stream.MalformedJsonException: Use 
JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1

gradle

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'dev.dworks.libs:volleyplus:0.1.4'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.android.support:support-v4:25.0.+'
}
Amrmsmb
  • 1
  • 27
  • 104
  • 226
  • it reads `use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1` ...which means, that the input might with anything, but JSON. unless posting the JSON, this question is just speculative. – Martin Zeitler Aug 15 '18 at 14:35
  • I haven't seen you import gson library in your `build.gradle` file.So check this first. – orzangleli Aug 15 '18 at 14:46
  • @orzangleli i just forget to add the dependency of the gson to the question..now i updted the question..please have a look..anyway i have the same errors – Amrmsmb Aug 15 '18 at 14:56
  • @LetsamrIt I need to have a look how you use `gson`. – orzangleli Aug 15 '18 at 15:01

1 Answers1

0

Some conditions could give this error.

Send application/json from the server as the content-type.

Gson gson = new GsonBuilder()
        .setLenient()
        .create();

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(BASE_URL)
        .client(client)
        .addConverterFactory(GsonConverterFactory.create(gson))
        .build();

implementation 'com.google.code.gson:gson:2.6.1'
Mbuodile Obiosio
  • 1,463
  • 1
  • 15
  • 19