Multidex Android App Instrumentation for DEX-Limited Code Coverage

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing code coverage measurement tools, such as ACVTool, are inadequate for multidex Android applications due to limitations in handling multiple DEX files, exceeding method and field counts, and lack the ability to rearrange or create additional DEX files, hindering effective instrumentation.

Innovation Solution

A novel method for instrumenting multidex Android apps by disassembling, inserting probes into multiple smali directories, creating supplementary directories for instrumentation-generated classes, rearranging classes to avoid DEX limits, and correlating probe execution data to generate a multidex coverage report, preserving the original class paths and structure.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If code coverage tools insert instrumentation probes into a single DEX file, then code coverage measurement is achieved for single-DEX apps, but the approach fails for multidex apps due to DEX format limitations (65536 methods, 65536 fields, 65536 instructions per method limit)

Engineering Contradiction:
Improvecode coverage measurement capabilityVSAvoidcompatibility with multidex apps
Core Design Contradiction:
Measurement precisionVSAdaptability or versatility

Solution Approach 1:

The patent segments the instrumentation process by creating separate instrumentation for each DEX file in the multidex application. Instead of attempting to instrument all DEX files simultaneously (which would exceed DEX limits), the patent divides the work into independent segments, one per DEX file, allowing code coverage measurement to be applied to each segment separately while respecting DEX format constraints.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent transitions from a single-DEX dimensional approach to a multi-DEX dimensional approach. By organizing instrumentation across multiple DEX files (adding a new dimension of DEX file organization), the patent enables code coverage measurement in multidex apps without violating the single-DEX method, field, and instruction limits.

Inventive Principle:
Principle #17Another dimension (Dimensionality change)

2Adaptability or versatility

If instrumentation probes are inserted into multiple DEX files, then code coverage measurement is enabled for multidex apps, but the number of classes, fields, and methods increases beyond DEX format limitations

Engineering Contradiction:
Improvesupport for multidex instrumentationVSAvoidnumber of classes, fields, and methods
Core Design Contradiction:
Adaptability or versatilityVSQuantity of substance

Solution Approach 1:

The patent segments the instrumented code entities (classes, fields, methods) across multiple DEX files. By distributing these entities across separate DEX files rather than consolidating them in one file, the patent maintains the quantity of instrumented entities needed for comprehensive code coverage measurement while keeping each individual DEX file within format limitations.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent extracts instrumented classes, fields, and methods that would exceed DEX limits from a single DEX file and places them into separate DEX files. This extraction process allows the instrumentation to encompass all necessary code entities for multidex apps while ensuring no single DEX file exceeds the 65536 limit for methods, fields, or instructions.

Inventive Principle:
Principle #2Taking out (Extraction)

3Ease of manufacture

If existing tools like ACVTool and multidexlib2 are used, then single-DEX app instrumentation works, but they fail to handle multiple DEX files, class and method counts, and method length limitations

Engineering Contradiction:
Improveinstrumentation process simplicityVSAvoidhandling of multidex structure
Core Design Contradiction:
Ease of manufactureVSAdaptability or versatility

Solution Approach 1:

The patent creates a universal instrumentation approach that functions for both single-DEX and multidex applications. The same instrumentation probe insertion mechanism works regardless of whether the application has one or multiple DEX files, eliminating the need for separate tooling approaches and maintaining ease of manufacture while gaining multidex capability.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Solution Approach 2:

The patent implements a dynamic instrumentation process that automatically adapts to the number of DEX files in the application. Rather than requiring static configuration for single-DEX apps, the system dynamically identifies and instruments each DEX file present in the multidex application, allowing the instrumentation process to flexibly handle varying app structures.

Inventive Principle:
Principle #15Dynamics

4Measurement precision

If instrumentation increases the number of classes, fields, and methods in a DEX file, then code coverage tracking capability is enhanced, but DEX format limitations are exceeded

Engineering Contradiction:
Improvecode coverage tracking capabilityVSAvoidDEX format compliance
Core Design Contradiction:
Measurement precisionVSManufacturing precision

Solution Approach 1:

The patent segments the code coverage tracking instrumentation across multiple DEX files to prevent any single DEX file from exceeding format limitations. By dividing the instrumentation workload, the patent maintains both precise code coverage tracking capability and strict DEX format compliance for each individual file.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent changes the organizational parameters of the instrumentation by distributing instrumented entities across multiple DEX files rather than concentrating them in one file. This parameter change in the organizational structure allows comprehensive code coverage tracking while maintaining compliance with DEX format limits for methods, fields, and instructions in each file.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS12608298B2Multidex android app instrumentation for code coverage measurement
Publication Date: 2026.04.21 PILGUN ALEKSANDR
  • US12608298B2 patent drawing
  • US12608298B2 patent drawing
  • US12608298B2 patent drawing

AI summary

A method to instrument a multidex Android application for code coverage measurement is described. The method considers structure and DEX limitations of a multidex Android application opposed to the previous single-DEX solution. The method introduces additional steps to bypass the DEX limitations in smali representation of Android app bytecode. The method creates one supplementary smali class per DEX for probe arrays allocation. The method creates additional smali classes directory for supplementary classes. The method counts smali classes fields in newly created classes and rearranges those having the overflow due to DEX limitations. The method counts code entities in the newly created smali_classes directory and creates additional smali directories when the method number overflows. The method bypasses DEX method length limitation when reading generated class fields by reflecting the fields while correcting the array order with regards to their naming convention. An embodiment of the method allows to generate a code coverage report in a multidex format considering probes execution information obtained from testing of a multidex Android application.