收集了常用的开源库的比较稳定的版本
俗称黄油刀,view绑定ID神器
dependencies {
compile 'com.jakewharton:butterknife:8.7.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
}
最新版使用了预编译技术大大提高了注解模式的效率
使用方法:在Project的build.gradle里
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:8.7.0'
}
}
module的build.gradle里加入
apply plugin: 'com.jakewharton.butterknife'
...
...
dependencies {
compile 'com.jakewharton:butterknife:8.7.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
}
具体code中使用方式:http://jakewharton.github.io/butterknife/
8.7版本官方使用说明,右键保存
http://upload-images.jianshu.io/upload_images/3515789-172e559b1a0275f3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240
或者可以使用旧版,没有预编译的版本
compile 'com.jakewharton:butterknife:7.0.1'
2 retrofit
集成了okhttp
//这个包里集成了okhttp3.6
compile 'com.squareup.retrofit2:retrofit:2.2.0'
//使retrofit2支持gson的转换
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
//Retrofit对Rxjava的支持
compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
RxJava针对Android的版本
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
4 glide
一行代码显示图片,已经更新了V4稳定版,具体用法看官网
Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView);
compile 'com.github.bumptech.glide:glide:3.7.0'
5 Android-ObservableScrollView
可以实现CoordinatorLayout+Behavior的效果,类似知乎首页,隐藏标题栏,操作栏
compile 'com.github.ksoichiro:android-observablescrollview:1.6.0'
解决RxJava内存泄露问题,用来严格控制由于发布了一个订阅后,由于没有及时取消,导致Activity/Fragment无法销毁导致的内存泄露 。
//包含了RxJAVA2.0.1和Rxandroid2.0.1
compile 'com.trello.rxlifecycle2:rxlifecycle:2.0.1'
compile 'com.trello.rxlifecycle2:rxlifecycle-components:2.0.1'
错误解决方法!!!!!!
警告:Conflict with dependency 'com.google.code.findbugs:jsr305'. Resolved versions for app (3.0.1) and test app (2.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
//强制test使用3.0.1版本的,每个gradle都要写
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.1'
RecycView二次封装,高度自定义
compile 'com.jcodecraeer:xrecyclerview:1.3.2'
注意recyclerView.refreshComplete();
的使用要放在adapter数据更新后(未知bug)
project gradle中
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Gradle
dependencies {
compile 'com.github.lzyzsd:circleprogress:1.2.1'
}
9 EventBus
神器啊,既能订阅前发送信息给订阅者,又能订阅后再发送信息给订阅者,耦合几乎为0。
compile 'org.greenrobot:eventbus:3.0.0'
UltraViewPager是一个封装多种特性的ViewPager,主要是为多页面切换场景提供统一解决方案。阿里出品。
compile ('com.alibaba.android:ultraviewpager:1.0.4@aar') {
transitive = true
}
Indicator 取代 tabhost,实现网易顶部tab,新浪微博主页底部tab,引导页,无限轮播banner等效果,高度自定义tab和特效。是一个很强大的库,从某个角度上包含了10的功能
compile 'com.shizhefei:ViewPagerIndicator:1.1.6'
由于用到了v4和recyclerview所以也要导入他们
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
用编译时注解实现动态权限申请的开源库,让你面对API 23+也能保持代码整洁高效。github上star有5000+
app module build.gradle file中:
compile("com.github.hotchemi:permissionsdispatcher:2.4.0") {
// if you don't use android.app.Fragment you can exclude support for them
exclude module: "support-v13"
}
annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:2.4.0"
Snapshots of the development version are available in JFrog's snapshots repository. Add the repo below to download SNAPSHOT releases.
repositories {
jcenter()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
13 greenDAO
greenDAO is a light & fast ORM for Android that maps objects to SQLite databases. Being highly optimized for Android, greenDAO offers great performance and consumes minimal memory.
主页:http://greenrobot.org/greendao/
// In your root build.gradle file:
buildscript {
repositories {
jcenter()
mavenCentral() // add repository
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
}
}
// In your app projects build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao' // apply plugin
dependencies {
compile 'org.greenrobot:greendao:3.2.2' // add library
}
未完