小编And*_*hke的帖子

java.lang.NoClassDefFoundError:解决失败:Lretrofit2/Retrofit$Builder;

我正在努力在 Android 中编写非常简单的基于 Retrofit2 的 Instrumented 测试(connectedTestAndroid 任务)。

然而,由于上述简短的错误消息,我的测试失败了。

这是我正在使用的代码示例:

package com.example.app.android;

import okhttp3.ResponseBody;
import okhttp3.OkHttpClient;

import java.util.concurrent.TimeUnit;
import java.io.IOException;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import android.util.Log;

public class Retrofit2Requests extends BasicRequest
{
  private Call<ResponseBody> call;
  private OkHttpClient _client;
  private String _baseUrl;
  private Retrofit2Adapter _adapter;
  private static final String LOG_TAG = "RetroFit2Requests";

  public Retrofit2Requests (String baseUrl) throws Exception
  {
    _client = new OkHttpClient
      .Builder()
      .connectTimeout(TIME_SOCKET_TIMEOUT, TimeUnit.MILLISECONDS)
      .readTimeout(TIME_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)
      .build();
    _adapter = (Retrofit2Adapter) new Retrofit.Builder()
      .client(_client)
      .baseUrl(baseUrl)
      .build() …
Run Code Online (Sandbox Code Playgroud)

java android dex retrofit retrofit2

5
推荐指数
1
解决办法
5064
查看次数

标签 统计

android ×1

dex ×1

java ×1

retrofit ×1

retrofit2 ×1