I am unable to understand what is the issue here : is it library issue?
java.lang.IllegalArgumentException: Form-encoded method must contain at least one @Field. for method ApiInterface.hitCheckVersionApi$79c79d47 at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:720) at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:11711) at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166) at retrofit2.Retrofit$1.invoke(Retrofit.java:145) at java.lang.reflect.Proxy.invoke(Proxy.java:1006) at $Proxy3.hitCheckVersionApi$79c79d47(Unknown Source) at com.shopoholicbuddy.activities.SplashActivity.onCreate(SplashActivity.java:1058)
Here is code sample:
@FormUrlEncoded
@POST("checkversion")
Call<ResponseBody> hitCheckVersionApi(@FieldMap HashMap<String, String> map);
And the implementation code is:
private void checkForceUpdateAPI() {
if (AppUtils.getInstance().isInternetAvailable(this)) {
final HashMap<String, String> params = new HashMap<>();
params.put(Constants.NetworkConstant.PARAM_VERSION_NAME, getAppVersion(this));
params.put(Constants.NetworkConstant.PARAM_PLATFORM, "1");
params.put(Constants.NetworkConstant.PARAM_APP_TYPE, "2");
ApiInterface apiInterface = RestApi.createService(this, ApiInterface.class);
Call<ResponseBody> call = apiInterface.hitCheckVersionApi(params);
ApiCall.getInstance().hitService(this, call, new NetworkListener() {
@Override
public void onSuccess(int responseCode, String response, int requestCode) {
try {
VersionUpdateResponse bean = new Gson().fromJson(response, VersionUpdateResponse.class);
if (bean.getCode() == 310) {
if (bean.getResult().getVersionName() != null && Double.parseDouble(bean.getResult().getVersionName())<=(Double.parseDouble(getAppVersion(SplashActivity.this)))) {
showSplashScreen();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(SplashActivity.this, R.style.DatePickerTheme);
builder.setTitle(getString(R.string.new_version_available));
builder.setMessage(getString(R.string.upgrade_to_new_version));
builder.setPositiveButton(getString(R.string.update), (dialogInterface, i) -> redirectStore("https://play.google.com/store/apps/details?id=com.shopoholic"));
if (bean.getResult().getUpdateType() != null && bean.getResult().getUpdateType().equals("1")) {
builder.setNegativeButton(getString(R.string.no_thanks), (dialogInterface, i) -> showSplashScreen());
}
builder.setCancelable(false);
builder.show();
}
} else {
showSplashScreen();
}
} catch (Exception e) {
e.printStackTrace();
showSplashScreen();
}
}