Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: agp is unable to handle the classes under the default package co… #28

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

styluo
Copy link
Contributor

@styluo styluo commented Aug 19, 2024

PR 内容

  1. AGP的ASMFactory在处理时逻辑如下,当类文件无包名时packageName的文件名无法被删除
    即默认路径下的CustomDialog 相关className 为 ClassDialog.class.ClassDialog
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
    val relativePath = inputPath.relativize(file)
    val fileName = relativePath.fileName.toString()
    val outputFile = outputDir.resolve(relativePath.toString())
    outputFile.parentFile.mkdirs()

    if (includeFileInInstrumentation(relativePath.toString())) {
        instrumentClassToDir(
            packageName = relativePath.toString()
                .removeSuffix(File.separatorChar + fileName)
                .replace(File.separatorChar, '.'),
            className = fileName.removeSuffix(SdkConstants.DOT_CLASS),
            classFile = file.toFile(),
            outputFile = outputFile
        )
    } else {
        FileUtils.copyFile(file.toFile(), outputFile)
    }
    return FileVisitResult.CONTINUE
}
  1. 修改单测中依赖的SDK版本为release版本,snapshot在snoatype上当发布release时会清理对应snapshot版本

测试步骤

默认路径下类注入后字节码不会存在异常

影响范围

是否属于重要变动?

其他信息

@styluo styluo force-pushed the fix/default_package branch from eae6f46 to 6f5d6a2 Compare August 20, 2024 02:11
@styluo styluo force-pushed the fix/default_package branch from 6f5d6a2 to 89f595d Compare August 20, 2024 02:18
@tianhui12 tianhui12 merged commit 6baa40d into master Sep 10, 2024
2 of 3 checks passed
@tianhui12 tianhui12 deleted the fix/default_package branch September 10, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants