Logger使用
1.引入依赖 compile‘com.orhannobut:logger:2.1.1’
2.初始化 Logger.init(getPackageName()).hideThreadInfo();
Butterknife使用
1.project 的build.gradle中加入插件
dependencis{
classpath ‘com.jackwharton.butterknife-gradle-plugin:8.8.1’
}
2.module 的build.gradle中应用插件
apply plugin:’com.android.library’
apply plugin:’com.jackwharton.butterknife’
3.Activity使用时,ButterKinfe.bind(this);Fragment使用后要在onDestroy中解绑。
Dagger使用
1.引入依赖:
compile ‘com.google.dagger:dagger-android:2.x’
annotationProcessor ‘com.google.dagger:dagger-android-processor:2.x’
需要使用support内容时再添加:compile ‘com.google.dagger:dagger-android-support:2.x’
2.直接使用;
Realm使用
1.在project 的build.gradle中加入插件
dependencies{
classpath ‘io.realm-gradle-plugin:3.1.1’
}
2.在module 的build.gradle中应用插件
apply plugin:’realm-android’
3.在Application的onCreate()方法里对Realm进行初始化配置
Realm.init(this);
RealmConfiguration config = RealmConfiguration.Builder()
.name(“myRealm.ralm”)
.deleteIfMigrationNeeded()
.build();
Realm.setDefaultConfiguration(config);
MultiDex使用
1.在module 的build.gradle中的defaultConfig里添加
multiDexEnable true;
2.复写在Application的attachBaseContext()方法添加
MutiDex.install(this);
LeakCanary使用
1.引入依赖
debugCompile ‘com.squareup.leakcanary:leakcanary-android:1.5.4’
releaseCompile ‘com.squareup.leakcanary:leakcanary-android-no-op:1.5.4’//正式版本不使用内存泄漏检测
2.复写Application中的onCreate()方法:
if(LeakCanary.isInAnalyzerProcess(this)){
return;
}
LeakCanary.install(this);
BlockCanary使用
1.引入依赖
debugCompile ‘com.github.markzhai:bolckcanary-android:1.5.0’
releaseCompile ‘com.github.markzhai:bolckcanary-android-no-op:1.5.0’
2.复写Application中的onCreate()方法:
BlockCanary.install(this,new AppBlockCanaryContext()).start();
3.实现上下文AppBlockCanaryContext()类;详见开源库
Bugly使用
1.添加依赖
compile ‘com.tencent.bugly:crashreport:latest.release’
compile ‘com.tencent.bugly:nativecrashreport:latest.release’
2.defaultConfig里配置支持so库架构
ndk{
abiFilters ‘armeabi’ //’x86’ , ‘armeabli-v7a’ , ‘x86_64’ , ‘arm64-v8a’
}
3.Manifest里添加权限
READ_PHONE_STATE
INTERNET
ACCESS_NETWORK_STATE
ACCESS_WIFI_STATE
READ_LOGS
4.复写Application中的onCreate()
CrashReport.initCrashReport(getApplicationContext(),”ID”,isDebug);
也可以添加策略:详见开源库
Glide使用
Glide V4版本支持的
最小版本是14
compile sdk 26
supportLibrary 27
所以如果想使用其他支持库时需要将Glide中的supportLibrary去除,例如
dependencies{
implementation(“com.github.bumptech.glide:gilde:4.4.0”){
exclude group:”com.android.support”
}
implementation “com.android.support:support-fragment:26.1.0”
普通使用
1.
respositories{
mavenCentral()
}
dependencies{
compile ‘com.github.bumptech.glide:glide:4.4.0’
annotationProcessor ‘com.github.bumptech.glide:compiler:4.4.0’
}
Retrofit2、Rxjava2,Rxandroid,okhttp3使用
compile ‘com.squareup.retrofit2:retrofit:2.3.0’
compile ‘com.squareup.retrofit2:converter-gson:x.x.x’
compile ‘com.squareup.retrofit2:adapter_rxjava2:x.x.x’
compile ‘com.squareup.okhttp3:okhttp:3.9.1’
compile ‘com.squareup.okhttp3:logging-interceptor:x.x.x’
compile ‘com.google.code.gson:gson:2.7’
compile ‘com.reactivex.rxjava2.rxjava:2.x.y’
compile ‘com.reactivex.rxjava2.rxandroid:2.0.1’