#android #react-native #expo
Вопрос:
После некоторых неизвестных изменений мое приложение неоднократно зависало в приложении Expo Go только на Android, iOS работает нормально. Он ломается сразу после загрузки пакета javascript.
Со следующей ошибкой от adb logcat:
--------- beginning of crash
2021-10-17 21:41:12.536 4780-4957/host.exp.exponent A/libc: /usr/local/google/buildbot/src/android/ndk-release-r20/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type facebook::jsi::JSError: No identifiers allowed directly after numeric literal
no stack" failed
2021-10-17 21:41:12.536 4780-4957/host.exp.exponent A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 4957 (mqt_js), pid 4780 (st.exp.exponent)
2021-10-17 21:41:12.592 4964-4964/? A/DEBUG: pid: 4780, tid: 4957, name: mqt_js >>> host.exp.exponent <<<
2021-10-17 21:41:12.704 4964-4964/? A/DEBUG: #04 pc 000bad94 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libfbjni.so (BuildId: 3546c1351f83366cb88b3802c4c63ee907e2db98)
2021-10-17 21:41:12.704 4964-4964/? A/DEBUG: #05 pc 0009fc2e /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libfbjni.so (BuildId: 3546c1351f83366cb88b3802c4c63ee907e2db98)
2021-10-17 21:41:12.704 4964-4964/? A/DEBUG: #06 pc 000b78e9 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libfbjni.so (BuildId: 3546c1351f83366cb88b3802c4c63ee907e2db98)
2021-10-17 21:41:12.704 4964-4964/? A/DEBUG: #07 pc 000b8294 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libfbjni.so (BuildId: 3546c1351f83366cb88b3802c4c63ee907e2db98)
2021-10-17 21:41:12.704 4964-4964/? A/DEBUG: #08 pc 000b7dab /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libfbjni.so (BuildId: 3546c1351f83366cb88b3802c4c63ee907e2db98)
2021-10-17 21:41:12.704 4964-4964/? A/DEBUG: #09 pc 000b7a2e /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libfbjni.so (__gxx_personality_v0 158) (BuildId: 3546c1351f83366cb88b3802c4c63ee907e2db98)
2021-10-17 21:41:12.704 4964-4964/? A/DEBUG: #10 pc 00034dab /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libjscexecutor_abi42_0_0.so (BuildId: 0afc290041ee8f03)
2021-10-17 21:41:12.704 4964-4964/? A/DEBUG: #11 pc 00034e62 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libjscexecutor_abi42_0_0.so (BuildId: 0afc290041ee8f03)
2021-10-17 21:41:12.704 4964-4964/? A/DEBUG: #12 pc 0002e085 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libjscexecutor_abi42_0_0.so (facebook::jsc::JSCRuntime::evaluateJavaScript(std::__ndk1::shared_ptr<facebook::jsi::Buffer const> constamp;, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > constamp;) 629) (BuildId: 0afc290041ee8f03)
2021-10-17 21:41:12.705 4964-4964/? A/DEBUG: #13 pc 00025cd0 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libjscexecutor_abi42_0_0.so (facebook::react::JSIExecutor::loadBundle(std::__ndk1::unique_ptr<facebook::react::JSBigString const, std::__ndk1::default_delete<facebook::react::JSBigString const> >, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >) 384) (BuildId: 0afc290041ee8f03)
2021-10-17 21:41:12.705 4964-4964/? A/DEBUG: #14 pc 000b5401 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libreactnativejni_abi42_0_0.so (BuildId: a7dea22b245b2ec7)
2021-10-17 21:41:12.705 4964-4964/? A/DEBUG: #15 pc 000b6bcc /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libreactnativejni_abi42_0_0.so (BuildId: a7dea22b245b2ec7)
2021-10-17 21:41:12.705 4964-4964/? A/DEBUG: #16 pc 00078e9c /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libreactnativejni_abi42_0_0.so (BuildId: a7dea22b245b2ec7)
2021-10-17 21:41:12.705 4964-4964/? A/DEBUG: #17 pc 00068422 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libreactnativejni_abi42_0_0.so (facebook::jni::detail::MethodWrapper<void (facebook::react::JNativeRunnable::*)(), amp;(facebook::react::JNativeRunnable::run()), facebook::react::JNativeRunnable, void>::dispatch(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::react::JNativeRunnable, facebook::react::Runnable>::JavaPart, facebook::react::Runnable, void>::_javaobject*>) 50) (BuildId: a7dea22b245b2ec7)
2021-10-17 21:41:12.705 4964-4964/? A/DEBUG: #18 pc 00068389 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libreactnativejni_abi42_0_0.so (facebook::jni::detail::FunctionWrapper<void (*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::react::JNativeRunnable, facebook::react::Runnable>::JavaPart, facebook::react::Runnable, void>::_javaobject*>), amp;(facebook::jni::detail::MethodWrapper<void (facebook::react::JNativeRunnable::*)(), amp;(facebook::react::JNativeRunnable::run()), facebook::react::JNativeRunnable, void>::dispatch(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::react::JNativeRunnable, facebook::react::Runnable>::JavaPart, facebook::react::Runnable, void>::_javaobject*>)), facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<facebook::react::JNativeRunnable, facebook::react::Runnable>::JavaPart, facebook::react::Runnable, void>::_javaobject*, void>::call(_JNIEnv*, _jobject*) 73) (BuildId: a7dea22b245b2ec7)
2021-10-17 21:41:12.705 4964-4964/? A/DEBUG: #19 pc 00068333 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/lib/x86/libreactnativejni_abi42_0_0.so (facebook::jni::detail::MethodWrapper<void (facebook::react::JNativeRunnable::*)(), amp;(facebook::react::JNativeRunnable::run()), facebook::react::JNativeRunnable, void>::call(_JNIEnv*, _jobject*) 35) (BuildId: a7dea22b245b2ec7)
2021-10-17 21:41:12.705 4964-4964/? A/DEBUG: #20 pc 000cf258 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/oat/x86/base.odex (art_jni_trampoline 104)
2021-10-17 21:41:12.705 4964-4964/? A/DEBUG: #28 pc 009e3898 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/oat/x86/base.vdex (abi42_0_0.com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage)
2021-10-17 21:41:12.706 4964-4964/? A/DEBUG: #40 pc 009e3a26 /data/app/~~ZiekYe0x1Z8XbtryZLj4Dg==/host.exp.exponent-jT1g_VBoSLB3h6CrOBOi_g==/oat/x86/base.vdex (abi42_0_0.com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run 74)
2021-10-17 21:41:12.932 548-4971/system_process W/ActivityTaskManager: Force finishing activity host.exp.exponent/.experience.HomeActivity
2021-10-17 21:41:12.934 548-4971/system_process W/ActivityTaskManager: Force finishing activity host.exp.exponent/.experience.ExperienceActivity
2021-10-17 21:41:13.063 548-1284/system_process I/WindowManager: WIN DEATH: Window{d045a07 u0 host.exp.exponent/host.exp.exponent.experience.ExperienceActivity}
2021-10-17 21:41:13.063 548-1284/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel 'd045a07 host.exp.exponent/host.exp.exponent.experience.ExperienceActivity (server)'
2021-10-17 21:41:13.064 548-3885/system_process D/ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=33, [ Capabilities: NOT_RESTRICTEDamp;TRUSTEDamp;NOT_VPNamp;FOREGROUND Uid: 10121 AdministratorUids: [] RequestorUid: 10121 RequestorPackageName: host.exp.exponent] ], android.os.BinderProxy@39fc18e)
2021-10-17 21:41:13.065 548-960/system_process D/ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=34, [ Capabilities: NOT_RESTRICTEDamp;TRUSTEDamp;NOT_VPNamp;FOREGROUND Uid: 10121 AdministratorUids: [] RequestorUid: 10121 RequestorPackageName: host.exp.exponent] ], android.os.BinderProxy@9d2ddaf)
2021-10-17 21:41:13.084 548-2175/system_process I/ActivityManager: Process host.exp.exponent (pid 4780) has died: prcp TOP
пакет.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@expo/react-native-action-sheet": "^3.11.0",
"@expo/vector-icons": "^12.0.0",
"@react-native-community/datetimepicker": "3.5.2",
"@react-native-community/slider": "3.0.3",
"@react-navigation/bottom-tabs": "^6.0.5",
"@react-navigation/native": "^6.0.2",
"@react-navigation/native-stack": "^6.1.0",
"@reduxjs/toolkit": "^1.6.1",
"@svgr/webpack": "^5.2.0",
"compressorjs": "^1.1.1",
"expo": "~42.0.1",
"expo-camera": "~11.2.2",
"expo-image-manipulator": "~9.2.2",
"expo-image-picker": "~10.2.2",
"expo-linear-gradient": "~9.2.0",
"expo-status-bar": "~1.0.4",
"expo-svg-uri": "^1.3.1",
"firebase": "8.2.3",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-firebase-hooks": "^3.0.4",
"react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
"react-native-gesture-handler": "^1.10.3",
"react-native-modal": "^13.0.0",
"react-native-modalize": "^2.0.8",
"react-native-paper": "^4.9.2",
"react-native-safe-area-context": "3.2.0",
"react-native-screens": "~3.4.0",
"react-native-shared-element": "0.7.0",
"react-native-svg": "12.1.1",
"react-native-svg-transformer": "^0.14.3",
"react-native-web": "~0.13.12",
"react-redux": "^7.2.5",
"tailwind-react-native-classnames": "^3.0.1"
},
"devDependencies": {
"@babel/core": "^7.9.0"
},
"private": true
}
Я действительно не знаю, с чего начать отладку этого. Глядя на мой код, кажется, что это не является очевидной ошибкой, вызывающей это. Он отлично работает на iOS
Любая помощь будет очень признательна! Спасибо.
Я пытался:
- очистка кэша несколько раз.
- перезагрузка телефона
- работает на разных устройствах Android
Ответ №1:
У вас есть имя переменной, которое начинается с числа в вашем коде JavaScript.
Комментарии:
1. Это не тот случай. Моя IDE предупредила бы меня об этом. И если бы это было так, то iOS также вышла бы из строя. Это происходит только на Android..
Ответ №2:
Обнаружена проблема, числа с разделителями подчеркивания вызывают ошибки в Android.
НЕ В ПОРЯДКЕ:
const time = () => {
if(!previous) return false
if(!previous.message) return true
if(!message.createdAt) {
const t1 = previous.createdAt.toDate()
const dt1 = new Date(t1.toString()), dt2 = new Date()
return dt2.getTime() - dt1.getTime() > 600_000;
} else {
const t1 = previous.createdAt.toDate(), t2 = message.createdAt.toDate()
const dt1 = new Date(t1.toString()), dt2 = new Date(t2.toString())
return dt2.getTime() - dt1.getTime() > 600_000;
}
}
окей:
const time = () => {
if(!previous) return false
if(!previous.message) return true
if(!message.createdAt) {
const t1 = previous.createdAt.toDate()
const dt1 = new Date(t1.toString()), dt2 = new Date()
return dt2.getTime() - dt1.getTime() > 600000;
} else {
const t1 = previous.createdAt.toDate(), t2 = message.createdAt.toDate()
const dt1 = new Date(t1.toString()), dt2 = new Date(t2.toString())
return dt2.getTime() - dt1.getTime() > 600000;
}
}
Числа с разделителями подчеркивания вызывают ошибку на Android