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.92k stars 271 forks source link

打包报错,BuildException报错8个jar包 #140

Open withoutbuff opened 2 weeks ago

withoutbuff commented 2 weeks ago

我屏蔽其中一个包名,对应的jar报错会消失,但是我屏蔽所有的包名,只有最后一个生效,也就是说只有最后一个jar包的报错信息消失了。

btrace版本2.0.3-rc03 jdk1.8

-blockpackage com/airbnb/lottie/LottieTask -blockpackage androidx/exifinterface/media/ExifInterface -blockpackage com/tencent/tinker/android/dex/Dex -blockpackage com/android/multidex/MainDexListBuilder 为什么我配置多个屏蔽项目,只有最后一个有用?

有8个类似下发的报错 org.gradle.tooling.BuildException: Failed to process: C:\Users\fionn.zhang\AndroidStudioProjects\n1904\app\build\intermediates\transforms\rheaTrace\overseaFour\debug\29.jar

withoutbuff commented 2 weeks ago

private fun parseTraceFilterFile(processor: MappingCollector) { var methodKeepStr = DEFAULT_BLOCK_PACKAGES if (traceFilterFilePath != null && File(traceFilterFilePath!!).exists()) { methodKeepStr += FileUtil.readFileAsString(traceFilterFilePath) } val methodKeepArray = methodKeepStr.trim { it <= ' ' }.replace("/", ".").split("\n").toTypedArray() val iterator = methodKeepArray.iterator() loop@ while (iterator.hasNext()) { val item = iterator.next() when { item.isEmpty() || item.startsWith("#") || item.startsWith("[") -> { continue@loop } item.startsWith("-defaultblockpackage ") -> { val packageName = item.replace("-defaultblockpackage ", "") defaultBlockPackages.add(packageName) } item.startsWith("-blockpackage ") -> { val blockPackageString = item.replace("-blockpackage ", "") blockPackages.add(blockPackageString) } item.startsWith("-allowpackage ") -> { val packageName = item.replace("-allowpackage ", "") allowPackages.add(packageName) } item.startsWith("-blockclassmethods ") -> { val className = item.replace("-blockclassmethods ", "").replace("{", "").trim() while (iterator.hasNext()) { val methodItem = iterator.next().split(";").first().replace(" ", "") if (methodItem == "}") { continue@loop } blockMethodSet.add("$className.$methodItem") } } item.startsWith("-allowclassmethodswithparametervalues ") -> { val className = item.replace("-allowclassmethodswithparametervalues ", "").replace("{", "").trim() while (iterator.hasNext()) { val methodItem = iterator.next().split(";").first().replace(" ", "") if (methodItem == "}") { continue@loop } formatClassMethodsWithParam(className, methodItem) } } item.startsWith("-traceclass ") -> { val traceClass = item.replace("-traceclass ", "") traceClassSet.add(traceClass) } item.startsWith("-traceclassmethods ") -> { val classInfoItems = item.replace("-traceclassmethods ", "").replace("{", "").trim().split(" ") var className = "" var superClassName = "" if (classInfoItems.size == 3) { if (classInfoItems[1] != "implements") { throw Exception("traceclassmethods error:implements cannot parse correctly") } superClassName = classInfoItems[2] } else { className = classInfoItems[0] } while (iterator.hasNext()) { val methodInfoItems = iterator.next().trim().split(" ") if (methodInfoItems[0] == "}") { continue@loop } val traceMethod = FilterTraceMethodData() traceMethod.method = methodInfoItems[0] traceMethod.className = className traceMethod.superClassName = superClassName traceMethodSet.add(traceMethod) } } item.startsWith("-enablepreciseinstrumentation") -> { enablePreciseInstrumentation = true } } } RheaLog.i(TAG, " allow packages: $allowPackages, block packages: $blockPackages") }

withoutbuff commented 2 weeks ago

rheaTrace { compilation { traceFilterFilePath = "${project.rootDir}/trace-filter/traceFilter.txt" needPackageWithMethodMap = true applyMethodMappingFilePath = "" } }

withoutbuff commented 2 weeks ago

以下三种分隔方式都不行 使用空格分隔 -blockpackage com/airbnb/lottie/LottieTask androidx/exifinterface/media/ExifInterface 使用逗号分隔 -blockpackage com/airbnb/lottie/LottieTask,androidx/exifinterface/media/ExifInterface 使用换行符分隔 -blockpackage com/airbnb/lottie/LottieTask androidx/exifinterface/media/ExifInterface

withoutbuff commented 2 weeks ago

找了源码相关部分,应该这么写,但是只有最后一行有用 -blockpackage com/airbnb/lottie/LottieTask -blockpackage androidx/exifinterface/media/ExifInterface -blockpackage com/tencent/tinker/android/dex/Dex -blockpackage com/android/multidex/MainDexListBuilder