Android 开发中一边向高级靠拢,一边整理高级开发这方面资料。同时一边使用Java语言和kotlin语言重新搭建APP原生开发基础架构。
我将要运用到:Retroft2网络框架 + Glide图片加载 + Gson数据解析 + Logger开源等优秀的第三方库,当然为了避免64K限制肯定是不会滥用第三方库的
首先介绍使用Kotlin进行搭建
使用kotlin中自我感觉的优点:
代码量少了
非空安全
这两个是给我最直接的体验,其他的好处真心没有感受到呢。应该是我还不够级。
和我一样是kotlin菜鸟的可以看一下这个,我刚开始也是这样看的,哈哈哈
kotlin教程:
http://www.runoob.com/kotlin/kotlin-tutorial.html
kotlin中文文档:
http://www.kotlindoc.cn/GettingStarted/Basic-Syntax.html
那么使用kotlin一步步搭建一个基础框架:
Kotlin+MVP+Retrofit2+RxJava2
首先我添加的依赖
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
//拦截器
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
//gson
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
// 1、升级自己的版本到27.0.2
// 2、使用exclue排除冲突 (我使用的方法)
// 3、降级Glide到 4.3.1
implementation('com.github.bumptech.glide:glide:4.7.1') {
exclude group: "com.android.support"
}
implementation 'com.orhanobut:logger:2.2.0'
}
介绍一下我的开发环境和目录



这是我的项目的目录结构,还有和所涉及的类。
网友评论