English README.md 中文 README_zh.md
TraceFix instruments Android app bytecode at compile time and injects paired android.os.Trace.beginSection/endSection calls around methods. These sections show up in Perfetto or other platform trace viewers; TraceFix only adds app-side trace sections and does not replace capture tooling such as Perfetto, atrace, or ProfilingManager.
TraceFix 0.2.x targets the Android 17 / API 37 code base:
| Component | Version |
|---|---|
| Artifact | io.github.gracker:TraceFix:0.2.0 |
| Android Gradle Plugin | 9.1.1 |
| Gradle | 9.3.1 |
| Compile SDK / Target SDK | 37 |
| Java | 17 |
The 0.1.x line was the legacy AGP 7.4/8.3 compatibility line. Use 0.2.x for Android 17 / AGP 9.1.x projects, and keep 0.1.x only for older builds that still need the previous compatibility matrix.
| Your Goal | Choose | Use This |
|---|---|---|
| Integrate TraceFix into your app | Remote plugin | "Remote Plugin" |
| Develop or debug plugin in this repo | Local plugin (mavenLocal) |
"Local Plugin" |
| Verify Android 17 behavior | Trace regression script | "Compatibility Verification" |
Maven Central artifact:
classpath("io.github.gracker:TraceFix:0.2.0")Example module or root build.gradle:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("io.github.gracker:TraceFix:0.2.0")
}
}
apply plugin: 'com.android.application'
apply plugin: 'auto-add-systrace'Optional configuration:
traceFix {
enabled = true
// Empty include lists mean "all"; excludes win over includes.
includedVariants = []
excludedVariants = []
includedClassPrefixes = []
excludedClassPrefixes = [
'com.example.generated.'
]
traceConstructors = true
traceClassInitializers = true
traceSyntheticMethods = false
traceBridgeMethods = false
}TraceFix skips abstract and native methods because they have no instrumentable method body. Synthetic and bridge methods are skipped by default to avoid adding noisy sections for compiler-generated methods; enable them only when you intentionally want compiler-generated code in traces.
Section names are readable method names with a stable hash suffix, capped to Android's 127 UTF-16 code-unit trace section limit.
Publish the plugin to local Maven:
./gradlew :android-systrace-plugin:publishToMavenLocalBuild local demo modules with:
./gradlew -PTRACEFIX_ENABLE_DEMOS=true \
:android-systrace-sample-high-local-debug:assembleDebug \
:android-systrace-sample-high-local-debug:assembleReleaseDemo modules are not included by default, so the plugin can build without pulling sample app configuration into normal development.
Run the Android 17 trace regression:
./scripts/verify-compatibility.shThe script verifies:
- Local Java fixture on AGP 9.1.1, debug and minified release.
- Remote Kotlin fixture through a file-backed Maven repository, debug and minified release.
- Method-level bytecode instrumentation via
javap, including normal returns and exception paths. - Edge cases: overloads, synchronized methods, long method names, interface default methods, concrete methods in abstract classes, skipped abstract/native methods, and skipped Kotlin synthetic
$defaultmethods.
Remote demo modules can be built manually with:
./gradlew -PTRACEFIX_ENABLE_REMOTE_DEMOS=true \
-PTRACEFIX_VERSION_REMOTE=0.2.0-local \
-PTRACEFIX_REMOTE_REPO_URL=file://$PWD/build/tracefix-remote-repo \
:android-systrace-sample-remote-debug:assembleDebug \
:android-systrace-sample-remote-debug:assembleReleaseMaintainers can publish from GitHub Actions by opening the Publish TraceFix workflow and running it on master. Configure these repository secrets first:
| Secret | Required | Notes |
|---|---|---|
OSSRH_USERNAME |
Yes | Central Portal token username. MAVEN_CENTRAL_USERNAME or SONATYPE_USERNAME also work. |
OSSRH_PASSWORD |
Yes | Central Portal token password. MAVEN_CENTRAL_PASSWORD or SONATYPE_PASSWORD also work. |
SIGNING_KEY |
Yes | ASCII-armored PGP private key for in-memory signing. |
SIGNING_PASSWORD |
Yes | Signing key password. SIGNING_PASSPHRASE also works. |
SIGNING_KEY_ID |
Optional | Required only when the in-memory key needs an explicit key id. |
Optional repository variables:
| Variable | Default |
|---|---|
TRACEFIX_CENTRAL_NAMESPACE |
io.github.gracker |
TRACEFIX_CENTRAL_PUBLISHING_TYPE |
automatic |
TRACEFIX_CENTRAL_SKIP_FINALIZE |
unset |
The workflow runs the Android 17 build and trace regression before publishing. Local manual publishing can use legacy keyring or system GPG, but the GitHub workflow intentionally uses in-memory signing because GitHub-hosted runners do not have your local GPG keyring.
Manual local publish is also supported:
- Configure Central Portal token credentials:
export OSSRH_USERNAME=... # token username from https://central.sonatype.com/usertoken
export OSSRH_PASSWORD=... # token password from https://central.sonatype.com/usertokenOr use root local.properties:
ossrhUsername=...
ossrhPassword=...- Configure signing:
export SIGNING_KEY='-----BEGIN PGP PRIVATE KEY BLOCK-----...'
export SIGNING_PASSWORD=...
export SIGNING_KEY_ID=... # optionalLegacy Gradle signing properties and system GPG are also supported:
signing.keyId=...
signing.password=...
signing.secretKeyRingFile=/path/to/secring.gpg
# or
useGpgCmd=true- Verify publish configuration:
./gradlew :android-systrace-plugin:verifyReleasePublishConfig- Publish release artifact:
./gradlew :android-systrace-plugin:publishReleaseToCentralCompatibility alias:
./gradlew :android-systrace-plugin:publishReleaseToSonatypeAfter publishing, verify Maven Central:
curl -I https://repo1.maven.org/maven2/io/github/gracker/TraceFix/0.2.0/TraceFix-0.2.0.pom