无法通过改造在真实主机中上传代码

时间:2018-12-14 14:17:08

标签: android retrofit retrofit2

我在本地主机中的代码运行良好,但在实际主机中却收到此错误。

public class ApiClient {


 private static final String BASE_URL = "http://aminkhataei.ir/android_login_api/";

  private static Retrofit retrofit = null;


  public static Retrofit getClient() {
    if (retrofit == null) {


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


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

}

当我在代码中添加json时,它又出现了这样的错误。

“ com.google.gson.JsonSyntaxException:java.lang.IllegalStateException:预期为BEGIN_OBJECT,但位于第1行第1列的路径$”

这是我的代码:

  public class MyResponse {
  @SerializedName("uid")
  private String uid;
  @SerializedName("error")
  private boolean error;
  @SerializedName("msg")
  private String msg;

  public String getMsg() {
    return msg;
  }



  public String getUid() {
    return uid;
  }


  public boolean isError() {
    return error;
  }

  public void setError(boolean error) {
    this.error = error;
  } 
}

和我的模型:

protected function credentials(Request $request)
{        
   return ['username' => $request->{$this->username()}, 'password' => $request->password, 'status' => 1];
}

有人可以帮助我吗?

0 个答案:

没有答案
相关问题