1. Introduction
DoKit is an efficient platform for the whole life cycle of pan-front-end product development. Currently, it supports multiple platforms such as Android, iOS, Mini Programs, Flutter, and Web. Moreover, with the launch of the dokit.cn platform, it also marks that DoKit has officially entered the stage of an efficiency tool platform from a pure efficiency tool. At the same time, DoKit is constantly being updated to provide more useful functions.
Currently, the functions provided by Dokit are:
Platform Tools (www.dokit.cn)
- [Data Mock] The App interface Mock solution provides a set of interface Mock solutions based on App network interception, which can complete the Mock for the interface data without modifying the code.
- [Health Checkup]One-click operation, integrating multiple tools of DoKit, data visualization, fast and accurate location of problems, so that you know the performance of the app well.
- [File Synchronization Assistant] Through Terminal Services, your terminal space can be fully displayed on the platform side and provide powerful file and database operation capabilities.
- [Multi-controller for one machine] Master-slave synchronization, freeing up manpower and improving the efficiency of R&D and testing
Common tools
- [App Information View] Quickly view the mobile phone information, the channels of basic App information, signature related, and permission information, to avoid the trouble of going to the mobile phone settings to find or view the source code of the project;
- [Developer options Android-specific] One-click jump to developer options to avoid inconsistencies in Android entries caused by platform differences
- [Local language] One-click jump to the local language to avoid inconsistencies in the entry of Android due to platform differences
- [Sandbox Browsing] The internal file browsing function of the App supports deletion and preview, and can be uploaded to the PC through AirDrop or other sharing methods for more detailed operations;
- [MockGPS]App can locate all over the country, supports map status and manual input of latitude and longitude;
- [H5 any door] Development and testing students can quickly enter the address of the H5 page to view the effect of the page;
- [Crash view] It is convenient to print out the stack where Crash appears locally;
- [Sub-thread UI] Quickly locate which UI operations are rendered in non-main thread to avoid unnecessary problems; (iOS only)
- [Clear local data] Delete all data in the sandbox with one click;
- [NSLog] Print all NSLog information to the UI interface to avoid the embarrassment of being unable to debug without a development certificate;
- [Lumberjack] Every log information of CocoaLumberjack is displayed in the interface of the App, so there is no need to export the log anymore; (only for iOS)
- [DBView] Convenient and quick operation of the in-app database through the web page makes the debugging of the database very elegant;
- [Simulation of weak network] Limit the network speed and simulate the operation of the App in a weak network environment; (only for android)
- [JS Script] Run JS script in the specified WebView. (iOS exclusive)
Performance testing
- [Frame rate] App frame rate information provides waveform view function, which makes the trend of frame rate monitoring more obvious;
- [CPU] App CPU usage information provides waveform view function, which makes the trend of CPU monitoring more vivid;
- [Memory] App memory usage information provides waveform view function to make the memory monitoring trend more distinct;
- [Traffic monitoring] Intercept the internal traffic information of the App, provide waveform display, traffic summary display, traffic list display, traffic filtering, traffic details, and uniformly intercept traffic information, becoming the "Charles" that comes with our App;
- [Stuck] Lock the moment when the App freezes, and print out the corresponding code call stack;
- [Large image detection] Through traffic monitoring, find all the pictures that exceed the standard size, and avoid the traffic waste caused by downloading large images and the CPU consumption caused by rendering large images.
- [Start-up time] Calculate the total time-consuming of the App startup process without intrusion;
- [UI level check] Check out the deepest element in each page;
- [Function time-consuming] Analyze app performance bottlenecks at the function level;
- [Load] Find all Load methods and give time-consuming analysis; (iOS only)
- [Memory Leaks] Find out all memory leaks in the App.
visual tool
- [Color straw] It is convenient for designers to check whether the color value of each component is set correctly when the UI is catching insects;
- [Component inspection] You can grab any UI control and view its detailed information, including control name, control position, background color, font color, and font size;
- [Alignment ruler] Refer to the test tool that comes with the Android system, which can capture screen coordinates in real time and check whether the components are aligned;
- [Element border line] Draw the border of each UI component, which has a certain reference significance for component layout.
Weex special tool (CML special tool)
- [console log viewing] It is convenient to view the console log in each Weex file on the terminal, providing classification and search functions;
- [Storage cache view] Visually display the local cache data of the storage module in Weex;
- [Container Information] View the basic information and performance data of each opened Weex page;
- [DevTool] Quickly open the scan code entry of Weex DevTool.
2. Quick access
For Android and iOS access to Dokit, official detailed access documentation.
Access steps
1. Gradle dependencies
First, we open the app/build.gradle file and add the following dependencies:
dependencies { debugImplementation 'io.github.didi.dokit:dokitx:${lastversion}' releaseImplementation 'io.github.didi.dokit:dokitx-no-op:${lastversion}' }
If you are not very clear about the version, you can open the link below to view it: Android Releases
Didi's internal business:
Please add a module for DiDi internal business line access
//Data mock internal network library support debugImplementation 'io.github.didi.dokit:dokitx-rpc:${lastversion}' //One machine multi-controller internal network library support debugImplementation 'io.github.didi.dokit:dokitx-rpc-mc:${lastversion}'
For the latest version see here.
It should be noted that if you use the latest version, you need to change the gradle version of your project to version 6.8 or above, preferably 7.0 or above. You can open the gradle-wrapper.properties file for modification.
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
2. Initialize
Initialized when the App starts.
overide fun onCreate() { DoKit.Builder(this) .productId("If you need to use the platform function, you need to go to dokit.cn Platform application id") .build() }
3. Traffic monitoring and other AOP functions (optional)
AOP includes the following functions:
1) Longitude and latitude simulation of Baidu, Tencent and AutoNavi maps
2)UrlConnection, Okhttp packet capture and subsequent interface hook functions
3)App startup time-consuming statistics
4) Slow function
5) Big picture
Add classpath to your project's build.gradle.
buildscript { dependencies { classpath 'io.github.didi.dokit:dokitx-plugin:${lastversion}' } }
Add plugin to your app's build.gradle.
apply plugin: 'com.didi.dokit'
Plugin configuration options:
Add to the build.gradle file of the app module at the same level as android {}
dokitExt { //General settings comm { //Map latitude and longitude switch gpsSwitch true //network switch networkSwitch true //big picture switch bigImgSwitch true //webView js capture webViewSwitch true } slowMethod { //Call stack mode configuration corresponds to DOKIT_METHOD_STRATEGY=0 in gradle.properties stackMethod { //The default value is 5ms, and functions less than this value are not displayed in the call stack thresholdTime 10 //Call stack function entry Do not use my default configuration. If you have special needs, modify it to your own entry in the project. If you don't need it, you can remove this field. enterMethods = ["com.didichuxing.doraemondemo.MainDebugActivity.test1"] //Blacklist The smallest granularity to the class The method is not supported for the time being. Do not use my default configuration. If you have special needs, modify it to your own entry in the project. If you don't need it, you can remove this field methodBlacklist = ["com.facebook.drawee.backends.pipeline.Fresco"] } //Normal mode configuration corresponds to DOKIT_METHOD_STRATEGY=1 in gradle.properties normalMethod { //The default value is 500ms, functions less than this value will not be printed in the console when running thresholdTime 500 //The package name that needs to be instrumented for the function. Do not use my default configuration. If there are special needs, modify it to your own project package name in the project. If you don't need it, you can remove this field. packageNames = ["com.didichuxing.doraemondemo"] //Do not need the package name & class name for function instrumentation. Do not use my default configuration. If you have special needs, modify it to your own project package name in the project. If you don’t need it, you can remove this field methodBlacklist = ["com.didichuxing.doraemondemo.dokit"] } } }
The strategy and methodSwitch configuration items have been deprecated. The new configuration switches are located in gradle.properties in the project root directory.
The specific configuration is as follows:
// dokit global configuration // Plugin switch DOKIT_PLUGIN_SWITCH=true // DOKIT will conflict with booster when reading the third-party library. If booster is also integrated in your project, it is recommended to change the switch to false DOKIT_THIRD_LIB_SWITCH=true // Plugin log DOKIT_LOG_SWITCH=true // The fully qualified name of the custom Webview is mainly used for h5 js packet capture and data mock ing DOKIT_WEBVIEW_CLASS_NAME=com/didichuxing/doraemonkit/widget/webview/MyWebView // dokit slow function switch DOKIT_METHOD_SWITCH=true // dokit function call stack level DOKIT_METHOD_STACK_LEVEL=4 // 0: Default mode Print function call stack Need to add specified entry Default is application onCreate and attachBaseContext // 1: Normal mode Time-consuming printing of a function at runtime Global business code function insertion DOKIT_METHOD_STRATEGY=0
reason:
In order to reduce the compile time of the project, the default switch for slow functions is false. Plus the plugin's transform registration must be earlier than project.afterEvaluate. Therefore, the configuration information cannot be obtained through the original configuration item, but can only be obtained through the configuration in the global gradle.properties.
tips:
After modifying the relevant configuration of the DoKit plugin, it must be clean ed and recompiled to take effect. This is caused by the incremental compilation of AS's cache, and there is no other good solution for the time being.
4. Custom functional components (optional)
Custom components need to implement the IKit interface, which corresponds to the components in the Doraemon function panel.
Taking the driver-side client as an example, the components for implementing environment switching are as follows.
class DemoKit : AbstractKit() { override val category: Int get() = Category.BIZ override val name: Int get() = R.string.dk_kit_demo override val icon: Int get() = R.mipmap.dk_sys_info override fun onClickWithReturn(activity: Activity): Boolean { SimpleDoKitStarter.startFloating(DemoDokitView::class.java) return true } override fun onAppInit(context: Context?) { } }
Register custom components during initialization.
override fun onCreate() { DoKit.Builder(this) .productId("If you need to use the platform function, you need to go to dokit.cn Platform application id") .customKits(mapKits) .build() }
DoKit entry api
public class DoKit private constructor() { companion object { /** * Whether the main icon is displayed */ @JvmStatic val isMainIconShow: Boolean get() = false /** * Show main icon */ @JvmStatic fun show() { } /** * Display the tool panel page directly */ @JvmStatic fun showToolPanel() { } /** * Hide the tool panel directly */ @JvmStatic fun hideToolPanel() { } /** * hide main icon */ @JvmStatic fun hide() { } /** * Activate the floating window * @JvmStatic:Allows invocation of static methods in java * @JvmOverloads :Use the @JvmOverloads annotation on a method with default parameter values, and Kotlin will expose multiple overloaded methods. */ @JvmStatic @JvmOverloads fun launchFloating( targetClass: Class<out AbsDokitView>, mode: DoKitViewLaunchMode = DoKitViewLaunchMode.SINGLE_INSTANCE, bundle: Bundle? = null ) { } /** * Activate the floating window * @JvmStatic:Allows invocation of static methods in java * @JvmOverloads :Use the @JvmOverloads annotation on a method with default parameter values, and Kotlin will expose multiple overloaded methods. */ @JvmStatic @JvmOverloads fun launchFloating( targetClass: KClass<out AbsDokitView>, mode: DoKitViewLaunchMode = DoKitViewLaunchMode.SINGLE_INSTANCE, bundle: Bundle? = null ) { } /** * remove floating window * @JvmStatic:Allows invocation of static methods in java * @JvmOverloads :Use the @JvmOverloads annotation on a method with default parameter values, and Kotlin will expose multiple overloaded methods. */ @JvmStatic fun removeFloating(targetClass: Class<out AbsDokitView>) { } /** * remove floating window * @JvmStatic:Allows invocation of static methods in java * @JvmOverloads :Use the @JvmOverloads annotation on a method with default parameter values, and Kotlin will expose multiple overloaded methods. */ @JvmStatic fun removeFloating(targetClass: KClass<out AbsDokitView>) { } /** * remove floating window * @JvmStatic:Allows invocation of static methods in java * @JvmOverloads :Use the @JvmOverloads annotation on a method with default parameter values, and Kotlin will expose multiple overloaded methods. */ @JvmStatic fun removeFloating(dokitView: AbsDokitView) { } /** * start full screen page * @JvmStatic:Allows invocation of static methods in java * @JvmOverloads :Use the @JvmOverloads annotation on a method with default parameter values, and Kotlin will expose multiple overloaded methods. */ @JvmStatic @JvmOverloads fun launchFullScreen( targetClass: Class<out BaseFragment>, context: Context? = null, bundle: Bundle? = null, isSystemFragment: Boolean = false ) { } /** * start full screen page * @JvmStatic:Allows invocation of static methods in java * @JvmOverloads :Use the @JvmOverloads annotation on a method with default parameter values, and Kotlin will expose multiple overloaded methods. */ @JvmStatic @JvmOverloads fun launchFullScreen( targetClass: KClass<out BaseFragment>, context: Context? = null, bundle: Bundle? = null, isSystemFragment: Boolean = false ) { } @JvmStatic fun <T : AbsDokitView> getDoKitView( activity: Activity?, clazz: Class<out T> ): T? { return null } @JvmStatic fun <T : AbsDokitView> getDoKitView( activity: Activity?, clazz: KClass<out T> ): T? { return null } /** * Send custom multi-controller events for one machine */ @JvmStatic fun sendCustomEvent( eventType: String, view: View? = null, param: Map<String, String>? = null ) { } /** * Get a multi-controller type */ @JvmStatic fun mcMode(): WSMode { return WSMode.UNKNOW } } class Builder(private val app: Application) { private var productId: String = "" private var mapKits: LinkedHashMap<String, List<AbstractKit>> = linkedMapOf() private var listKits: List<AbstractKit> = arrayListOf() init { } fun productId(productId: String): Builder { return this } /** * mapKits & listKits pick one of two */ fun customKits(mapKits: LinkedHashMap<String, List<AbstractKit>>): Builder { return this } /** * mapKits & listKits pick one of two */ fun customKits(listKits: List<AbstractKit>): Builder { return this } /** * H5 Any door global callback */ fun webDoorCallback(callback: WebDoorManager.WebDoorCallback): Builder { return this } /** * Disable the app information upload switch. The upload information is only used for statistics of DoKit access. If the user needs to protect the privacy of the app, this method can be called to disable it. */ fun disableUpload(): Builder { return this } fun debug(debug: Boolean): Builder { return this } /** * Whether to display the main entrance icon */ fun alwaysShowMainIcon(alwaysShow: Boolean): Builder { return this } /** * Set encrypted database password */ fun databasePass(map: Map<String, String>): Builder { return this } /** * Set the file management assistant http port number */ fun fileManagerHttpPort(port: Int): Builder { return this } /** * One machine multi-control port number */ fun mcWSPort(port: Int): Builder { return this } /** * One machine multi-control custom interceptor */ fun mcClientProcess(interceptor: McClientProcessor): Builder { return this } /** *Set dokit's performance monitoring global callback */ fun callBack(callback: DoKitCallBack): Builder { return this } /** * Set the proxy object of the extended network interceptor */ fun netExtInterceptor(extInterceptorProxy: DokitExtInterceptor.DokitExtInterceptorProxy): Builder { return this } fun build() { } } }
The command to enable plugin debugging is as follows:
./gradlew :app:assembleDebug -Dorg.gradle.daemon=false -Dorg.gradle.debug=true
3. Access version description
lastversion:3.5.0; kotlin compilation plugin is 1.4.32; Gradle 6.8 and above are supported
lastversion:3.5.0.1; kotlin compile plugin is 1.3.72; support Gradle 6.8 and below
DoKit | The latest version of | describe |
---|---|---|
3.3.5 and later Androidx | debugImplementation "io.github.didi.dokit:${aarName}: ${lastversion}" | (1) The groupId and version number of dokitx library and plugin need to be consistent; (2)AGP minimum version requires 3.3.0+ |
3.3.5 and previous Androidx versions | debugImplementation "com.didichuxing.doraemonkit:${aarName}:3.3.5" | (1) The groupId and version number of dokitx library and plugin need to be consistent; (2)AGP minimum version requires 3.3.0+ |
support android support | debugImplementation "com.didichuxing.doraemonkit:${aarName}:3.3.5" | support give up the update, please upgrade and adapt to Androidx as soon as possible |
${aarName} needs to be changed to the specified name, as follows:
//core module debugImplementation "io.github.didi.dokit:dokitx:${lastversion}" //file synchronization module debugImplementation "io.github.didi.dokit:dokitx-ft:${lastversion}" //One machine multi-control module debugImplementation "io.github.didi.dokit:dokitx-mc:${lastversion}" //weex module debugImplementation "io.github.didi.dokit:dokitx-weex:${lastversion}" //no-op module releaseImplementation "io.github.didi.dokit:dokitx-no-op:${lastversion}"
- debugImplementation needs to be changed to the corresponding productFlavor according to your own build
- **All examples below use dokitx as examples. To use the support version, please change dokitx to dokit.
Versions after v3.3.5 need to add mavenCentral() repository**
Source link: https://github.com/didi/DoKit