Crash Resolution after APP Accesses Open Source Plugin Dokit

Posted by TimC on Fri, 18 Feb 2022 00:42:58 +0100

Introduction to Dokit

  1. DoraemonKit can quickly enable your business test code to be managed and accepted uniformly here.
  2. DoraemonKit has many commonly used tools built in to avoid duplicate implementations. With one access, you will have a powerful collection of tools.
  3. With dokit platform, with interface Mock, health check-up, file synchronization assistant, you can easily collaborate with others, greatly improving the efficiency of research and development process

Android Application Access

1.Gradle dependency
dependencies {
debugImplementation 'com.didichuxing.doraemonkit:dokitx:3.3.5'
releaseImplementation 'com.didichuxing.doraemonkit:dokitx-no-op:3.3.5'
2. Initialization
  • Initialize when App starts.

import com.didichuxing.doraemonkit.DoraemonKit;

public class AndroidApplication extends Application {

    public void onCreate() {
        //pId can be used in Log in and get after console adds an application
        DoraemonKit.install(this, "xxxxxx4a09c833656de5ecxxxxxxxxx");
3. Traffic monitoring and other AOP functions (optional)
  • AOP includes the following functions: 1) Longitude and latitude simulation of Baidu, Tencent and Golden Maps 2)UrlConnection, Okhttp package and subsequent interface hook functions 3)App startup time statistics 4) Slow function 5) Big picture
  • Build in the project. Add a classpath to the gradle.
buildscript {
    dependencies {
        classpath 'com.didichuxing.doraemonkit:dokitx-plugin:3.3.5'
  • Build in app. Add plugin to gradle.
apply plugin: 'com.didi.dokit'
  • Plug-in configuration options: add to build of app module. The gradle file is 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 package
          webViewSwitch true
      slowMethod {
          //Call Stack Mode Configuration
          stackMethod {
              //Functions with a default value of less than 5ms are not shown on the call stack
              thresholdTime 10
              //Call Stack Function Entry
              enterMethods = ["com.didichuxing.doraemondemo.MainDebugActivity.test1"]
              //Blacklist granularity minimum to class not supported to method at this time
              methodBlacklist = ["com.facebook.drawee.backends.pipeline.Fresco"]
          //Normal mode configuration
          normalMethod {
              //Functions with a default value of 500ms or less will not be printed in the console at run time
              thresholdTime 500
              //Package name required for Function Instrumentation
              packageNames = ["com.wch.dokit"]
              //Package name & class name not required for Function Instrumentation
              methodBlacklist = ["com.didichuxing.doraemondemo.dokit"]
  • The strategy and methodSwitch configuration items have been deprecated, and the new configuration switches are located in the gradle in the project root directory. In properties, the configuration is as follows:
    // dokit global configuration
    // Plug-in switch
    // DOKIT reads tripartite library meetings and booster conflicts If booster is also integrated in your project, change the switch to false is recommended
    // Plugin Log
    // The fully qualified name of the custom Webview is primarily for h5 js packages and data mock s
    // dokit slow function switch
    // dokit function call stack level
    // 0: Default mode Print function call stack needs to add specified entries Default is application onCreate and attachBaseContext
    // 1: Time-consuming global business code function insertion for printing a function while running in normal mode
4. Install after compilation has passed
  • Huawei enjoys 8 devices (Android 8), Android apps import dokit plugins to compile, crash after opening and report the following error
2021-01-08 11:21:48.002 13696-13696/ E/AndroidRuntime: FATAL EXCEPTION: main
Process:, PID: 13696
java.lang.RuntimeException: Unable to instantiate application 
java.lang.ClassNotFoundException: Didn't find class "" 
on path: DexPathList[[zip file "/data/app/"],
/data/app/!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /product/lib64]]
  • Huawei MatePad Device (Android 10), Android App introduced dokit plugin compilation, crashed after opening and reported the following error
2021-01-08 11:33:29.643 19241-19241/? E/AndroidRuntime: FATAL EXCEPTION: main
Process:, PID: 19241
java.lang.BootstrapMethodError: Exception from call site #4 bootstrap method
 at okhttp3.internal.Util.<clinit>(
 at okhttp3.internal.Util.immutableList(
 at okhttp3.OkHttpClient.<clinit>(
 at com.didichuxing.doraemonkit.util.DoraemonStatisticsUtil.uploadUserInfo(
 at com.didichuxing.doraemonkit.DoraemonKitReal.install(DoraemonKitReal.kt:174)
 at com.didichuxing.doraemonkit.DoraemonKit.install(DoraemonKit.kt:58)
 at com.didichuxing.doraemonkit.DoraemonKit.install(DoraemonKit.kt:24)
5. Solving the above problems
  • Based on the error information related to Huawei Enjoy 8 devices, attempts have been made such as adjusting the dokit version, adding okhttp3, and adjusting DoraemonKit. The introduction of install, the addition of multiDexEnabled true, adjusting the location of the Application, and so on, did not resolve the direct crash of open applications.
  • According to Huawei MatePad device error information, it is normal to try to add the following configuration and enjoy 8 devices in Huawei.
    compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
  • Reason analysis: The dokit plug-in uses new features of Java8, which prevents the application from running without adding the above configuration

Topics: Android