iT邦幫忙

2024 iThome 鐵人賽

DAY 7
0

今天來用 Mac 重覆 Day 6 的進度,看會出現什麼結果。

在安裝好 Expo Notification library 後,運行 Android App,出現下列錯誤訊息:

Logs for your project will appear below. Press Ctrl+C to exit.
Android Bundling failed 3796ms node_modules/expo/AppEntry.js (638 modules)
Unable to resolve "expo-device" from "App.js"

原來是漏掉 IDE 提示下列 package 尚未安裝所造成的。

import * as Device from 'expo-device';
...
import Constants from 'expo-constants';

依照 IDE 提供的幫助按鈕,把這 2 個 package 安裝後,再使用 npm run android 運行 App。
看起來有啟用 Expo Go 的 App,但在 terminal 按下 a 來運行 android App 時,出現以下錯誤。

Logs for your project will appear below. Press Ctrl+C to exit.
› Opening on Android...
› Opening exp://192.168.1.103:8081 on Pixel_5_API_28
› Press ? │ show all commands
Android Bundled 1036ms node_modules/expo/AppEntry.js (751 modules)
 ERROR  TypeError: Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.

This error is located at:
    in App (created by withDevTools(App))
    in withDevTools(App)
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent), js engine: hermes
 ERROR  TypeError: Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.

This error is located at:
    in App (created by withDevTools(App))
    in withDevTools(App)
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent), js engine: hermes

看到這段錯誤,不確定是不是在模擬器上運行 App 所導致的。
官方有說要在實體手機上運行才能使用範例程式碼。

明天來連上實體手機跑看看。

末段來看一下 terminal 提供的操作提示。

npm run android

notificationprogress@1.0.0 android
expo start --android

Starting project at /Users/(省略)/development/jim/NotificationProgress
Starting Metro Bundler
› Opening exp://(省略) on Pixel_5_API_28
(QR Code)

› Metro waiting on exp://(省略)
› Scan the QR code above with Expo Go (Android) or the Camera app (iOS)

› Using Expo Go
// s: 切換至開發構建模式
› Press s │ switch to development build
// a: 開啟 Android 應用程式
› Press a │ open Android
// i: 使用 iOS 模擬器開啟應用程式
› Press i │ open iOS simulator
// w: 開啟網頁應用程式
› Press w │ open web
// j: 開啟偵錯工具
› Press j │ open debugger
// r: 重新載入 App
› Press r │ reload app
// m: 展開選單
› Press m │ toggle menu
// o: 使用編譯器開啟專案程式碼
› Press o │ open project code in your editor
// ?: 顯示所有可用命令
› Press ? │ show all commands


上一篇
[Day 6] Windows 安裝 Expo Notification library
系列文
跨平台協同:在 React Native 和 Kotlin 應用中實現無縫交互 -以 Notification 為例7
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言