如何解决java.io.EOFException:在android 1的改造服务调用中第1行第1列路径1的输入结束?

I am new to android. I am not getting why this error is coming. Error : java.io.EOFException: End of input at line 1 column 1 path $ W/System.err:at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1393) Please help. This is my code : 1. Pojo

class ProfileEntity implements Parcelable {

@SerializedName("tag")
@Expose
private String tag;
@SerializedName("success")
@Expose
private Integer success;
@SerializedName("error")
@Expose
private Integer error;
@SerializedName("studentId")
@Expose
private String studentId;
@SerializedName("pic_id")
@Expose
private String picId;
@SerializedName("instUrl")
@Expose
private String instUrl;
@SerializedName("course_name")
@Expose
private String courseName;
@SerializedName("batch_name")
@Expose
private String batchName;
@SerializedName("semester_name")
@Expose
private Object semesterName;
@SerializedName("section_name")
@Expose
private String sectionName;
@SerializedName("first_name")
@Expose
private String firstName;
@SerializedName("last_name")
@Expose
private String lastName;
@SerializedName("username")
@Expose
private String username;
@SerializedName("groupname")
@Expose
private String groupname;
@SerializedName("mobile")
@Expose
private String mobile;
@SerializedName("email")
@Expose
private String email;
@SerializedName("dob")
@Expose
private String dob;
@SerializedName("address")
@Expose
private String address;
@SerializedName("dbname")
@Expose
private String dbname;
@SerializedName("Branch_id")
@Expose
private String branchId;
@SerializedName("org_id")
@Expose
private String orgId;
@SerializedName("cyear")
@Expose
private String cyear;
@SerializedName("url")
@Expose
private String url;
@SerializedName("password")
@Expose
private String password;
public final static Creator<ProfileEntity> CREATOR = new Creator<ProfileEntity>() {


    @SuppressWarnings({
            "unchecked"
    })
    public ProfileEntity createFromParcel(Parcel in) {
        return new ProfileEntity(in);
    }

    public ProfileEntity[] newArray(int size) {
        return (new ProfileEntity[size]);
    }
};

protected ProfileEntity(Parcel in) {
    this.tag = ((String) in.readValue((String.class.getClassLoader())));
    this.success = ((Integer) in.readValue((Integer.class.getClassLoader())));
    this.error = ((Integer) in.readValue((Integer.class.getClassLoader())));
    this.studentId = ((String) in.readValue((String.class.getClassLoader())));
    this.picId = ((String) in.readValue((String.class.getClassLoader())));
    this.instUrl = ((String) in.readValue((String.class.getClassLoader())));
    this.courseName = ((String) in.readValue((String.class.getClassLoader())));
    this.batchName = ((String) in.readValue((String.class.getClassLoader())));
    this.semesterName = ((Object) in.readValue((Object.class.getClassLoader())));
    this.sectionName = ((String) in.readValue((String.class.getClassLoader())));
    this.firstName = ((String) in.readValue((String.class.getClassLoader())));
    this.lastName = ((String) in.readValue((String.class.getClassLoader())));
    this.username = ((String) in.readValue((String.class.getClassLoader())));
    this.groupname = ((String) in.readValue((String.class.getClassLoader())));
    this.mobile = ((String) in.readValue((String.class.getClassLoader())));
    this.email = ((String) in.readValue((String.class.getClassLoader())));
    this.dob = ((String) in.readValue((String.class.getClassLoader())));
    this.address = ((String) in.readValue((String.class.getClassLoader())));
    this.dbname = ((String) in.readValue((String.class.getClassLoader())));
    this.branchId = ((String) in.readValue((String.class.getClassLoader())));
    this.orgId = ((String) in.readValue((String.class.getClassLoader())));
    this.cyear = ((String) in.readValue((String.class.getClassLoader())));
    this.url = ((String) in.readValue((String.class.getClassLoader())));
    this.password = ((String) in.readValue((String.class.getClassLoader())));
}

public ProfileEntity() {}

public String getCyear() {
    return cyear;
}

public void setCyear(String cyear) {
    this.cyear = cyear;
}

public String getUrl() {
    return url;
}

public void setUrl(String url) {
    this.url = url;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

public String getOrgId() {
    return orgId;
}

public void setOrgId(String orgId) {
    this.orgId = orgId;
}

public String getBranchId() {
    return branchId;
}

public void setBranchId(String branchId) {
    this.branchId = branchId;
}

public String getDbname() {
    return dbname;
}

public void setDbname(String dbname) {
    this.dbname = dbname;
}

public String getTag() {
    return tag;
}

public void setTag(String tag) {
    this.tag = tag;
}

public Integer getSuccess() {
    return success;
}

public void setSuccess(Integer success) {
    this.success = success;
}

public Integer getError() {
    return error;
}

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

public String getStudentId() {
    return studentId;
}

public void setStudentId(String studentId) {
    this.studentId = studentId;
}

public String getPicId() {
    return picId;
}

public void setPicId(String picId) {
    this.picId = picId;
}

public String getInstUrl() {
    return instUrl;
}

public void setInstUrl(String instUrl) {
    this.instUrl = instUrl;
}

public String getCourseName() {
    return courseName;
}

public void setCourseName(String courseName) {
    this.courseName = courseName;
}

public String getBatchName() {
    return batchName;
}

public void setBatchName(String batchName) {
    this.batchName = batchName;
}

public Object getSemesterName() {
    return semesterName;
}

public void setSemesterName(Object semesterName) {
    this.semesterName = semesterName;
}

public String getSectionName() {
    return sectionName;
}

public void setSectionName(String sectionName) {
    this.sectionName = sectionName;
}

public String getFirstName() {
    return firstName;
}

public void setFirstName(String firstName) {
    this.firstName = firstName;
}

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

public String getUsername() {
    return username;
}

public void setUsername(String username) {
    this.username = username;
}

public String getGroupname() {
    return groupname;
}

public void setGroupname(String groupname) {
    this.groupname = groupname;
}

public String getMobile() {
    return mobile;
}

public void setMobile(String mobile) {
    this.mobile = mobile;
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

public String getDob() {
    return dob;
}

public void setDob(String dob) {
    this.dob = dob;
}

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}

public void writeToParcel(Parcel dest, int flags) {
    dest.writeValue(tag);
    dest.writeValue(success);
    dest.writeValue(error);
    dest.writeValue(studentId);
    dest.writeValue(picId);
    dest.writeValue(instUrl);
    dest.writeValue(courseName);
    dest.writeValue(batchName);
    dest.writeValue(semesterName);
    dest.writeValue(sectionName);
    dest.writeValue(firstName);
    dest.writeValue(lastName);
    dest.writeValue(username);
    dest.writeValue(groupname);
    dest.writeValue(mobile);
    dest.writeValue(email);
    dest.writeValue(dob);
    dest.writeValue(address);
    dest.writeValue(dbname);
    dest.writeValue(branchId);
    dest.writeValue(orgId);
    dest.writeValue(cyear);
    dest.writeValue(url);
    dest.writeValue(password);
}

public int describeContents() {
    return 0;
}
}
  1. ApiInterface

        @Headers("Content-Type: application/json")
        @POST("profile.php")
     Call<ProfileEntity> getProfile(@Body ProfileEntity profileEntity);
    

3.Impl

@Override
public void profileCall(ProfileEntity profileEntity) {
 ApiInterface controller = ApiClient.getClient(null).create(ApiInterface.class);
 Call<ProfileEntity> call = controller.getProfile(profileEntity);
    call.enqueue(new Callback<ProfileEntity>() {
        @Override
        public void onResponse(Call<ProfileEntity> call, Response<ProfileEntity> response) {
            if (response.body() != null) {
                ProfileEntity entity = response.body();
                if (entity.getSuccess().toString().equalsIgnoreCase("1")) {
                    profilePresentor.onProfileSuccess(entity);
                } else {
                    profilePresentor.onLogFailedMessage(response.message());
                }

            } else {
                profilePresentor.onLogFailedMessage(response.message());
            }
        }

        @Override
        public void onFailure(Call<ProfileEntity> call, Throwable t) {
            Log.d("FAILURE....",t.toString());
            t.printStackTrace();
            profilePresentor.onProfileFailure(HttpURLConnection.HTTP_INTERNAL_ERROR,"Oops! Something went wrong. Please try again");
        }
    });
}
}

4.ApiClient

 class ApiClient {

public static String BASE_URL = "http://xxxx.xxxxxx.com/appAPI_v2/";

static Retrofit retrofit = null;

public static Retrofit getClient(Map<String, String> headerMap) {
    Gson gson = new GsonBuilder()
            .setLenient()
            .create();

    Retrofit.Builder builder = new Retrofit.Builder();
    builder.baseUrl(BASE_URL);
    builder.addConverterFactory(GsonConverterFactory.create(gson));

    if (headerMap != null) {
        builder.client(getHeader(headerMap));
    } else {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor()
                .setLevel(HttpLoggingInterceptor.Level.BODY);

        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
        httpClient.readTimeout(60, TimeUnit.SECONDS);
        httpClient.connectTimeout(60, TimeUnit.SECONDS);
        if (BuildConfig.DEBUG)
            httpClient.addInterceptor(interceptor);
        builder.client(httpClient.build());
    }
    retrofit = builder.build();
    return retrofit;
}

@NonNull
private static OkHttpClient getHeader(final Map<String, String> header) {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor()
            .setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    httpClient.addInterceptor(new Interceptor() {
        @Override
        public Response intercept(Interceptor.Chain chain) throws IOException {
            Request original = chain.request();

            Request.Builder builder = original.newBuilder();
            for (Map.Entry<String, String> entry : header.entrySet()) {
                builder.addHeader(entry.getKey(), entry.getValue());
            }
            builder.method(original.method(), original.body());
            return chain.proceed(builder.build());
        }
    });
    if (BuildConfig.DEBUG) //hides exposing web service call in logcat when app is released
        httpClient.addInterceptor(interceptor);
    return httpClient.build();
}
}

Thanks in advance.

dongshi9407
dongshi9407 可能重复的Retrofit2错误java.io.EOFException:第1行第1列的输入结束
一年多之前 回复
dongtan7201
dongtan7201 我只是想知道为什么getProfile()在它应该返回一个时需要一个ProfileEntity参数。它向我建议使用该功能的设计缺陷,但也许我不完全理解您的代码
2 年多之前 回复
donglei7152
donglei7152 是的,我将ProfileEntity传递给我的服务impl类。我已经更新了我的代码。我仍然得到同样的错误。
2 年多之前 回复
dougu3988
dougu3988 你的实现方法profileCall()应该做什么?似乎在它里面,你通过传入一个ProfileEntity来调用你的服务声明的getter(ApiInterface.getProfile()),该方法应该得到它。您应该首先确保调用语法与方法签名匹配
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问