如何解决java.lang.NoClassDefFoundError:okio.Okio?

时间:2016-05-02 08:05:59

标签: android web-services okhttp okio

我有一个非常好用的应用程序,但有时当我向我的程序添加一些类和代码时,我的应用程序崩溃了。在我的logcat错误是这样的:

 8871-8929/com.example.first E/AndroidRuntime﹕ FATAL EXCEPTION: pool-4-thread-1
java.lang.NoClassDefFoundError: okio.Okio
    at com.squareup.okhttp.internal.http.HttpConnection.<init>    (HttpConnection.java:90)
    at com.squareup.okhttp.Connection.connectSocket(Connection.java:208)
    at com.squareup.okhttp.Connection.connect(Connection.java:172)
    at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
    at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
    at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
    at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:438)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:389)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:233)

我的傻瓜:

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 compile 'com.android.support:support-v4:23.1.+'
 compile 'com.google.android.gms:play-services:3.2.+'
 compile 'net.hockeyapp.android:HockeySDK:3.6.+'
 compile 'com.googlecode.mp4parser:isoparser:1.0.+'
 compile 'com.android.support:appcompat-v7:23.1.0'
 compile 'com.android.support:design:23.1.1'
 compile 'com.android.support:cardview-v7:23.1.0'
 compile 'com.android.support:recyclerview-v7:23.0.1'
 compile 'com.github.bumptech.glide:glide:+'
 compile 'com.nineoldandroids:library:2.4.+'
  compile 'com.koushikdutta.ion:ion:2.+'
 compile 'de.greenrobot:eventbus:2.4.0'
 compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
 compile 'com.theartofdev.edmodo:android-image-cropper:1.0.+'
 compile 'com.squareup.picasso:picasso:2.5.2'
 compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.5'
 compile 'com.github.rahatarmanahmed:circularprogressview:2.4.0'
 compile 'com.makeramen:roundedimageview:2.1.2'
 compile 'com.squareup.okio:okio:1.6.0'
}

1 个答案:

答案 0 :(得分:5)

也许您正在超过65K方法限制,并且拥有multiDexEnabled = true,但尚未正确设置多索引?

如果您没有,请添加此内容:

dependencies { compile 'com.android.support:multidex:1.0.1' }

@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } 扩展应用程序类

查看完整指南以获取详细信息: https://developer.android.com/studio/build/multidex.html#avoid