1 2 3 4
| :amap_bundle_miniapp:miniapp-api:generateDebugRFile > Resolve files of :amap_bundle_miniapp:miniapp-api:debugCompileClasspath > dice-11.00.0.316.aar > 14.95 MB/15.52 MB downloaded
|
反推法
根据 “ 14.95 MB/15.52 MB downloaded “,我们在ResourceOperation 中找到了满足我们看到的这种格式。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public enum Type{ download, upload;
public String getCapitalized() { return StringUtils.capitalize(toString()); } }
private final Type operationType;
String.format("%s/%s %sed", getLengthText(totalProcessedBytes), contentLengthString, operationType)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| public class ResourceOperation { public enum Type{ download, upload;
public String getCapitalized() { return StringUtils.capitalize(toString()); } } private final ProgressLogger progressLogger; private final Type operationType; private final String contentLengthString; private final String resourceName;
private long loggedKBytes; private long totalProcessedBytes;
public ResourceOperation(ProgressLogger progressLogger, Type type, long contentLength, String resourceName) { this.progressLogger = progressLogger; this.operationType = type; this.contentLengthString = getLengthText(contentLength != 0 ? contentLength : null); this.resourceName = resourceName; }
private String getLengthText(Long bytes) { if (bytes == null) { return "unknown size"; } if (bytes < 1024) { return bytes + " B"; } else if (bytes < 1048576) { return (bytes / 1024) + " KB"; } else { return String.format("%.2f MB", bytes / 1048576.0); } }
public void logProcessedBytes(long processedBytes) { totalProcessedBytes += processedBytes; long processedKB = totalProcessedBytes / 1024; if (processedKB > loggedKBytes) { loggedKBytes = processedKB; String progressMessage = String.format("%s/%s %sed", getLengthText(totalProcessedBytes), contentLengthString, operationType); progressLogger.progress(progressMessage); } }
public void completed() { this.progressLogger.completed(); } }
|
找到之后就很简单了,我们给build.gradle添加一个新的依赖或者删除一个aar的依赖,并且在 寻找调用 logProcessedBytes的地方,设置断点。
这里我们删除一个androidx.activity:activity:1.2.3的依赖
/Users/juneleo/.gradle/caches/modules-2/files-2.1
/Users/juneleo/.gradle/caches/transforms-2/files-2.1
DefaultBuildOperationExecutor 下载时创建线程池 线程池名(Build operations)
在调用getArtifact的地方都会触发下载检查,如果没有下载才会触发下载