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

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0 #138

Open
successfBoy opened this issue Aug 13, 2024 · 8 comments

Comments

@successfBoy
Copy link

gradle:
classpath 'com.android.tools.build:gradle:7.2.2'
distributionUrl=https://services.gradle.org/distributions/gradle-7.5-bin.zip

配置:
apply plugin: 'com.bytedance.rhea-trace'

implementation "com.bytedance.btrace:rhea-core:2.0.3-rc03"

rheaTrace {
compilation {
traceFilterFilePath = ""
needPackageWithMethodMap = true
applyMethodMappingFilePath = ""
}
}

执行命令:
java -jar rhea-trace-processor-2.0.0.jar -a com.weo.projectz -t 10 -o output.pb rhea.all sched -fullClassName -debug -mode simple

报错

08-13 15:06:15.180 D RheaTrace : SystemTime is 0
08-13 15:06:15.180 D RheaTrace : BootTime is 16038188335075
08-13 15:06:15.180 D RheaTrace : Monotonic is 15431727692913
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:365)
at java.base/java.util.ArrayList.get(ArrayList.java:428)
at com.bytedance.rheatrace.processor.core.AppTraceProcessor.processBinary(AppTraceProcessor.java:200)
at com.bytedance.rheatrace.processor.core.AppTraceProcessor.getBinaryTrace(AppTraceProcessor.java:50)
at com.bytedance.rheatrace.processor.lite.LiteCapture.process(LiteCapture.java:73)
at com.bytedance.rheatrace.processor.Main.main(Main.java:108)
08-13 15:06:15.236 D RheaTrace : Run adb shell setprop debug.rhea.startWhenAppLaunch 0
08-13 15:06:15.279 D RheaTrace : Run adb shell setprop debug.rhea.mainThreadOnly 0
08-13 15:06:15.324 D RheaTrace : Run adb shell setprop debug.rhea.methodDurThreshold 0
08-13 15:06:15.373 D RheaTrace : Run adb shell setprop debug.rhea.category.all 0
log.log

log.log

@successfBoy
Copy link
Author

image image

@WangFeng-AHU
Copy link
Collaborator

采集的 trace 数据为空的失败,看下 methodMapping.txt 文件里插桩了哪些方法,在 trace 采集时这些方法会不会被执行,是不是因为插桩方法都没有执行导致的

@successfBoy
Copy link
Author

我看methodMapping中非常多的方法。我设置下过滤吧,然后是不是因为我整个项目是compose 写的,所以会插桩失败。

@WangFeng-AHU
Copy link
Collaborator

还可以检查下 apk 看 methodMapping 中记录的方法是否确实插桩成功了,插桩后方法的开始和结束会有 TraceStub.i(int) 和 TraceStub.o(int, long) 方法的调用

@successfBoy
Copy link
Author

image 看反编译之后的代码是有TraceStub.i(int) 和 TraceStub.o(int, long) 方法的调用 。执行命令还是不行。

@successfBoy
Copy link
Author

我看了下确实很少的插桩,然后编译后有ignoreMethodMapp 这个文件里面有很多我需要插桩的类。这个是在哪里配置的呢?

@WangFeng-AHU
Copy link
Collaborator

我看了下确实很少的插桩,然后编译后有ignoreMethodMapp 这个文件里面有很多我需要插桩的类。这个是在哪里配置的呢?

这个说明你 traceFilter 配置的不合理,加上诸如 -allowpackage com.weo 来指定需要插桩的包路径吧

@successfBoy
Copy link
Author

现在可以了。我不知道是不是因为我重启了下手机。还是我去掉了项目中另外一个插件。现在可以抓了。

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

No branches or pull requests

2 participants