btrace
btrace copied to clipboard
failed to write rhea-atrace.gz file completely
2022-03-31 14:24:28.516 7791-7791/com.example.myapplication E/rhea:atrace: failed to create directory /storage/emulated/0/rhea-trace/com.example.myapplication 2022-03-31 14:24:28.555 7791-7791/com.example.myapplication I/Toast: Show toast from OpPackageName:com.example.myapplication, PackageName:com.example.myapplication 2022-03-31 14:24:33.598 7791-7791/com.example.myapplication D/Rhea:TraceSwitch: RheaTrace has not been started, just ignore!
2022-03-31 14:24:27,949 - rhea_trace - capture - INFO: - app 'com.example.myapplication' has been started, just start tracing immediately. 2022-03-31 14:24:28,029 - rhea_trace - capture - INFO: - start to capture atrace for 5 seconds, now you can operate your app. 2022-03-31 14:24:33,035 - rhea_trace - capture - INFO: - stop to capture atrace, it maybe take a long time... 2022-03-31 14:25:00,154 - rhea_trace - main_impl - ERROR: - failed to write rhea-atrace.gz file completely. 2022-03-31 14:25:00,168 - rhea_trace - unzip_rhea_original_file - ERROR: - adb: error: failed to stat remote object 'sdcard/rhea-trace/com.example.myapplication/rhea-atrace.gz': No such file or directory
WARM PROMPT
- Make sure you have grant permission of writing external storage.
- Make sure RheaTrace has been integrated into your app and inited successfully.
- if
startWhenAppLaunch
is false, you can't capture trace when launch app.
2022-03-31 14:25:00,168 - rhea_trace - processor - INFO: - unzip atrace file: False, unable to pull raw atrace file from device.
2022-03-31 14:24:28.516 7791-7791/com.example.myapplication E/rhea:atrace: failed to create directory /storage/emulated/0/rhea-trace/com.example.myapplication 2022-03-31 14:24:28.555 7791-7791/com.example.myapplication I/Toast: Show toast from OpPackageName:com.example.myapplication, PackageName:com.example.myapplication 2022-03-31 14:24:33.598 7791-7791/com.example.myapplication D/Rhea:TraceSwitch: RheaTrace has not been started, just ignore!
2022-03-31 14:24:27,949 - rhea_trace - capture - INFO: - app 'com.example.myapplication' has been started, just start tracing immediately. 2022-03-31 14:24:28,029 - rhea_trace - capture - INFO: - start to capture atrace for 5 seconds, now you can operate your app. 2022-03-31 14:24:33,035 - rhea_trace - capture - INFO: - stop to capture atrace, it maybe take a long time... 2022-03-31 14:25:00,154 - rhea_trace - main_impl - ERROR: - failed to write rhea-atrace.gz file completely. 2022-03-31 14:25:00,168 - rhea_trace - unzip_rhea_original_file - ERROR: - adb: error: failed to stat remote object 'sdcard/rhea-trace/com.example.myapplication/rhea-atrace.gz': No such file or directory
WARM PROMPT
- Make sure you have grant permission of writing external storage.
- Make sure RheaTrace has been integrated into your app and inited successfully.
- if
startWhenAppLaunch
is false, you can't capture trace when launch app.2022-03-31 14:25:00,168 - rhea_trace - processor - INFO: - unzip atrace file: False, unable to pull raw atrace file from device.
见https://github.com/bytedance/btrace/issues/37 亲测有效
见https://github.com/bytedance/btrace/issues/37 亲测有效,应该不是同一个问题现象,我这边有初始化的日志,但是出现创建文件夹失败问题
仍然无效,设置 startWhenAppLaunch true,出现错误如下:
2022-07-05 14:59:52.385 8455-8455/com.example.myapplication D/BaseLifecycleCallback_MainActivity: onActivityPaused called
2022-07-05 14:59:52.402 8455-8455/com.example.myapplication D/BaseLifecycleCallback_MainActivity: onActivityStopped called
2022-07-05 14:59:52.406 8455-8455/com.example.myapplication D/BaseLifecycleCallback_MainActivity: onActivitySaveInstanceState called
2022-07-05 15:00:20.451 8972-8972/? I/e.myapplicatio: Late-enabling -Xcheck:jni
2022-07-05 15:00:20.496 8972-8972/? E/e.myapplicatio: Unknown bits set in runtime_flags: 0x8000
2022-07-05 15:00:21.076 8972-8993/com.example.myapplication W/e.myapplicatio: Long monitor contention with owner main (8972) at void java.lang.Object.
权限已申请成功,仍然存在上述问题,说明不是权限问题 #37 讲的初始化问题,我这边代码中有 初始化相关代码
我也出现了和你一样的问题,然后我换了一个测试机就好了,不知道为什么
我也遇到了相同的问题。可能还是由于没有完成sdk的初始化。所以在自定义Application类的attachBaseContext方法内强制调用初始化方法 TraceApplicationLike.attachBaseContex()
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
TraceApplicationLike.attachBaseContext(base);
}
因为TraceApplicationLike源码注释说:会在 Application#attachBaseContext(Context)
里注入。
/**
* the method would be injected in {@link Application#attachBaseContext(Context)} of your app application.
*
* @param context base context of application.
*/
public static void attachBaseContext(Context context) {
if (Build.VERSION.SDK_INT < 18) {
throw new RuntimeException("rhea trace don't support api level lower than 18");
}
TraceSwitch.init(context);
}
不懂它的注入的内部逻辑,但是我估计在某些设备上可能会注入失败。 所以如果你的设备也遇到只这个问题,可以强制手动初始化试一下,最后不要忘了授权读写sdcard。
读写权限先授权
adb shell pm grant com.alibaba.aliexpresshd android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.alibaba.aliexpresshd android.permission.WRITE_EXTERNAL_STORAGE
可以试试2.0.0版本,已经不再依赖存储权限了。