Unexpected token no stack - android emulator expo - android

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.

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": {}
}
}

Error is saying You may need an additional loader to handle the result of these loaders

I meet with the following error on my terminal whenever I try to use native-base in react-native
./node_modules/react-native-reanimated/lib/index.web.js 5:9
Module parse failed: Unexpected token (5:9)
File was processed with these loaders:
../../../AppData/Roaming/npm/node_modules/expo-cli/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| export * from "./reanimated1";
| export * from "./reanimated2";
export * as default from "./Animated";
=>Here is my babe.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
'react-native-reanimated/plugin',
"nativewind/babel",
],
};
};
=>Here is my package.json
{
"name": "equb",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start --android",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"#react-navigation/drawer": "^6.5.4",
"#react-navigation/native": "^6.1.1",
"expo": "~47.0.8",
"expo-linear-gradient": "~12.0.1",
"expo-status-bar": "~1.4.2",
"native-base": "^3.4.25",
"nativewind": "^2.0.11",
"react": "18.1.0",
"react-dom": "^18.2.0",
"react-native": "0.70.5",
"react-native-gesture-handler": "^2.8.0",
"react-native-reanimated": "^2.13.0",
"react-native-safe-area-context": "^3.3.2",
"react-native-svg": "^12.1.1",
"react-native-vector-icons": "^9.2.0",
"react-native-web": "^0.17.1",
"tailwindcss": "^3.2.4"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
I've installed native-base and enclose all my project in as follows
export default function App() {
return (
<NativeBaseProvider>
<NavigationContainer>
<RootStack />
</NavigationContainer>
</NativeBaseProvider>
);
}
But error is still occuring

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

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'],
},
},
};
};

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
}

Built Expo app crashes on start up: Didn't find class "host.exp.exponent.taskManager.ExpoHeadlessAppLoader"

When I'm trying to run my app built with React Native through Expo it crashes on the splash screen. It runs just fine if I boot it through the expo app on a real device or through an emulator. Logcat gives me the error:
W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "host.exp.exponent.taskManager.ExpoHeadlessAppLoader"
I can't find any info on this error message, but I've seem to read that these types of issues are related to something with the package.json file. This is how mine looks like:
{
"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": "~38.0.8",
"expo-constants": "~9.1.1",
"expo-location": "~8.2.1",
"expo-status-bar": "^1.0.2",
"geolib": "^3.3.1",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-dialog-input": "^1.0.8",
"react-native-maps": "0.27.1",
"react-native-svg": "12.1.0",
"react-native-web": "~0.11.7",
"react-native-svg-transformer": "^0.14.3",
"#react-native-community/slider": "^3.0.3"
},
"devDependencies": {
"#babel/core": "^7.8.6",
"babel-preset-expo": "~8.1.0"
},
"expo": {
"android": {
"package": "com.atlemlund.naturetracker",
"config": {
"googleMaps": {
"apiKey": "MY API KEY"
}
}
}
},
"private": true
}
Solved! Turns out that the error message had nothing to do with the crash. I had misplaced the API key. Moving it from package.json to app.json solved my issue.

Categories

Resources