如何跟踪 JavascriptException index.android.bundle:424:4194 到 JS 源中的行号?
How to trace JavascriptException index.android.bundle:424:4194 to line number in JS source?
Google 播放堆栈跟踪指向崩溃的原因:
com.facebook.react.modules.core.JavascriptException: addWaypointDone
index.android.bundle:424:4194
我从 apk 中提取了 index.android.bundle。
如何从 424:4194 获取 JS 源代码行号?
谢谢丹尼尔。你的方法在命令行对我有用!
我尝试将其添加到 android/app/react.gradle 但我无法在 ./android 目录下找到 source.map 文件。
commandLine "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}”,
"--sourcemap-output", "source.map",
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets dest", resourcesDir
有没有一种方法可以随时自动构建 source.map 文件?
提前致谢,
要获得准确位置,您需要源地图。如果您不保留这些用于部署,您可以重新生成它。
- 检查您从 VCS 部署的确切版本
- 将其与源映射输出捆绑在一起:
react-native bundle --entry-file index.android.js --platform android --dev false --sourcemap-output source.map --bundle-output main.jsbundle
(确保您使用的依赖版本与您在发布中使用的依赖版本完全相同)
- 创建包含以下代码的文件
findpos.js
:
findpos.js
var sourceMap = require('source-map');
var fs = require('fs');
var sourcemap = JSON.parse(fs.readFileSync('source.map', 'utf8'));
var smc = new sourceMap.SourceMapConsumer(sourcemap);
console.log(smc.originalPositionFor({
line: 424,
column: 4194
}));
- 执行脚本
node findpos.js
您应该得到错误的确切位置(文件、行和列)。
如何使用Atom查找index.android.bundle
中的异常源码
- 从 Google Play
获取堆栈跟踪
- 使用 zip 扩展重命名 apk 文件并提取 apk
- 使用 Atom 或其他编辑器,打开提取的“'assets/index.android.bundle'”
- 编辑 > 转到行,来自堆栈跟踪,424:4194
从 index.android.bundle 中删除所有白色-space,并将行连接成一行。但它确定了罪魁祸首。
Google 播放堆栈跟踪指向崩溃的原因:
com.facebook.react.modules.core.JavascriptException: addWaypointDone
index.android.bundle:424:4194
我从 apk 中提取了 index.android.bundle。
如何从 424:4194 获取 JS 源代码行号?
谢谢丹尼尔。你的方法在命令行对我有用!
我尝试将其添加到 android/app/react.gradle 但我无法在 ./android 目录下找到 source.map 文件。
commandLine "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}”,
"--sourcemap-output", "source.map",
"--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets dest", resourcesDir
有没有一种方法可以随时自动构建 source.map 文件?
提前致谢,
要获得准确位置,您需要源地图。如果您不保留这些用于部署,您可以重新生成它。
- 检查您从 VCS 部署的确切版本
- 将其与源映射输出捆绑在一起:
react-native bundle --entry-file index.android.js --platform android --dev false --sourcemap-output source.map --bundle-output main.jsbundle
(确保您使用的依赖版本与您在发布中使用的依赖版本完全相同) - 创建包含以下代码的文件
findpos.js
:
findpos.js
var sourceMap = require('source-map');
var fs = require('fs');
var sourcemap = JSON.parse(fs.readFileSync('source.map', 'utf8'));
var smc = new sourceMap.SourceMapConsumer(sourcemap);
console.log(smc.originalPositionFor({
line: 424,
column: 4194
}));
- 执行脚本
node findpos.js
您应该得到错误的确切位置(文件、行和列)。
如何使用Atom查找index.android.bundle
中的异常源码- 从 Google Play 获取堆栈跟踪
- 使用 zip 扩展重命名 apk 文件并提取 apk
- 使用 Atom 或其他编辑器,打开提取的“'assets/index.android.bundle'”
- 编辑 > 转到行,来自堆栈跟踪,424:4194
从 index.android.bundle 中删除所有白色-space,并将行连接成一行。但它确定了罪魁祸首。