美文网首页
Matrix 接入详解

Matrix 接入详解

作者: gogoingmonkey | 来源:发表于2019-04-28 14:28 被阅读0次

官方地址

接入第一步

在根目录的gradle.properties 文件添加Matrix的版本号

MATRIX_VERSION=0.5.1

当前版本0.5.1运行就会报错,报错内容是栈内存超出,因为给出的代码混淆过只能知道一个i 方法报错,根本原因就是这个版本循环调用了该方法引起

解决办法:替换版本,换成0.4.8或者0.5.2(这个版本还未公布,但是也是可以使用的)

接入第二步

在项目的build.gradle文件中添加:

 dependencies {
     classpath ("com.tencent.matrix:matrix-gradle-plugin:${MATRIX_VERSION}") { changing = true }
 }

接入第三步

在app/build.gradle.文件中添加

dependencies {
    implementation group: "com.tencent.matrix", name: "matrix-android-lib", version: MATRIX_VERSION, changing: true
    implementation group: "com.tencent.matrix", name: "matrix-android-commons", version: MATRIX_VERSION, changing: true
    implementation group: "com.tencent.matrix", name: "matrix-trace-canary", version: MATRIX_VERSION, changing: true
    implementation group: "com.tencent.matrix", name: "matrix-resource-canary-android", version: MATRIX_VERSION, changing: true
    implementation group: "com.tencent.matrix", name: "matrix-resource-canary-common", version: MATRIX_VERSION, changing: true
    implementation group: "com.tencent.matrix", name: "matrix-io-canary", version: MATRIX_VERSION, changing: true
    implementation group: "com.tencent.matrix", name: "matrix-sqlite-lint-android-sdk", version: MATRIX_VERSION, changing: true
  }
  
  apply plugin: 'com.tencent.matrix-plugin'
  matrix {
    trace {
        enable = true   //if you don't want to use trace canary, set false
        baseMethodMapFile = "${project.buildDir}/matrix_output/Debug.methodmap"
        blackListFile = "${project.projectDir}/matrixTrace/blackMethodList.txt"
    }
  }

接入第四步

创建一个监听类

public class TestPluginListener extends DefaultPluginListener {
    public static final String TAG = "Matrix.TestPluginListener";
    public TestPluginListener(Context context) {
        super(context);
        
    }

    @Override
    public void onReportIssue(Issue issue) {
        super.onReportIssue(issue);
        MatrixLog.e(TAG, issue.toString());
        
        //add your code to process data
    }
}

接入第五步

创建一个配置类:

public class DynamicConfigImplDemo implements IDynamicConfig {
    public DynamicConfigImplDemo() {}

    public boolean isFPSEnable() { return true;}
    public boolean isTraceEnable() { return true; }
    public boolean isMatrixEnable() { return true; }
    public boolean isDumpHprof() {  return false;}

    @Override
    public String get(String key, String defStr) {
        //hook to change default values
        retrun defStr;
    }

    @Override
    public int get(String key, int defInt) {
      //hook to change default values
   retrun defInt;
    }

    @Override
    public long get(String key, long defLong) {
        //hook to change default values
   retrun defLong;
    }

    @Override
    public boolean get(String key, boolean defBool) {
        //hook to change default values
   retrun defBool;
    }

    @Override
    public float get(String key, float defFloat) {
       retrun defFloat;
    }
}

接入第六步

在APPlication类中初始化:

Matrix.Builder builder = new Matrix.Builder(application); // build matrix
  builder.patchListener(new TestPluginListener(this)); // add general pluginListener
  DynamicConfigImplDemo dynamicConfig = new DynamicConfigImplDemo(); // dynamic config
  
  // init plugin 
  IOCanaryPlugin ioCanaryPlugin = new IOCanaryPlugin(new IOConfig.Builder()
                    .dynamicConfig(dynamicConfig)
                    .build());
  //add to matrix               
  builder.plugin(ioCanaryPlugin);
  
  //init matrix
  Matrix.init(builder.build());

  // start plugin 
  ioCanaryPlugin.start();

这样就完成接入,跑一遍项目.然后就可以执行后续操作了

相关文章

  • Matrix 接入详解

    官方地址 接入第一步 在根目录的gradle.properties 文件添加Matrix的版本号 当前版本0.5....

  • iOS接入 Lottie 动画过程详解

    iOS接入 Lottie 动画过程详解 iOS接入 Lottie 动画过程详解

  • 自定义View-Matrix

    Matrix原理 Matrix详解 -Matrix常用方法 setPolyToPoly最多可以支持4个点,这4个点...

  • reactnative ~ android 模块通讯混合跳转方案

    rn ~ android 模块通讯混合跳转方案详解 android原生 接入rn模块 原生接入rn + 通信详解资...

  • LeakCanary 原理实现

    最近接入了Matrix性能监控看了下Matrix的Resource-Plugin,简单的监控了Activity的泄...

  • eular angle

    pytorch3d.transforms.euler_angles_to_matrix详解 ⚠️Attention...

  • url

    1 matrix 详解 https://github.com/xingstarx/AndroidNote/blob...

  • Matrix--iOS 技术调研和接入

    一、matrix介绍 Matrix 是一款微信研发并日常使用的应用性能接入框架,支持iOS, macOS和Andr...

  • Android自定义控件

    Android中Canvas绘图基础详解 Android Paint、Canvas、Matrix使用讲解(一、Pa...

  • Matrix原理详解

    前言:图像的变换处理离不开矩阵,在Android里面也一样,本文将从原理出发,介绍了Android里面 view的...

网友评论

      本文标题:Matrix 接入详解

      本文链接:https://www.haomeiwen.com/subject/lybdnqtx.html