我正在使用Rtofit在实施改造后处理来自Mobile的Serverside数据我得到以下例外任何关于这个问题的知道告诉我我做错了
Init Retrofit:
mRetrofit = new Retrofit.Builder()
.baseUrl(AppConstance.APP_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
Iservice = mRetrofit.create(IdeaService.class);
Gradle文件
dependencies {
compile fileTree(dir: 'libs',include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okio:okio:1.7.0'
}
堆栈跟踪
04-26 11:54:36.441 18355-18355/com.omt.example W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41da0c98)
04-26 11:54:36.441 18355-18355/com.omt.example W/dalvikvm: threadid=1: uncaught exception occurred
04-26 11:54:36.442 18355-18355/com.omt.example W/System.err: java.lang.NoClassDefFoundError: retrofit2.Platform
04-26 11:54:36.444 18355-18355/com.omt.example W/System.err: at retrofit2.Retrofit$Builder.
最佳答案
尝试将okhttp更改为okhttp3
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'
作为retrofit2内部使用okhttp3.
尝试构建和同步gradle.