2016-05-03 126 views
1

當我使用改造。我得到了異常java.lang.NoClassDefFoundError:失敗的解決方案:Lokio /緩衝區;我使用okhttpclient爲retrofit.get設置標題userList是一個post方法,我需要發送身體請求。java.lang.NoClassDefFoundError:失敗的解決方案:Lokio/Buffer;

private void getUserList(int startIndex){ 
    final JSONObject audienceObj = ProtocolHelper.getProtocolUtils(mContext).getUserlistJsonObj(mRoomData.mUid, mRoomData.mRoomId, startIndex); 
    OkHttpClient okClient = new OkHttpClient.Builder() 
    .addInterceptor(
     new Interceptor() { 
      @Override 
      public okhttp3.Response intercept(Interceptor.Chain chain) throws IOException { 
       Request original = chain.request(); 

       // Request customization: add request headers 
       Request.Builder requestBuilder = original.newBuilder() 
         .header("sessionId", CommonData.getUserInfo(mContext).sessionId); 
       Request request = requestBuilder.build(); 
       return chain.proceed(request); 
      } 
     }) 
    .build(); 


    String baseUrl = ProtocolUtils.BASE_URL+"/"; 
    Retrofit retrofit = new Retrofit.Builder() 
    .baseUrl(baseUrl) 
    .addConverterFactory(GsonConverterFactory.create()) 
    .client(okClient) 
    .build(); 

    String audienceUrl = ProtocolHelper.getProtocolUtils(mContext).getProtocolUrl(ProtocolUtils.PROTOCOL_MSG_ID_MEMBER_LIST); 
    AudienceInterface audienceInterface = retrofit.create(AudienceInterface.class); 
    Call<String> call = audienceInterface.getAudienceList(audienceUrl,audienceObj); 
    call.enqueue(new Callback<String>() { 
     @Override 
     public void onResponse(Call<String> call, Response<String> response) { 
      Log.d(TAG, "onResponse"); 
     } 

     @Override 
     public void onFailure(Call<String> call, Throwable t) { 
      Log.d(TAG, "onFailure"+t.getMessage()); 
     } 
    }); 
} 

public interface AudienceInterface { 

@POST("{url}") 
Call<String>getAudienceList(@Path("url") String url,@Body JSONObject boder); 

}

日誌t.getMessage是:java.lang.NoClassDefFoundError:的失敗分辨率:Lokio /緩衝液;

回答

0

好吧〜我上次也發現這個錯誤。
通過這樣的:
NoClassDefFoundError的:失敗分辨率:Lokio /緩衝
你可能失去了一個罐子lib-- 奧基奧
您可以從github下載jar文件:
https://github.com/square/okio
並將此lib附加到您的項目中。

相關問題