bytedance / ByteX

ByteX is a bytecode plugin platform based on Android Gradle Transform API and ASM. 字节码插件开发平台
Apache License 2.0
3.15k stars 463 forks source link

method-call-opt-plugin根本就没效果 #143

Open ikakaxi opened 2 years ago

ikakaxi commented 2 years ago
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        findViewById<Button>(R.id.button).setOnClickListener {
            Log.e("TAG","aaaa")
        }
    }
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
// apply ByteX宿主
apply plugin: 'bytex'
ByteX {
    enable true
    enableInDebug false
    logLevel "DEBUG"
}
// 按需apply bytex 插件
apply plugin: 'bytex.refer_check'
apply plugin: 'bytex.method_call_opt'
method_call_opt {
    enable true
    //建议开发模式关闭
    enableInDebug true
    logLevel "DEBUG"
    //是否在log中显示删除方法调用指令后的方法指令,一般调试时使用
    showAfterOptInsLog false
    //需要删除的方法配置
    methodList = [
            //下面的每一项配置必须严格按照数据配置,一个地方不对这一项不生效。
            //class#method#desc
            "android/util/Log#v#(Ljava/lang/String;Ljava/lang/String;)I",
            "android/util/Log#v#(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I",
            "android/util/Log#d#(Ljava/lang/String;Ljava/lang/String;)I",
            "android/util/Log#d#(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I",
            "android/util/Log#i#(Ljava/lang/String;Ljava/lang/String;)I",
            "android/util/Log#i#(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I",
            "android/util/Log#w#(Ljava/lang/String;Ljava/lang/String;)I",
            "android/util/Log#w#(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I",
            "android/util/Log#e#(Ljava/lang/String;Ljava/lang/String;)I",
            "android/util/Log#e#(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I",
            "android/util/Log#println#(ILjava/lang/String;Ljava/lang/String;)I",

            "java/lang/Throwable#printStackTrace#()V",
            "com/google/devtools/build/android/desugar/runtime/ThrowableExtension#printStackTrace#(Ljava/lang/Throwable;)V"

            //还有自己项目中封装的Logger方法
    ]
    onlyCheckList = [
            //"com/ss/*",
            //"com/bytedance/*"
    ]

    whiteList = [
            "com/facebook/stetho*",
    ]
}

根本没效果,点击按钮仍然输出日志

myxh commented 2 years ago

我也是,是不是对Kotlin无效啊

TellH commented 2 years ago

@ikakaxi 你是用debug包试的吗,我看你的配置里

ByteX {
    enable true
    enableInDebug false
    logLevel "DEBUG"
}

enableInDebug = false ,你改成true试试?