I am a beginner in the subject of apk development, so your help will be much appreciated.
I started a few days ago with expo, but I can’t manage to solve that specific error:
“Invariant failed (Device)”
Here is the code
Here is the barcode for Expo Go
Its should be a template that I will change it according to the apk i will need.
I tried running it on an Android device:
Just based on the error it looks like there’s some web browser-specific code that’s trying to run in the Expo Go app. This won’t work because React Native isn’t a web browser, so the
createBrowserHistory call fails.
By the way, your package.json on GitHub is incomplete. It looks like what you see in a Snack, but Snack doesn’t show you everything that should be there. If you Export the project from Snack you’ll see it fills in the rest of the stuff that should be there.
If I export the snack, run
yarn to install the dependencies and then search for
createBrowserHistory I find this:
coding % grep -rl createBrowserHistory . ./node_modules/history/createBrowserHistory.js ./node_modules/history/esm/history.js ./node_modules/history/umd/history.js ./node_modules/history/umd/history.min.js ./node_modules/history/package.json ./node_modules/history/es/createBrowserHistory.js ./node_modules/history/cjs/history.js ./node_modules/history/cjs/history.min.js ./node_modules/react-router-dom/esm/react-router-dom.js ./node_modules/react-router-dom/esm/react-router-dom.js.map ./node_modules/react-router-dom/umd/react-router-dom.js ./node_modules/react-router-dom/umd/react-router-dom.min.js.map ./node_modules/react-router-dom/umd/react-router-dom.js.map ./node_modules/react-router-dom/modules/BrowserRouter.js ./node_modules/react-router-dom/cjs/react-router-dom.js ./node_modules/react-router-dom/cjs/react-router-dom.min.js.map ./node_modules/react-router-dom/cjs/react-router-dom.js.map ./node_modules/react-router-dom/cjs/react-router-dom.min.js ./node_modules/react-router/umd/react-router.min.js.map ./node_modules/react-router/umd/react-router.js.map coding % yarn why history yarn why v1.22.11 [1/4] 🤔 Why do we have the module "history"...? [2/4] 🚚 Initialising dependency graph... [3/4] 🔍 Finding dependency... [4/4] 🚡 Calculating file sizes... => Found "email@example.com" info Reasons this module exists - "react-router" depends on it - Hoisted from "react-router#history" - Hoisted from "react-router-dom#history" info Disk size without dependencies: "240KB" info Disk size with unique dependencies: "1.25MB" info Disk size with transitive dependencies: "1.32MB" info Number of shared dependencies: 8 ✨ Done in 0.24s. coding % grep react-router package.json "react-router": "^5.2.0", "react-router-dom": "^5.2.0", coding % yarn why react-router-dom yarn why v1.22.11 [1/4] 🤔 Why do we have the module "react-router-dom"...? [2/4] 🚚 Initialising dependency graph... [3/4] 🔍 Finding dependency... [4/4] 🚡 Calculating file sizes... => Found "firstname.lastname@example.org" info Has been hoisted to "react-router-dom" info This module exists because it's specified in "dependencies". info Disk size without dependencies: "820KB" info Disk size with unique dependencies: "2.93MB" info Disk size with transitive dependencies: "3.36MB" info Number of shared dependencies: 13 ✨ Done in 0.24s.
So it’s coming from
react-router-dom. These are not compatible with React Native. Try something like React Navigation instead.
The problem were those react-router imports, as you said.
I have other errors so I’ll keep working on it.