项目作者: xingchenxuanfeng

项目描述 :
insert try catch code when gradle transform class
高级语言: Java
项目地址: git://github.com/xingchenxuanfeng/AddTryCatchPlugin.git
创建时间: 2019-03-02T13:56:07Z
项目社区:https://github.com/xingchenxuanfeng/AddTryCatchPlugin

开源协议:Apache License 2.0

下载


AddTryCatchPlugin

insert try catch code when gradle transform class

自动在字节码中增加try catch的gradle 插件

Wiki

AddTryCatch gradle plugin 编译期给代码加try catch的插件

一步步实现AddTryCatch插件 —— Gradle Transform和ASM实践

usage

用法

add jitpack to buildScript repositories,add classpath ‘com.github.xingchenxuanfeng:AddTryCatchPlugin:1.0’ to dependencies

把jitpack加入到buildScript repositories中,在dependencies 中加入classpath ‘com.github.xingchenxuanfeng:AddTryCatchPlugin:1.0’

  1. buildscript {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. dependencies {
  7. ...
  8. classpath 'com.github.xingchenxuanfeng:AddTryCatchPlugin:1.0'
  9. }
  10. }

add this code to build.gradle in app moudle

在app moudle级别的build.gradle中插入如下代码即可

  1. apply plugin: 'add-trycatch'
  2. addTryCatch {
  3. hookPoint = [
  4. "com.addtrycatchplugin.TestCrash1": [
  5. "crashMethod1",
  6. "crashMethod2"
  7. ],
  8. "com.addtrycatchplugin.TestCrash2": [
  9. "crashMethod1",
  10. "crashMethod2"
  11. ],
  12. "anotherClassToInsertTryCatch" : [
  13. "firstMethodToInsert",
  14. "secondMethodToInsert"
  15. ]
  16. ]
  17. exceptionHandler = ["com.addtrycatchplugin.ExceptionUtils": "uploadCatchedException"]
  18. }