简体   繁体   English

翻新无法创建呼叫适配器

[英]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.

相关问题 Retrofit 无法创建呼叫适配器 - Retrofit is unable to create call adapter Retrofit 2.0:无法为类创建调用适配器 - Retrofit 2.0: Unable to create call adapter for class 无法在翻新版2.0.0中创建呼叫适配器 - Unable to create call adapter in retrofit 2.0.0 无法为 retrofit2.Response<...> 创建调用适配器 - Unable to create call adapter for retrofit2.Response<...> 改造:无法创建适配器 - Retrofit :Unable to create adapter 无法为 class java.lang.Object - ZB9794896D299A7854021A 创建呼叫适配器 - Unable to create call adapter for class java.lang.Object - Retrofit 使用Retrofit2和Kotlin将数据发布到正文中:无法创建呼叫适配器 - Post data in body with Retrofit2 and Kotlin: Unable to create call adapter 错误:IllegalArgumentException:无法为retrofit2.Response 创建调用适配器 - Error: IllegalArgumentException: Unable to create call adapter for retrofit2.Response RxAndroid 和 Retrofit:无法为 io.reactivex.Observable 创建调用适配器<retrofit2.Response<okhttp3.ResponseBody> &gt; - RxAndroid and Retrofit: Unable to create call adapter for io.reactivex.Observable<retrofit2.Response<okhttp3.ResponseBody>> 无法创建用于改装的呼叫适配器。 <java.util.List<Model.Object> &gt; - Unable to create call adapter for retrofit.Call<java.util.List<Model.Object>>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM