2016-07-11 87 views
1

嘿,夥計們,請幫助我!我被困在這個非常持久的錯誤中。我無法理解錯誤發生的原因。請幫幫我。我使用改裝2.0.0

這是錯誤: 失敗使用JsonReader.setLenient(真)的行接受畸形的JSON 1列1路$

這是堆棧跟蹤:

07-11 10:30:38.393 26263-26263/com.example.kick.imageslider D/ViewRootImpl: doProcessInputEvents ViewRoot{3c3c6ba com.example.kick.imageslider/com.example.kick.imageslider.login_register,ident = 1} 
07-11 10:30:38.394 26263-26263/com.example.kick.imageslider D/View: Touch up dispatch to android.support.v7.widget.AppCompatButton{ecc3188 VFED..C.. ...p.... 0,1361-840,1505 #7f0c00ed app:id/btn_register}, event = MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=425.49493, y[0]=41.232178, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=769988827, downTime=769988788, deviceId=7, source=0x1002 } 
07-11 10:30:38.394 26263-26263/com.example.kick.imageslider D/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 0 
07-11 10:30:38.401 26263-31413/com.example.kick.imageslider I/System.out: [CDS][DNS] getAllByNameImpl netId = 0 
07-11 10:30:38.403 26263-31413/com.example.kick.imageslider D/libc-netbsd: [getaddrinfo]: hostname=hostmyfile.16mb.com; servname=(null); netid=0; mark=0 
07-11 10:30:38.403 26263-31413/com.example.kick.imageslider D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 
07-11 10:30:38.404 26263-31413/com.example.kick.imageslider D/libc-netbsd: [getaddrinfo]: hostname=hostmyfile.16mb.com; servname=(null); netid=0; mark=0 
07-11 10:30:38.404 26263-31413/com.example.kick.imageslider D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0 
07-11 10:30:38.408 26263-31413/com.example.kick.imageslider D/libc-netbsd: getaddrinfo: hostmyfile.16mb.com get result from proxy gai_error = 0 
07-11 10:30:38.409 26263-31413/com.example.kick.imageslider I/System.out: [CDS]rx timeout:90000 
07-11 10:30:38.409 26263-31413/com.example.kick.imageslider I/System.out: [socket][7] connection hostmyfile.16mb.com/31.170.165.198:80;LocalPort=50547(90000) 
07-11 10:30:38.409 26263-31413/com.example.kick.imageslider I/System.out: [CDS]connect[hostmyfile.16mb.com/31.170.165.198:80] tm:90 
07-11 10:30:38.409 26263-31413/com.example.kick.imageslider D/Posix: [Posix_connect Debug]Process com.example.kick.imageslider :80 
07-11 10:30:38.567 26263-31413/com.example.kick.imageslider I/System.out: [socket][/192.168.1.228:50547] connected 
07-11 10:30:38.567 26263-31413/com.example.kick.imageslider I/System.out: [CDS]rx timeout:90000 
07-11 10:30:38.716 26263-31413/com.example.kick.imageslider I/System.out: [CDS][DNS] getAllByNameImpl netId = 0 
07-11 10:30:38.716 26263-31413/com.example.kick.imageslider D/libc-netbsd: [getaddrinfo]: hostname=error.hostinger.eu; servname=(null); netid=0; mark=0 
07-11 10:30:38.716 26263-31413/com.example.kick.imageslider D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 
07-11 10:30:38.717 26263-31413/com.example.kick.imageslider D/libc-netbsd: [getaddrinfo]: hostname=error.hostinger.eu; servname=(null); netid=0; mark=0 
07-11 10:30:38.718 26263-31413/com.example.kick.imageslider D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0 
07-11 10:30:38.724 26263-31413/com.example.kick.imageslider D/libc-netbsd: getaddrinfo: error.hostinger.eu get result from proxy gai_error = 0 
07-11 10:30:38.724 26263-31413/com.example.kick.imageslider I/System.out: [CDS]rx timeout:90000 
07-11 10:30:38.724 26263-31413/com.example.kick.imageslider I/System.out: [socket][8] connection error.hostinger.eu/31.170.160.61:80;LocalPort=47182(90000) 
07-11 10:30:38.724 26263-31413/com.example.kick.imageslider I/System.out: [CDS]connect[error.hostinger.eu/31.170.160.61:80] tm:90 
07-11 10:30:38.724 26263-31413/com.example.kick.imageslider D/Posix: [Posix_connect Debug]Process com.example.kick.imageslider :80 
07-11 10:30:38.954 26263-31413/com.example.kick.imageslider I/System.out: [socket][/192.168.1.228:47182] connected 
07-11 10:30:38.954 26263-31413/com.example.kick.imageslider I/System.out: [CDS]rx timeout:90000 
07-11 10:30:39.182 26263-31413/com.example.kick.imageslider I/System.out: close [socket][/192.168.1.228:47182] 
07-11 10:30:39.195 26263-26263/com.example.kick.imageslider D/Beeetle: failedUse JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $ 

這是我的POJO:

public class User { 


    @Expose 
    private String name; 


    @Expose 
    private String email; 


    @Expose 
    private String password; 


    @Expose 
    private String homeaddress; 

    public void setName(String name) { 
     this.name = name; 
    } 

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

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

    public void setHomeaddress(String homeaddress) { 
     this.homeaddress = homeaddress; 
    } 

    public String getName() { 

     return name; 
    } 

    public String getEmail() { 
     return email; 
    } 

    public String getPassword() { 
     return password; 
    } 

    public String getHomeaddress() { 
     return homeaddress; 
    } 
} 

這是我的註冊方法:

private void registerProcess(String name, String email,String password,String homeaddress){ 

     OkHttpClient.Builder client = new OkHttpClient.Builder(); 
     client.readTimeout(90, TimeUnit.SECONDS); 
     client.connectTimeout(90,TimeUnit.SECONDS); 

Retrofit retrofit = new Retrofit.Builder() 
       .baseUrl(Constants.BASE_URL) 
       .addConverterFactory(GsonConverterFactory.create()) 
       .client(client.build()) 
       .build(); 

     RequestInterface requestInterface = retrofit.create(RequestInterface.class); 

     User user = new User(); 
     user.setName(name); 
     user.setEmail(email); 
     user.setPassword(password); 
     user.setHomeaddress(homeaddress); 
     ServerRequest request = new ServerRequest(); 
     request.setOperation(Constants.REGISTER_OPERATION); 
     request.setUser(user); 
     Call<ServerResponse> response = requestInterface.operation(request); 

     response.enqueue(new Callback<ServerResponse>() { 
      @Override 
      public void onResponse(Call<ServerResponse> call, retrofit2.Response<ServerResponse> response) { 

       ServerResponse resp = response.body(); 
       Snackbar.make(getView(), resp.getMessage(), Snackbar.LENGTH_LONG).show(); 
       progress.setVisibility(View.INVISIBLE); 
       //goToLogin(); 
      } 

      @Override 
      public void onFailure(Call<ServerResponse> call, Throwable t) { 

       progress.setVisibility(View.INVISIBLE); 
       Log.d(Constants.TAG,"failed"+t.getLocalizedMessage()); 
       Snackbar.make(getView(), t.getLocalizedMessage(), Snackbar.LENGTH_LONG).show(); 
      } 
     }); 
    } 

回答

0

答案很簡單:

您設定從響應獲取對象,但反應是一樣的東西再string.So檢查瀏覽器的響應,它有JSON對象爲出發點有所不同。

+0

Smit.Satodia謝謝!我重新檢查,並幫助。 – Sidharth

+0

@Sidharth,Yr wlcm如果這有幫助,那麼請upvote這個答案,以便其他用戶也可以得到幫助。Thankyou –

相關問題