Modify: 异常上报、权限申请
This commit is contained in:
@ -48,6 +48,7 @@ dependencies {
|
|||||||
api AndroidX.ConstraintLayout
|
api AndroidX.ConstraintLayout
|
||||||
api AndroidX.ActivityKtx
|
api AndroidX.ActivityKtx
|
||||||
api AndroidX.FragmentKtx
|
api AndroidX.FragmentKtx
|
||||||
|
api AndroidX.MultiDex
|
||||||
|
|
||||||
api Kotlin.Kotlin
|
api Kotlin.Kotlin
|
||||||
api Kotlin.CoroutinesCore
|
api Kotlin.CoroutinesCore
|
||||||
@ -69,6 +70,8 @@ dependencies {
|
|||||||
api GitHub.RecyclerViewAdapter
|
api GitHub.RecyclerViewAdapter
|
||||||
api GitHub.StatusBar
|
api GitHub.StatusBar
|
||||||
api GitHub.EventBus
|
api GitHub.EventBus
|
||||||
|
api GitHub.Bugly
|
||||||
|
api GitHub.PermissionX
|
||||||
|
|
||||||
kapt GitHub.GlideCompiler
|
kapt GitHub.GlideCompiler
|
||||||
kapt GitHub.ARouteCompiler
|
kapt GitHub.ARouteCompiler
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
package com.quyunshuo.base
|
package com.quyunshuo.base
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.multidex.MultiDex
|
||||||
import com.alibaba.android.arouter.launcher.ARouter
|
import com.alibaba.android.arouter.launcher.ARouter
|
||||||
import com.quyunshuo.base.utils.SpUtils
|
import com.quyunshuo.base.utils.SpUtils
|
||||||
import me.jessyan.autosize.AutoSizeConfig
|
import com.tencent.bugly.crashreport.CrashReport
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: QuYunShuo
|
* @Author: QuYunShuo
|
||||||
@ -34,5 +36,13 @@ open class BaseApplication : Application() {
|
|||||||
|
|
||||||
// // 屏幕适配 AndroidAutoSize 以横屏高度为基准进行适配
|
// // 屏幕适配 AndroidAutoSize 以横屏高度为基准进行适配
|
||||||
// AutoSizeConfig.getInstance().isBaseOnWidth = false
|
// AutoSizeConfig.getInstance().isBaseOnWidth = false
|
||||||
|
|
||||||
|
// Bugly 初始化 第三个参数为SDK调试模式开关
|
||||||
|
CrashReport.initCrashReport(this, "c5a9b1304f", BuildConfig.DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun attachBaseContext(base: Context?) {
|
||||||
|
super.attachBaseContext(base)
|
||||||
|
MultiDex.install(base)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,11 @@
|
|||||||
package com.quyunshuo.main
|
package com.quyunshuo.main
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.os.Handler
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.alibaba.android.arouter.launcher.ARouter
|
import com.alibaba.android.arouter.launcher.ARouter
|
||||||
|
import com.permissionx.guolindev.PermissionX
|
||||||
import com.quyunshuo.base.ktx.toast
|
import com.quyunshuo.base.ktx.toast
|
||||||
import com.quyunshuo.base.utils.EventBusRegister
|
import com.quyunshuo.base.utils.EventBusRegister
|
||||||
import com.quyunshuo.base.utils.sendEvent
|
import com.quyunshuo.base.utils.sendEvent
|
||||||
@ -11,6 +14,7 @@ import com.quyunshuo.common.constant.RouteKey
|
|||||||
import com.quyunshuo.common.constant.RouteUrl
|
import com.quyunshuo.common.constant.RouteUrl
|
||||||
import com.quyunshuo.common.ui.BaseActivity
|
import com.quyunshuo.common.ui.BaseActivity
|
||||||
import com.quyunshuo.main.databinding.MainActivityMainBinding
|
import com.quyunshuo.main.databinding.MainActivityMainBinding
|
||||||
|
import com.tencent.bugly.crashreport.CrashReport
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,10 +28,22 @@ import org.greenrobot.eventbus.Subscribe
|
|||||||
class MainActivity :
|
class MainActivity :
|
||||||
BaseActivity<MainActivityMainBinding, MainViewModel>(MainViewModel::class.java) {
|
BaseActivity<MainActivityMainBinding, MainViewModel>(MainViewModel::class.java) {
|
||||||
|
|
||||||
|
lateinit var handle: Handler
|
||||||
|
|
||||||
override fun initViewBinding(): MainActivityMainBinding =
|
override fun initViewBinding(): MainActivityMainBinding =
|
||||||
MainActivityMainBinding.inflate(layoutInflater)
|
MainActivityMainBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
|
PermissionX.init(this)
|
||||||
|
.permissions(Manifest.permission.READ_PHONE_STATE)
|
||||||
|
.request { allGranted, grantedList, deniedList ->
|
||||||
|
if (allGranted) {
|
||||||
|
toast("权限全部授予")
|
||||||
|
CrashReport.postCatchedException(Throwable("权限全部授予"));
|
||||||
|
} else {
|
||||||
|
toast("您拒绝了权限")
|
||||||
|
}
|
||||||
|
}
|
||||||
mViewModel.msg.observe(this, {
|
mViewModel.msg.observe(this, {
|
||||||
mBinding.mTv.text = it
|
mBinding.mTv.text = it
|
||||||
Toast.makeText(this, it, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, it, Toast.LENGTH_SHORT).show()
|
||||||
@ -37,6 +53,11 @@ class MainActivity :
|
|||||||
ARouter.getInstance().build(RouteUrl.MainActivity2)
|
ARouter.getInstance().build(RouteUrl.MainActivity2)
|
||||||
.withString(RouteKey.KEY_NAME, "ARouter").navigation()
|
.withString(RouteKey.KEY_NAME, "ARouter").navigation()
|
||||||
}
|
}
|
||||||
|
mBinding.mDebacle.setOnClickListener {
|
||||||
|
handle.post {
|
||||||
|
toast("")
|
||||||
|
}
|
||||||
|
}
|
||||||
sendEvent(TestBean("EventBus"))
|
sendEvent(TestBean("EventBus"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,15 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/mBtn" />
|
app:layout_constraintTop_toBottomOf="@+id/mBtn" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/mDebacle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="崩溃"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/mIntentBtn" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="200dp"
|
android:layout_width="200dp"
|
||||||
android:layout_height="200dp"
|
android:layout_height="200dp"
|
||||||
|
|||||||
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
note: 1. 测试打包脚本
|
note: 1. 测试打包脚本
|
||||||
2. 对比开源项目flow的封装
|
2. 对比开源项目flow的封装
|
||||||
|
3. bugly 测试上报
|
||||||
|
4. 内存泄漏工具
|
||||||
|
5. 网络请求库
|
||||||
|
|
||||||
资源文件相关{
|
资源文件相关{
|
||||||
资源相关文件属于项目相关的,因此需要放在Common组件内,不要放在Base组件里
|
资源相关文件属于项目相关的,因此需要放在Common组件内,不要放在Base组件里
|
||||||
@ -18,6 +21,7 @@ note: 1. 测试打包脚本
|
|||||||
屏幕适配 AndroidAutoSize : https://github.com/JessYanCoding/AndroidAutoSize
|
屏幕适配 AndroidAutoSize : https://github.com/JessYanCoding/AndroidAutoSize
|
||||||
本地存储 MMKV : https://github.com/Tencent/MMKV
|
本地存储 MMKV : https://github.com/Tencent/MMKV
|
||||||
路由 ARouter : https://github.com/alibaba/ARouter
|
路由 ARouter : https://github.com/alibaba/ARouter
|
||||||
|
权限申请 PermissionX : https://github.com/guolindev/PermissionX
|
||||||
}
|
}
|
||||||
|
|
||||||
网络{
|
网络{
|
||||||
|
|||||||
@ -15,6 +15,7 @@ android {
|
|||||||
versionCode BuildConfig.versionCode
|
versionCode BuildConfig.versionCode
|
||||||
versionName BuildConfig.versionName
|
versionName BuildConfig.versionName
|
||||||
testInstrumentationRunner AndroidX.AndroidJUnitRunner
|
testInstrumentationRunner AndroidX.AndroidJUnitRunner
|
||||||
|
multiDexKeepProguard file("multidexKeep.pro")
|
||||||
}
|
}
|
||||||
|
|
||||||
// signingConfigs {
|
// signingConfigs {
|
||||||
@ -68,7 +69,6 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
implementation AndroidX.MultiDex
|
|
||||||
if (!BuildConfig.isAppMode) {
|
if (!BuildConfig.isAppMode) {
|
||||||
implementation project(path: ':Lib_Main')
|
implementation project(path: ':Lib_Main')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
1
app/multidexKeep.pro
Normal file
1
app/multidexKeep.pro
Normal file
@ -0,0 +1 @@
|
|||||||
|
-keep public class com.tencent.bugly.**{*;}
|
||||||
@ -1,7 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.quyunshuo.androidbaseframemvvm">
|
package="com.quyunshuo.androidbaseframemvvm">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.READ_LOGS"
|
||||||
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".AppApplication"
|
android:name=".AppApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.quyunshuo.androidbaseframemvvm
|
package com.quyunshuo.androidbaseframemvvm
|
||||||
|
|
||||||
import androidx.multidex.MultiDex
|
|
||||||
import com.quyunshuo.androidbaseframemvvm.eventbus.index.MainEventIndex
|
import com.quyunshuo.androidbaseframemvvm.eventbus.index.MainEventIndex
|
||||||
import com.quyunshuo.common.CommonApplication
|
import com.quyunshuo.common.CommonApplication
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
@ -14,7 +13,6 @@ import org.greenrobot.eventbus.EventBus
|
|||||||
class AppApplication : CommonApplication() {
|
class AppApplication : CommonApplication() {
|
||||||
|
|
||||||
override fun initialize() {
|
override fun initialize() {
|
||||||
MultiDex.install(this)
|
|
||||||
// 开启EventBusAPT,优化反射效率
|
// 开启EventBusAPT,优化反射效率
|
||||||
EventBus
|
EventBus
|
||||||
.builder()
|
.builder()
|
||||||
|
|||||||
@ -39,7 +39,9 @@ object Version {
|
|||||||
const val ARouteCompiler = "1.2.2" // 阿里路由 APT
|
const val ARouteCompiler = "1.2.2" // 阿里路由 APT
|
||||||
const val RecyclerViewAdapter = "3.0.4" // RecyclerViewAdapter
|
const val RecyclerViewAdapter = "3.0.4" // RecyclerViewAdapter
|
||||||
const val StatusBar = "1.5.1" // 状态栏
|
const val StatusBar = "1.5.1" // 状态栏
|
||||||
const val EventBus = "3.2.0"
|
const val EventBus = "3.2.0" // 事件总线
|
||||||
|
const val Bugly = "3.2.33" // Bugly 异常上报
|
||||||
|
const val PermissionX = "1.3.0" // 权限申请
|
||||||
}
|
}
|
||||||
|
|
||||||
object AndroidX {
|
object AndroidX {
|
||||||
@ -94,4 +96,6 @@ object GitHub {
|
|||||||
const val StatusBar = "com.jaeger.statusbarutil:library:${Version.StatusBar}"
|
const val StatusBar = "com.jaeger.statusbarutil:library:${Version.StatusBar}"
|
||||||
const val EventBus = "org.greenrobot:eventbus:${Version.EventBus}"
|
const val EventBus = "org.greenrobot:eventbus:${Version.EventBus}"
|
||||||
const val EventBusAPT = "org.greenrobot:eventbus-annotation-processor:${Version.EventBus}"
|
const val EventBusAPT = "org.greenrobot:eventbus-annotation-processor:${Version.EventBus}"
|
||||||
|
const val Bugly = "com.tencent.bugly:crashreport:${Version.Bugly}"
|
||||||
|
const val PermissionX = "com.permissionx.guolindev:permissionx:${Version.PermissionX}"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user