bytedance / btrace

🔥🔥 btrace(AKA RheaTrace) is a high performance Android trace tool which is based on Perfetto, it support to define custom events automatically during building apk and using bhook to provider more native events like Render/Binder/IO etc.
Other
1.88k stars 268 forks source link

[E][MethodTracer] Failed to trace class:xxx.class, e:java.lang.TypeNotPresentException: Type android/widget/TextView not present #94

Open FutureHere opened 1 year ago

FutureHere commented 1 year ago

大部分类全部报如标题错误 编译环境: jdk11 agp4.1 classpath 'com.bytedance.btrace:rhea-gradle-plugin:2.0.3-rc02'

请问如何解决?

binIoter commented 1 year ago

遇到了同样的问题

mzule commented 1 year ago

打包加入 --stacktrace 给个完整的堆栈看看

FutureHere commented 1 year ago

打包加入 --stacktrace 给个完整的堆栈看看 image

WXZNJS commented 1 year ago

一样的问题,编译失败

mzule commented 1 year ago

打包加入 --stacktrace 给个完整的堆栈看看 image

贴个完整的堆栈看看呢?这里没有包含堆栈信息。

FutureHere commented 1 year ago

打包加入 --stacktrace 给个完整的堆栈看看 image

贴个完整的堆栈看看呢?这里没有包含堆栈信息。

这就是完整的日志。堆栈你们代码打印出来的就是如此啊 image 205行报的错 根本原因是ClassWriter image

FutureHere commented 1 year ago

我大胆猜测问题出在这 image

能不能给个联系方式 咱私聊

mzule commented 1 year ago

@FutureHere 感谢,可以加入飞书群进行沟通交流,另外我发布了一个测试版本,可以测试验证下 2.0.3-alpha04

livelitoday commented 1 year ago

@FutureHere 感谢,可以加入飞书群进行沟通交流,另外我发布了一个测试版本,可以测试验证下 2.0.3-alpha04

2.0.3-alpha04还是有报错:

yiwowang commented 1 year ago

我把plugin源码内的try 去掉,抛出这个异常,实际上com/xxx/TestClass类是存在的 Caused by: java.lang.TypeNotPresentException: Type com/xxx/TestClass not present at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1025) at org.objectweb.asm.SymbolTable.addMergedType(SymbolTable.java:1202) at org.objectweb.asm.Frame.merge(Frame.java:1299) at org.objectweb.asm.Frame.merge(Frame.java:1197) at org.objectweb.asm.MethodWriter.computeAllFrames(MethodWriter.java:1610) at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1546) at org.objectweb.asm.MethodVisitor.visitMaxs(MethodVisitor.java:773) at org.objectweb.asm.commons.LocalVariablesSorter.visitMaxs(LocalVariablesSorter.java:148) at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2642) at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1491) at org.objectweb.asm.ClassReader.accept(ClassReader.java:721) at org.objectweb.asm.ClassReader.accept(ClassReader.java:401) at com.bytedance.rheatrace.plugin.compiling.MethodTracer.innerTraceMethodFromJar(MethodTracer.kt:205) at com.bytedance.rheatrace.plugin.compiling.MethodTracer.access$innerTraceMethodFromJar(MethodTracer.kt:66) at com.bytedance.rheatrace.plugin.compiling.MethodTracer$traceMethodFromJar$1.run(MethodTracer.kt:104)

看了一下ASM这个方法:getCommonSuperClass,内部竟然使用ClassLoader加载类,jvm环境要加载安卓类当然加载不到,很奇怪。 protected String getCommonSuperClass(final String type1, final String type2) { ClassLoader classLoader = getClassLoader(); Class<?> class1; try { class1 = Class.forName(type1.replace('/', '.'), false, classLoader); } catch (ClassNotFoundException e) { throw new TypeNotPresentException(type1, e); }

litongxi8527 commented 9 months ago

这个问题解决了吗?我也碰到了

WangFeng-AHU commented 4 months ago

@FutureHere @binIoter @livelitoday @yiwowang @litongxi8527 我们升级了 2.0.3-rc03 版本尝试解决这个问题,几位可以试下能否解决问题

LiuHongtao commented 1 month ago

遇到同样问题,升级2.0.3-rc03已解决

LiuLeiThreestone commented 1 day ago

请问2.0.3-rc03在github的btrace上没有发布吧?master分支最新的代码有包含2.0.3-rc03的修改吗?@angFeng-AHU