- How to integrate Leakcanary-android service through AAR form
- How do I get all the relevant dependency files in a way that is referenced online?
- #1. Disabling Gradle offline mode
- #2. Add project dependencies as required by the documentation
- #3. Sync will parse and cache all dependent dependencies online after synchronization
- #4. Find the *.pom file in the directory where the dependency cache is located analyze its child dependencies
- #5. Copy all dependencies.
- #6. Transforming the. AAR dependency file
- #7. Modifying the original online form of the project depends on the dependency of the Aar form
- #8. Enable Gradle offline mode for normal use.
- How to transform the release dependency. aar files integrate only Jar class library files used in release mode into one piece?
- Pre-Retrofit: Leakcanary-android-1.5.4.aar > Libs Empty
- After transformation: Add all of its dependent jar packages to the ' Leakcanary-android-1.5.4.aar > Libs ' directory.
- Result validation
How to integrate Leakcanary-android service through AAR form
Leakcanary-android Official website: square/leakcanary:a memory leak detection library for Android and Java.
How do I get all the relevant dependency files by online referencing? #1. Disable Gradle Offline mode # # # Add Project dependencies as required by the documentation
In your build.gradle:
dependencies {
debugImplementation ‘com.squareup.leakcanary:leakcanary-android:1.5.4‘
releaseImplementation ‘com.squareup.leakcanary:leakcanary-android-no-op:1.5.4‘
}
#3. Sync will parse and cache all dependent dependencies online after synchronization. Find the *.pom file in the directory where the dependency cache is located analyze its child dependencies
The Windows system cache is typically located on the path:
.gradle\caches\modules-2\files-2.1\com.squareup.leakcanary\leakcanary-android\1.5.4
.gradle\caches\modules-2\files-2.1\com.squareup.leakcanary\leakcanary-android-no-op\1.5.4
The following types of files are generally present in subdirectories: *-sources.jar, . Aar or . jar, *.pom
Open the *.pom file with the Text tool, visible in XML-formatted text, find the following node data to learn its child dependency information:
Project-dependencies-dependency-artifactid
#5. Copy all dependencies.
Copies all the file dependencies in the cache for all *.aar或*.jar
formats. and put it in the specified flatDir
directory (such as the libs
directory.)
#6. Transforming the. AAR dependency file
The Jar class library files that are used only in release mode are integrated into a piece
#7. Modifying the original online form of the project depends on the dependency of the Aar form
debugImplementation(name: ‘leakcanary-android-1.5.4‘, ext: ‘aar‘)
releaseImplementation(name: ‘leakcanary-android-no-op-1.5.4‘, ext: ‘aar‘)
Note that depending on the Aar form, the build.gradle
following settings should be added:
repositories {
flatDir {
dirs ‘libs‘
}
}
#8. Enable Gradle offline mode for normal use. How to transform the release dependency. aar files integrate only Jar class library files that are used in release mode?
The ultimate goal is to:
- The
debug
leakcanary-android
function that can be used normally in operation mode is guaranteed,
- Ensure that
Release
you do not add any extra code and resources in the release mode (only add No-op class to ensure the compilation does not error)
Before transformation: Leakcanary-android-1.5.4.aar > Libs after an empty retrofit: Add all of its dependent jar packages to
leakcanary-android-1.5.4.aar > libs
in the catalogue.
leakcanary-android
Dependencies are inherently jars:
- Leakcanary-watcher-1.5.4.jar
- Haha-2.0.3.jar
Part of the dependency is that the AAR needs to extract the jar file:
- Leakcanary-analyzer-1.5.4.aar
After extracting it, extract and classes.jar
change the name leakcanary-analyzer-1.5.4.jar
to differentiate.
leakcanary-android-1.5.4.aar > libs
The following files are in the final directory:
- Leakcanary-watcher-1.5.4.jar
- Haha-2.0.3.jar
- leakcanary-analyzer-1.5.4. Jar
Result validation
Release mode class structure diagram:
Debug mode class structure diagram:
How to integrate Leakcanary-android service through AAR form