首页 > 代码库 > RxAndroid+RxJava+Gson+retrofit+okhttp初步搭建android网络请求框架

RxAndroid+RxJava+Gson+retrofit+okhttp初步搭建android网络请求框架

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px ".PingFang SC"; color: #454545 } span.s1 { font: 12.0px "Helvetica Neue" }</style>

新建工程集成,工具集成

 

一、集成

  RxAndroid+RxJava git官网 https://github.com/ReactiveX/RxAndroid

  Gson git官网 https://github.com/google/gson/   在android studio中引用请点击下方链接 

  • Gson Tutorial Series by Future Studio 进入教程网站

  Butterknife git官网 https://github.com/JakeWharton/butterknife  深入 http://www.cnblogs.com/zhaoyanjun/p/6016341.html

  retrofit git 官网 https://github.com/square/retrofit

  okhttp git 官网 https://github.com/square/okhttp

  按照要求在build.gradle中的dependencies中添加引用:因为jdk或者android studio版本不同会出现相对的错误 请注意。

  

dependencies {
compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])
androidTestCompile(‘com.android.support.test.espresso:espresso-core:2.2.2‘, {
exclude group: ‘com.android.support‘, module: ‘support-annotations‘
})
compile ‘com.android.support:appcompat-v7:25.3.1‘
compile ‘com.android.support.constraint:constraint-layout:1.0.0-alpha9‘
testCompile ‘junit:junit:4.12‘
compile ‘io.reactivex.rxjava2:rxandroid:2.0.1‘
compile ‘io.reactivex.rxjava2:rxjava:2.0.1‘
compile ‘com.google.code.gson:gson:2.8.0‘
compile ‘com.jakewharton:butterknife:8.5.1‘
annotationProcessor ‘com.jakewharton:butterknife-compiler:8.5.1‘
compile ‘com.squareup.retrofit2:retrofit:2.2.0‘
compile ‘com.squareup.okhttp3:okhttp:3.6.0‘
}

 

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Helvetica Neue"; color: #e4af0a } span.s1 { font: 12.0px ".PingFang SC"; color: #454545 } span.s2 { color: #454545 } span.s3 { color: #e4af0a }</style>

RxAndroid+RxJava+Gson+retrofit+okhttp初步搭建android网络请求框架