常见开源框架引入

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’

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值