Created
January 8, 2024 05:48
-
-
Save tiiime/3a0e0bf6b6a9bf1874a861f77c435b91 to your computer and use it in GitHub Desktop.
gradle task 输出 aar 依赖到 mrDebugDependencies.txt 文件,使用 parse_aar_activity.py 读取 mrDebugDependencies.txt,输出所有 activity 以及所在的 aar 文件。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 放到 app/build.gradle 文件内 | |
task showDeps { | |
doLast { | |
project.configurations.mrDebugRuntimeClasspath.each { File file -> | |
project.file('mrDebugDependencies.txt') << "${file.path} \n" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zipfile | |
import xml.etree.ElementTree as ET | |
def read_aar(aar_file): | |
# 指定aar文件的路径 | |
# 打开aar文件 | |
aar_zip = zipfile.ZipFile(aar_file) | |
# 获取AndroidManifest.xml文件 | |
manifest_xml = aar_zip.read('AndroidManifest.xml') | |
# 解析成XML树 | |
root = ET.fromstring(manifest_xml) | |
# 打印所有activity | |
for activity in root.findall('application/activity'): | |
print(aar_file + "/" + activity.get('{http://schemas.android.com/apk/res/android}name')) | |
aar_zip.close() | |
with open('mrDebugDependencies.txt') as f: | |
for line in f: | |
try: | |
read_aar(line.strip()) | |
except: | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment