我一直致力于反应本机应用程序开发,我已经构建了一个发布版本。不幸的是,当应用程序调用 auth().signInWithPhoneNumber() 函数时,发布的版本导致我出现意外错误。相反,debug版本不会造成任何问题。
由于我无法在已发布的应用程序中获取任何日志,因此我进一步记录了错误消息。原来,firebase返回的错误信息是
{{'行': 101, '列': 244, 'sourceURL': 'index.android.bundle'}}
因此,我对index.android.bundle进行了一些研究,似乎google中的资源都是关于JS的,没有正确捆绑它。在这种情况下,我会毫不犹豫地尝试任何可以在网上搜索到的解决方案。
我遵循的解决方案之一是 https://medium.com/@shreyasnisal/solved-packing-error-in-react-native-release-apk-f887687edc4f
React-Native Bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src /主/资源
解决这个问题也没有运气。
错误返回后的代码
async function signInWithPhoneNumber(phoneNumber: string, event: any) {
event.preventDefault();
try {
const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
if (confirmation) {
setConfirm(confirmation);
}
} catch (err) {
console.log('Check Exist Error2 - ' + err.message);
console.log('error Code - ' + err.code);
setErrorOccured(true);
if (err.code === 'missing-phone-number') {
console.log('Missing Phone Number.');
setErrorMsg('Missing Phone Number.');
} else if …
Run Code Online (Sandbox Code Playgroud) javascript android reactjs react-native firebase-authentication