Installing an existing React-native application is throwing error.
Logcat error:
E/unknown:ReactNative: Exception in native call from JS
com.facebook.react.devsupport.JSException: Unexpected token '<'
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:920)
Caused by: com.facebook.jni.CppException: Unexpected token '<'`
no stack
... 8 more
D/SoLoader: Loaded: libyoga.so
E/ReactNativeJNI: Attempting to call JS function on a bad application bundle: HMRClient.setup()
E/unknown:ReactNative: Exception in native call
java.lang.RuntimeException: Attempting to call JS function on a bad application bundle: HMRClient.setup()
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:920)
E/ReactNativeJNI: Attempting to call JS function on a bad application bundle: AppRegistry.runApplication()
E/unknown:ReactNative: Exception in native call
java.lang.RuntimeException: Attempting to call JS function on a bad application bundle: AppRegistry.runApplication()
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:920)
D/SoLoader: init exiting
Output of npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.4
CPU: (8) x64 Apple M1
Memory: 40.87 MB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.19.0 - /usr/local/bin/node
npm: 6.14.16 - /usr/local/bin/npm
Watchman: 2022.06.13.00 - /opt/homebrew/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
Android SDK:
API Levels: 29, 30, 31, 32
Build Tools: 29.0.2, 30.0.2, 30.0.3, 32.0.0, 32.1.0
System Images: android-30 | Intel x86 Atom_64, android-32 | Google APIs ARM 64 v8a
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8193401
Xcode: 13.0/13A233 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.1 => 0.61.1
Steps to reproduce
Create a React native app with version 0.61.1,
Install npm dependencies: npm i (tried npm i --legacy-peer-deps)
Run metro server: npx react-native start --reset-cache
Run android build: npx react-native run-android (I am using Android studio to run the app)
I have already been through following issue resolutions but nothing worked for me:
https://github.com/facebook/react-native/issues/21074
https://github.com/facebook/react-native/issues/32875
https://github.com/babel/babel/issues/14139
First clear your cache and node_module using the below command
cd android && ./gradlew cleanBuildCache && cd .. &&
watchman watch-del-all && rm -rf node_modules/ &&
rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf
$TMPDIR/metro-bundler-cache-* &&
yarn cache clean && yarn install &&
yarn start --reset-cache
After done this change you babel.config.js
module.exports = {
presets: [['module:metro-react-native-babel-preset', {
unstable_disableES6Transforms: true
}]],
};
Related
I have upgraded expo from 46 to 47 and enabled hermes on app.json
now I get this error message
Error: ENOENT: no such file or directory, open 'C:\Users\kudo\01_Work\Repos\expo\expo\android\versioned-react-native\ReactAndroid\hermes-engine\.cxx\MinSizeRel\2q85j1u4\arm64-v8a\lib\InternalBytecode\InternalBytecode.js'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at getCodeFrame (C:\xxx\node_modules\metro\src\Server.js:1028:18)
at Server._symbolicate (C:\xxx\node_modules\metro\src\Server.js:1101:22)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Server._processRequest (C:\xxx\node_modules\metro\src\Server.js:458:7) {
errno: -4058,
code: 'ENOENT',
path: 'C:\\Users\\kudo\\01_Work\\Repos\\expo\\expo\\android\\versioned-react-native\\ReactAndroid\\hermes-engine\\.cxx\\MinSizeRel\\2q85j1u4\\arm64-v8a\\lib\\InternalBytecode\\InternalBytecode.js'
}
This happend when I dispatch anything with RTK Query
Only happens on Android.
env info
expo-env-info 1.0.5 environment info:
System:
OS: Windows 10 10.0.19044
Binaries:
Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 2020.3.0.0 AI-203.7717.56.2031.7583922
npmPackages:
expo: ^47.0.0 => 47.0.8
react: 18.1.0 => 18.1.0
react-dom: 18.1.0 => 18.1.0
react-native: 0.70.5 => 0.70.5
react-native-web: ~0.18.7 => 0.18.8
Expo Workflow: managed
I'm new to react-native, this community is awesome.
but i'm having an issue with configuring https://github.com/terrylinla/react-native-sketch-canvas with npx create-react-native-app .
all I've done so far is edit the metro.config.js
const extraNodeModules = {
'#terrylinla/react-native-sketch-canvas': './node_modules/#terrylinla\react-native-sketch-canvas/'
}
const resolverMainFields = ['browser','main'];
module.exports = {
resolver: {
extraNodeModules,
resolverMainFields
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
then cmd react-native run-android it bundles correctly but it never loads onto the emulator:
this is what it says in shell:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:8712) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
Jetifier found 987 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
Configure project :terrylinla_react-native-sketch-canvas
WARNING: Configuration 'provided' is obsolete and has been replaced with 'compileOnly'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
<============-> 99% EXECUTING [10m 30s]
IDLE
IDLE
:app:installDebug
IDLE
So I just got metro to bundle my js files correctly. I discovered it was something to do with the react-native android gradle it's very confusing. But I just restarted my computer and ran the same commands. That fixed it.
these stackoverflow answers worked before for me to get my build working:
Stuck on info starting JS server
React-native run-android stuck at 99% appDebug
I hope this helps to anyone using create-react-native-app & metro-bundler
I have a starter app created with React Native CLI on a Mac, added Detox and am trying to run the sample tests. I get this error (newlines added for easier reading):
$ ./node_modules/.bin/detox -c android test
detox[37289] INFO: [test.js] configuration="android" reportSpecs=true readOnlyEmu=false
useCustomLogger=true forceAdbInstall=false DETOX_START_TIMESTAMP=1591313397594
node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:ios:).)*$' --
maxWorkers 1 android test
detox[37290] INFO: [DetoxServer.js] server listening on localhost:62332...
detox[37290] ERROR: [DetoxExportWrapper.js/DETOX_INIT_ERROR]
DetoxRuntimeError: Failed to run application on the device
HINT: Most likely, your tests have timed out and called detox.cleanup() while it was
waiting for "ready" message (over WebSocket) from the instrumentation process.
When it runs, the emulator starts but the app does not.
The app runs fine separate from E2E tests, through React Native CLI.
.detoxrc.json
{
"testRunner": "jest",
"runnerConfig": "e2e/config.json",
"configurations": {
"android": {
"type": "android.emulator",
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
"build": "cd android; ./gradlew assembleDebug assembleAndroidTest -DtestBiuldType=debug; cd -",
"device": {
"avdName": "Pixel_3"
}
}
}
}
Environment:
Detox: 16.7.0
React Native: 0.62.2
Node: v12.17.0
Device: Pixel 3, x86, API 29, Android 10
OS: MacOS 10.15.4
Test-runner: Jest
Android Studio: 3.6.3
My bad. I missed a few steps on the second page of getting started instructions specific to Android.
https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md
Im getting this while trying to load the app from an Android device (1+ 5t)
error: bundling failed: Invariant Violation: invalid asset resolution
at invariant (~/project/node_modules/metro/node_modules/fbjs/lib/invariant.js:40:15)
at ModuleResolver._getFileResolvedModule (~/project/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:175:9)
at ModuleResolver.resolveDependency (~/project/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:116:19)
at ResolutionRequest.resolveDependency (~/project/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:49:18)
at DependencyGraph.resolveDependency (~/project/node_modules/metro/src/node-haste/DependencyGraph.js:218:16)
at Object.resolve (~/project/node_modules/metro/src/lib/transformHelpers.js:141:30)
at dependencies.map.result (~/project/node_modules/metro/src/DeltaBundler/traverseDependencies.js:373:31)
at Array.map (<anonymous>)
at resolveDependencies (~/project/node_modules/metro/src/DeltaBundler/traverseDependencies.js:369:18)
at ~/project/node_modules/metro/src/DeltaBundler/traverseDependencies.js:188:33
BUNDLE [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.
Tried:
- react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
- react-native start --reset-cache
- rm -rf node_module & yarn install
and this - didnt work
Any help would be appreciated
fix: remove '.ios.' out of an image name
since my app currently works on ios-only, i had some leftovers in some images names such as 'welcome#2.ios.png' - so when running on android, react native couldn't find any resources
when you use React Native Platform Api (https://reactnative.dev/docs/platform),
if you have 2 files in your assets folder to display different UI, one for Android and one for Ios, when you call your image you must remove the type of the Os inside the name of your file.
I mean, buttonIcon.android.png || buttonIcon.ios.png => buttonIcon.png
React Native Platform api will do the switch.
ex :
var displayShareButton = () => {
if(data != undefined && Platform.OS === "android") {
return(
<TouchableOpacity
style={styles.shareButton}
onPress={() => shareSomething()}
>
<Image
style={styles.shareImage}
source={require("../assets/buttonIcon.png")}/>
)
}
}
Hope it will fix the troubleshoot :)
I have created a project following these steps:
npm install -g gatsby
gatsby new dev-blog
cd dev-blog
npm install
Then I try to start by project by
gatsby develop --host localhost --port 9000
At this point it throws an exception:
Failed to require /Users/antkong/wd/blogs/gatsby/dev-blog/html.js
./html.js
Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/antkong/wd"
How can I fix this problem?
Edit
OS: OSX 10.12.4
Darwin mymac.local 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
npm: 3.10.10
node: 6.10.2
Full stacktrace:
❯❯ npm run develop
> gatsby-starter-default#1.0.0 develop /Users/antkong/wd/blogs/gatsby/dev-blog
> gatsby develop
Failed to require /Users/antkong/wd/blogs/gatsby/dev-blog/html.js
./html.js
Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/antkong/wd"
at /Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
at Array.map (native)
at OptionManager.resolvePresets (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
at OptionManager.mergePresets (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transpile (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-loader/lib/index.js:46:20)
at /Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-loader/lib/fs-cache.js:79:18
at ReadFileContext.callback (/Users/antkong/wd/blogs/gatsby/dev-blog/node_modules/babel-loader/lib/fs-cache.js:15:14)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:366:13)
# (webpack)-require/lib/webpackRequireEntrypoint.js 1:20-41
I am also using nvm
❯❯ nvm list
-> v6.10.2
system
default -> v6 (-> v6.10.2)
node -> stable (-> v6.10.2) (default)
stable -> 6.10 (-> v6.10.2) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> v6.10.2)
lts/argon -> v4.8.2 (-> N/A)
lts/boron -> v6.10.2
gabsty new does not create a .babelrc that is needed by babel. The error is caused by the missing .babelrc.
Here is the content of my .babelrc:
{
"presets": ["react", "es2015", "stage-0"],
"env": {
"development": {
"presets": ["react-hmre"]
}
}
}