在app module的build.gradle文件添加

    1. class CheckSoPlugin implements Plugin<Project> {
    2. void apply(Project project) {
    3. project.afterEvaluate {
    4. if (project.tasks.findByName('transformNativeLibsWithMergeJniLibsForDebug')) {
    5. project.tasks.getByName('transformNativeLibsWithMergeJniLibsForDebug') {
    6. task ->
    7. println("println task $it")
    8. task.doLast {
    9. it.inputs.files.each { fileTemp ->
    10. println "input file: $fileTemp.absolutePath"
    11. }
    12. println '—————————————————————————'
    13. it.outputs.files.each { fileTemp ->
    14. println "output file: $fileTemp.absolutePath"
    15. }
    16. }
    17. }
    18. }
    19. }
    20. }
    21. }
    22. apply plugin: CheckSoPlugin
    //---------------------构建渠道包 end---------------------//
    tasks.whenTaskAdded { task ->
        println("-------------------------------------->>>" + task.name)
    
        if (task.name == 'mergeArmeabiv7aDebugNativeLibs' || task.name == 'mergeArm64v8aDebugNativeLibs' ||
                task.name == 'mergeDebugNativeLibs' || task.name == 'transformNativeLibsWithMergeJniLibsForDebug') {
            task.doFirst {
                println("------------------- find so files start -------------------")
                it.inputs.files.each { file ->
                    printDir(new File(file.absolutePath))
                }
                println("------------------- find so files end -------------------")
            }
        }
    }
    
    def printDir(File file) {
        if (file != null) {
            if (file.isDirectory()) {
                file.listFiles().each {
                    printDir(it)
                }
            } else if (file.absolutePath.endsWith(".so")) {
                println "find so file: $file.absolutePath"
            }
        }
    }