首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从firebase crashlytics堆栈跟踪文本index.android.bundle或iOS main.jsbundle获取错误源文件?

如何从firebase crashlytics堆栈跟踪文本index.android.bundle或iOS main.jsbundle获取错误源文件?
EN

Stack Overflow用户
提问于 2021-05-26 17:10:26
回答 1查看 2.3K关注 0票数 3

如何从指向index.android.bundle:474:6500的crashlytics堆栈跟踪行获取源文件行和列信息?

crashlytics报告堆栈跟踪文本看起来类似于:

代码语言:javascript
复制
Non-fatal Exception: io.invertase.firebase.crashlytics.UnhandledPromiseRejection: undefined is not an object (evaluating 't.includes')
       at .removeFile(index.android.bundle:474:6500)
       at .<unknown>(index.android.bundle:758:3472)
       at .y(index.android.bundle:105:596)
       at .<unknown>(index.android.bundle:105:2546)
       at .y(index.android.bundle:105:596)
       at .o(index.android.bundle:105:1483)
       at .<unknown>(index.android.bundle:105:1626)
       at .f(index.android.bundle:101:155)
       at .<unknown>(index.android.bundle:101:1012)
       at .y(index.android.bundle:107:657)
       at .C(index.android.bundle:107:1021)
       at .callImmediates(index.android.bundle:107:3216)
       at .callImmediates([native code]:0:0)
       at .value(index.android.bundle:25:3080)
       at .<unknown>(index.android.bundle:25:1264)
       at .value(index.android.bundle:25:2772)
       at .value(index.android.bundle:25:1234)
       at .value([native code]:0:0)
       at .value([native code]:0:0)

我尝试了堆叠美容有限的成功。有没有更可靠的方法?

EN

回答 1

Stack Overflow用户

发布于 2021-05-26 17:10:26

我花了几天时间想出一个好的解决方案。这是我迄今发现的最好的。

1)从Git标记或提交哈希创建源代码地图,与Crashlytics报告的版本相对应

iOS

代码语言:javascript
复制
react-native bundle --platform ios --entry-file index.js --dev false --reset-cache --bundle-output /tmp/bundle.ios.js --assets-dest /tmp/ --sourcemap-output sourcemap.ios.js.map

Android从build自动生成

代码语言:javascript
复制
// https://github.com/facebook/react-native/issues/7393
// https://stackoverflow.com/questions/34715106/how-to-add-sourcemap-in-react-native-for-production/34733906
project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing    
    extraPackagerArgs: ["--sourcemap-output", 
    file("$buildDir/../../../sourcemap.android.js.map")]
]

或者手工构建:

代码语言:javascript
复制
react-native bundle --platform android --entry-file index.js --dev false --reset-cache --bundle-output /tmp/bundle.android.js --assets-dest /tmp/ --sourcemap-output sourcemap.android.js.map

2)使用地铁-象征意义

  1. Google Firebase控制台中打开崩溃报告
  2. 选择堆栈跟踪选项卡
  3. 选择TXT选项卡并将文本保存到名为mytrace.txt的文件中
  4. 删除从包含“本机代码”的第一行开始的所有堆栈跟踪行,因为“本机代码”似乎会引起问题。
  5. 结果示例:错误起源于Utility.js:567
代码语言:javascript
复制
npx metro-symbolicate sourcemap.android.js < fs-27-stack-trace.txt                                                                 
Non-fatal Exception: io.invertase.firebase.crashlytics.UnhandledPromiseRejection: undefined is not an object (evaluating 't.includes')
       at .removeFile(/Users/eddie/Documents/projects/react-native/my-react-native-app/v1.6.1146/source/app/components/Utility.js:567:includes)
       at .<unknown>(/Users/eddie/Documents/projects/react-native/my-react-native-app/v1.6.1146/source/app/components/software-downloader/DownloadClient.js:237:oldVersion)

我希望这会对其他人有所帮助。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67709680

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档