[英]Retrofit Unable to create call adapter
I followed the format from the tutorial in inserting data to database using Retrofit Library. 在使用Retrofit库将数据插入数据库时,我遵循了教程中的格式。 The logcat shows the error
Unable to create call adapter for retrofit2.Call<dagger.com.japorms.model.User_Account_Model> for method APIService.registerUser
日志显示错误消息
Unable to create call adapter for retrofit2.Call<dagger.com.japorms.model.User_Account_Model> for method APIService.registerUser
Here is my APIService Interface: 这是我的APIService接口:
public interface APIService {
@FormUrlEncoded
@POST("test_db/register.php")
Call<User_Account_Model> registerUser(@Field("email") String email, @Field("password") String password);
}
Here is the Method: 这是方法:
public void registerUser(){
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Registering Account");
progressDialog.setMessage("Please Wait ...");
progressDialog.setCancelable(false);
progressDialog.show();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://192.168.1.73:8080/")
.addConverterFactory(GsonConverterFactory.create())
.build();
APIService service = retrofit.create(APIService.class);
User_Account_Model user_account_model = new User_Account_Model();
user_account_model.email = reg_email_et.getText().toString();
user_account_model.password = reg_pass_et.getText().toString();
String conf_pass = reg_conf_pass_et.getText().toString();
if(user_account_model.password.equals(conf_pass)){
Call<User_Account_Model> call = service.registerUser(user_account_model.email,user_account_model.password);
call.enqueue((new Callback<User_Account_Model>() {
@Override
public void onResponse(Call<User_Account_Model> call, Response<User_Account_Model> response) {
progressDialog.dismiss();
}
@Override
public void onFailure(Call<User_Account_Model> call, Throwable t) {
}
}));
}
else
{
progressDialog.dismiss();
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle(Html.fromHtml("<font color='#ff0000'>REGISTER FAILED</font>")).setMessage("password and confirm password did not match")
.setCancelable(false)
.setNegativeButton("Ok", null).create().show();
}
}
my format is the same as the tutorial except I have 2 parameters. 我的格式与教程相同,除了我有2个参数。 I hope you could help me explain this logcat because I'm having a hard time understanding it since I'm new to this Retrofit library.
我希望您能帮助我解释一下此logcat,因为由于我是这个Retrofit库的新手,所以我很难理解它。 Thank you so much guys.
十分感谢大家。
Can you paste User_Account_Model.class here 您可以在此处粘贴User_Account_Model.class吗
Have you add in app gradle file 您是否添加了应用程序gradle文件
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.