Expo error Unexpected token '{'. import call expects exactly one argument - android

It was working fine until I installed some packages with --legacy-peer-deps. then I uninstalled those packages but the error remained
my package.json:
{
"name": "nativefetchdemo",
"version": "1.0.0",
"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": {
"#react-native-async-storage/async-storage": "^1.17.7",
"#react-native-community/masked-view": "^0.1.11",
"#react-native-material/core": "^1.3.7",
"#react-navigation/native": "^6.0.11",
"#react-navigation/stack": "^6.2.2",
"axios": "^0.27.2",
"expo": "~45.0.0",
"expo-build-properties": "~0.2.0",
"expo-device": "~4.2.0",
"expo-notifications": "~0.15.4",
"expo-permissions": "~13.2.0",
"expo-status-bar": "~1.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-gesture-handler": "~2.2.1",
"react-native-paper": "^4.12.4",
"react-native-reanimated": "~2.8.0",
"react-native-safe-area-context": "4.2.4",
"react-native-screens": "~3.11.1",
"react-native-svg-transformer": "^1.0.0",
"react-native-web": "0.17.7",
"react-redux": "^8.0.2",
"redux": "^4.2.0",
"redux-devtools-extension": "^2.13.9",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.4.1",
"tailwindcss-react-native": "^1.7.10",
"twrnc": "^3.3.3"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"tailwindcss": "^3.1.8"
},
"private": true
}
I installed the packages which made this error appear. It was fine when only the current packages were there. but now the error won' go away.
Idk if it caused it but I used --legacy-peer-deps command line when installing packages because some packages had different versions of react
my babel.config.js:
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
'tailwindcss-react-native/babel',
'react-native-reanimated/plugin',
],
env: {
production: {
plugins: ['react-native-paper/babel', 'react-native-reanimated/plugin'],
},
},
};
};

Related

Expo eas build apk crashes on real device but work on expo go

Everything runs normally while testing with the emulator in development env but when i built my expo app to get an apk with this command eas build -p android --profile preview.
After i installed the apk on a real device it instantly crashes.
But if i run it on expo go, it runs normally.
Here is my package.json
{
"name": "myapp",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"#react-native-firebase/app": "^16.4.6",
"#react-native-firebase/messaging": "^16.4.6",
"#react-native-picker/picker": "^2.4.8",
"#react-navigation/drawer": "^6.5.3",
"#react-navigation/native": "^6.0.16",
"#react-navigation/stack": "^6.3.7",
"#reduxjs/toolkit": "^1.9.1",
"email-validator": "^2.0.4",
"expo": "~47.0.8",
"expo-dev-client": "~2.0.1",
"expo-device": "~5.0.0",
"expo-image-picker": "~14.0.2",
"expo-notifications": "~0.17.0",
"expo-status-bar": "~1.4.2",
"expo-updates": "~0.15.6",
"firebase": "^9.6.7",
"formik": "^2.2.9",
"react": "18.1.0",
"react-native": "0.70.5",
"react-native-gesture-handler": "~2.8.0",
"react-native-modal-datetime-picker": "^14.0.0",
"react-native-reanimated": "^2.12.0",
"react-native-safe-area-context": "^4.4.1",
"react-native-screens": "~3.18.0",
"react-native-toast-message": "^2.1.5",
"react-redux": "^8.0.5",
"redux": "^4.2.0",
"redux-thunk": "^2.4.2",
"yup": "^0.32.11"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
And here is my eas.json
{
"cli": {
"version": ">= 2.6.0"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal",
"android": {
"buildType": "apk"
}
},
"preview2": {
"android": {
"gradleCommand": ":app:assembleRelease"
}
},
"production": {}
},
"submit": {
"production": {}
}
}

Raise error after reload android app on React-native

When I run the app via "expo run:android" the app starts, but if I close the app in the emulator and try to run it again, I get 2 errors:
Screen native module hasn't been linked. Please check the react-native-screens README for more details
and
Invariant Violation: requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager.
Is this normal behavior or am I missing something?
My package.json
{
"name": "mwproductivity",
"version": "1.0.0",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
},
"dependencies": {
"#expo/webpack-config": "^0.17.0",
"#react-native-community/masked-view": "^0.1.11",
"#react-navigation/native": "^6.0.13",
"#react-navigation/native-stack": "^6.9.1",
"#reduxjs/toolkit": "^1.8.6",
"expo": "~46.0.16",
"expo-splash-screen": "~0.16.2",
"expo-status-bar": "~1.4.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "0.69.6",
"react-native-gesture-handler": "^2.7.1",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-reanimated": "^2.11.0",
"react-native-safe-area-context": "^4.4.1",
"react-native-screens": "^3.18.2",
"react-native-sqlite-storage": "^6.0.1",
"react-native-web": "~0.18.7",
"react-redux": "^8.0.4",
"styled-components": "^5.3.6"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}

Unexpected token no stack - android emulator expo

