Skip to content

0x00 QuickStart_en

hui.zhao edited this page Mar 24, 2020 · 21 revisions

QuickStart

Prerequisite

  • Because AndroidGodEye use java8, so make sure your android projest support it.
android {
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}
  • Secondly, because AndroidGodEye has been migrated to androidx since version 3.1.3, so your project needs to be migrated to androidx,if not in this case, use version 3.1.2 or below.

Step1 Dependencies

build.gradle of Module project

dependencies {
    // Core module
    implementation 'cn.hikyson.godeye:godeye-core:VERSION_NAME'
    // Debug dashboard
    debugImplementation 'cn.hikyson.godeye:godeye-monitor:VERSION_NAME'
    // Release no dashboard
    releaseImplementation 'cn.hikyson.godeye:godeye-monitor-no-op:VERSION_NAME'
    // Extra module, help to monitor network
    implementation 'cn.hikyson.godeye:godeye-okhttp:VERSION_NAME'
    // Extra module, help to monitor crash/ANR
    implementation 'cn.hikyson.godeye:godeye-xcrash:VERSION_NAME'
    // Extra module, help to monitor memory leak
    implementation 'cn.hikyson.godeye:godeye-leakcanary:VERSION_NAME'
}

VERSION_NAME Github release, Migrated to androidx from Version 3.1.3, so if you don't use androidx, use version below 3.1.2

[Optional] Support MethodCanary(A tool to monitor method time consuming)

build.gradle of Root Project:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "cn.hikyson.methodcanary:plugin:PLUGIN_VERSION_NAME"
    }
}

PLUGIN_VERSION_NAME MethodCanary github release

build.gradle of Application Module Project('com.android.application'):

apply plugin: 'cn.hikyson.methodcanary.plugin'

Create js file named AndroidGodEye-MethodCanary.js in project root directory to config MethodCanary, sample:

/**
    classInfo
        {int access
         String name
         String superName
         String[] interfaces}

     methodInfo
         {int access
         String name
         String desc}
**/
function isInclude(classInfo,methodInfo){
    return classInfo.name.startsWith('cn/hikyson/godeye/sample')
}

How to write AndroidGodEye-MethodCanary.js

Step2 Initialize And Install Modules

GodEye class is entrance for this step, almost all apis are provided by it.

Init first in your application:

GodEye.instance().init(this);

Install modules in application onCreate, Repeated calls of this method will install modules that have not been installed.

if (ProcessUtils.isMainProcess(this)) {//install in main process
    GodEye.instance().install(GodEyeConfig.fromAssets("assets path"));
}

There are several ways to build GodEyeConfig

  1. (General usage)Install from XML type assets directory:GodEyeConfig.fromAssets("assets path")
  2. Install from XML type InputStream:GodEyeConfig.fromInputStream(InputStream)
  3. Default configuration:GodEyeConfig.defaultConfig()

XML Sample:install.config

[Optional] Uninstall Modules

Uninstall modules when you don't need it(not recommend):

GodEye.instance().uninstall();

Step3 Install Performance Visualization Dashboard

GodEyeMonitor class is entrance for this step.

Start performance visualization dashboard:

GodEyeMonitor.work(context)

[Optional] Stop it

GodEyeMonitor.shutDown()

Step4 Install IDE Plugin

Install Android Studio plug-in(Search AndroidGodEye in Android Studio plugin setting),Then you can find AndroidGodEye in main toolbar,click it and it will open dashboard in browser.

android_god_eye_plugin

You can open it by sh/bat script without installing the plug-in

Modify port when port conflict

Now enjoy it!

Clone this wiki locally