retrofit Expected a string but was BEGIN_OBJECT at line 1 column 2 path $
.addConverterFactory(ScalarsConverterFactory.create()) .addxxxx
Try like this
@Override
public void onResponse(Call<ResponseBody> call, Response< ResponseBody > response) {
try {
if (response.body() != null)
Log.e("UploadResponse>>>", response.body());
layoutUpload.setVisibility(View.GONE);
if (file.exists()) {
file.delete();
thumb.delete();
}
} catch (Exception e) {
e.printStackTrace();
layoutUpload.setVisibility(View.GONE);
if (file.exists()) {
file.delete();
thumb.delete();
}
}
}
Error say's you want to get result in String body. If you want to do this, Just add ScalarsConverterFactory.create() in your Retrofit.Builder.
public static Retrofit getClient() {
Gson gson = new GsonBuilder()
.setLenient()
.create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(getBaseUrl())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
return retrofit;
}
Use retrofit Implementation in app level build.gradle.
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'