I get this weird message in android emulator whilst running expo, any idea whats causing this? There seems to be no real stack trace. If I run in debug mode, it works fine which is odd. There's definitely enough space on the hard disk so don't think that's an issue either.
Package.json
{
"name": "project",
"version": "1.0.0",
"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-google-fonts/kanit": "^0.2.2",
"#expo-google-fonts/oxanium": "^0.2.2",
"#fortawesome/fontawesome-svg-core": "^6.1.1",
"#fortawesome/free-solid-svg-icons": "^6.1.1",
"#fortawesome/react-native-fontawesome": "^0.3.0",
"#react-navigation/drawer": "^6.4.3",
"#react-navigation/native": "^6.0.11",
"#react-navigation/native-stack": "^6.7.0",
"axios": "^0.27.2",
"expo": "^46.0.0",
"expo-status-bar": "~1.4.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "0.69.4",
"react-native-dotenv": "^3.3.1",
"react-native-reanimated": "~2.9.1",
"react-native-safe-area-context": "4.3.1",
"react-native-screens": "~3.15.0",
"react-native-svg": "12.3.0",
"react-native-web": "~0.18.7",
"react-native-webview": "11.23.0",
"react-native-youtube-iframe": "^2.2.2"
},
"devDependencies": {
"#babel/core": "^7.18.6",
"#babel/preset-react": "^7.18.6",
"eslint": "^8.19.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-native": "^4.0.0"
},
"private": true
}
babel.config.js
module.exports = function(api) {
api.cache(true);
return {
presets: [
'babel-preset-expo'
],
plugins: [
'react-native-reanimated/plugin',
'module:react-native-dotenv'
]
};
};
Found the solution. You have to run the emulator without Android Studio (ie. from the command line)
In Windows:
cd C:\Users\%USERNAME%\AppData\Local\Android\Sdk\emulator
emulator -avd Pixel_5_API_30
Of course, switch 'Pixel_5_API_30' with the name of the emulator listed in Android Studio.

Expo start works but Expo build apk does not

I am able to run my react-native app locally using expo start --no-dev. When I try to build the APK and install it, it installs succesfully but when I run it, the app just closes and I get the android error frontend keeps stopping.
app.json
{
"name": "frontend",
"displayName": "frontend",
"expo": {
"name": "frontend",
"slug": "frontend",
"version": "1.0.0",
"assetBundlePatterns": [
"**/*"
],
"android": {
"package": "com.sri.showify",
"versionCode": 1
}
}
}
package.json
{
"main": "index.js",
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"#ptomasroos/react-native-multi-slider": "^2.2.2",
"#react-native-community/async-storage": "~1.11.0",
"#react-native-community/masked-view": "0.1.10",
"#react-navigation/bottom-tabs": "^5.8.0",
"#react-navigation/drawer": "^5.9.0",
"#react-navigation/material-bottom-tabs": "^5.2.16",
"#react-navigation/native": "^5.7.3",
"#react-navigation/stack": "^5.9.0",
"axios": "^0.20.0",
"expo": "~38.0.9",
"expo-linear-gradient": "~8.2.1",
"expo-splash-screen": "^0.5.0",
"expo-status-bar": "^1.0.0",
"expo-updates": "~0.2.10",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "^0.63.2",
"react-native-animatable": "^1.3.3",
"react-native-deck-swiper": "^2.0.5",
"react-native-flags": "^1.0.0",
"react-native-gesture-handler": "~1.6.0",
"react-native-maps": "0.27.1",
"react-native-paper": "^4.1.0",
"react-native-reanimated": "~1.9.0",
"react-native-safe-area-context": "~3.0.7",
"react-native-screens": "~2.9.0",
"react-native-unimodules": "~0.10.1",
"react-native-vector-icons": "^7.1.0",
"react-native-web": "^0.13.12",
"use-state-with-callback": "^2.0.3"
},
"devDependencies": {
"#babel/core": "~7.9.0",
"babel-jest": "~25.2.6",
"jest": "~25.2.6",
"react-test-renderer": "~16.11.0"
},
"jest": {
"preset": "react-native"
},
"private": true
}

How to run react-native using application on Android (using CRNA)

I have this a simple app which was created using CRNA which runs fine on iOS but fails on Android.
It seems to be related to the missing JSC on Android OS. I added the "android-jsc" (https://github.com/facebook/android-jsc) dep to the project but nothing changed. What am I missing?
Here is my package.json
{
"name": "app",
"version": "0.1.0",
"private": true,
"devDependencies": {
"babel-plugin-module-resolver": "^2.7.1",
"eslint": "^4.10.0",
"eslint-plugin-react": "^7.4.0",
"jest-expo": "^28.0.0",
"jest-immutable-matchers": "^2.0.1",
"react-native-scripts": "1.14.0",
"react-test-renderer": "16.4.0"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "REACT_NATIVE_ENV=development react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "REACT_NATIVE_ENV=test node node_modules/jest/bin/jest.js --watch",
"test_ci": "REACT_NATIVE_ENV=test node node_modules/jest/bin/jest.js"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"jsc-android": "224109.x.x",
"expo": "^29.0.0",
"immutable": "^3.8.2",
"momentjs": "^2.0.0",
"prop-types": "^15.6.1",
"react": "16.3.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",
"react-native-elements": "1.0.0-beta5",
"react-native-keyboard-aware-scroll-view": "^0.4.1",
"react-native-modal-datetime-picker": "^6.0.0",
"react-native-side-menu": "^1.1.3",
"react-native-vector-icons": "^4.6.0",
"react-navigation": "2.0.4",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-immutablejs": "^0.0.8",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"sentry-expo": "^1.9.0",
"validate": "^4.4.1"
}
}
jsc-android needs manual linking, and isn't compatible with Expo. See if all your dependencies are compatible with Expo. If not, you'll either have to detach to ExpoKit, or look for a compatible substitute.
Edit: Upon inspection, you are installing react-native-vector-icons directly. It needs manual linking, but is included on Expo. Check here for the instructions.

Categories

Resources