android build fails with error - null is not an object - javascript

I have a private gitlab repo (react native module) and i added this repo to my App's package.json.
index file in my private gitlab repo:
ios methods:
android methods:
Now in my App, i install the above module and i call the methods.
App's package.json
App.js
In ios, everything works perfectly fine.
Both "multiply" (HealthLibrary.multiply()] and "requestAuthorization" [HealthLibrary.requestAuthorization()] work fine.
But when i run "react-native run-android", the build is successful but the display is a blank screen with this error in the log
TypeError: null is not an object (evaluating 'nativeModule.requestAuthorization')
Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
Why does this error pop up only when i run android??i am not even calling "requestAuthorization" method yet i am unable to build the app in Android.
Any help would be great guys....

In the images you have provided, there seems to be no requestAuthorization method in your android file, only a method called 'getAuthorization'.

Related

Expo app thowing file missing error though files are actually present there

I am using pnpm to create expo app. Just created pnpm create expo-app, installed dependencies and then run yarn android === expo start --android.
Tried shamefully-hoisting as well as moving project to location with no spaces in path but each time I get the same error.
I manually checked, all the files that are shown missing in error are actually present there.
How do I fix this?
Error: Unable to resolve module ./node_modules\expo\AppEntry from C:\Users\HariC\AndroidStudioProjects\chat/.:
None of these files exist:
* node_modules\expo\AppEntry(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
* node_modules\expo\AppEntry\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
at ModuleResolver.resolveDependency (C:\Users\HariC\AndroidStudioProjects\chat\node_modules\.pnpm\metro#0.72.3\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:152:15)
at DependencyGraph.resolveDependency (C:\Users\HariC\AndroidStudioProjects\chat\node_modules\.pnpm\metro#0.72.3\node_modules\metro\src\node-haste\DependencyGraph.js:264:43)
at C:\Users\HariC\AndroidStudioProjects\chat\node_modules\.pnpm\metro#0.72.3\node_modules\metro\src\lib\transformHelpers.js:170:21
at Server._resolveRelativePath (C:\Users\HariC\AndroidStudioProjects\chat\node_modules\.pnpm\metro#0.72.3\node_modules\metro\src\Server.js:1196:12)
at async Server.requestProcessor [as _processBundleRequest] (C:\Users\HariC\AndroidStudioProjects\chat\node_modules\.pnpm\metro#0.72.3\node_modules\metro\src\Server.js:484:37)
at async Server._processRequest (C:\Users\HariC\AndroidStudioProjects\chat\node_modules\.pnpm\metro#0.72.3\node_modules\metro\src\Server.js:435:9)
Since android didn't work. I tried running web and I was prompted to install #expo/webpack-config. I installed it using expo install #expo/webpack-config#^0.17.2 and wow… It worked!

how to implement reload app in react native expo (production)

I tried to create restart with react-native-restart, but I get an error when calling RNRestart.Restart():
[Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNativeRestart.default.Restart')]
How do I implement reload in production ?
p.s. I use expo
you can use expo-updates just run expo install expo-updates and restart the app with the method reloadAsync
import * as Updates from 'expo-updates';
Updates.reloadAsync()

Undefined error in build version with electron

I have an electron app, the app is working when I am running:
npm run electron-dev
I am creating a build folder using react-scripts:
yarn react-scripts build
Than I am trying to build it using electron builder with the command:
yarn electron-builder -c.extraMetadata.main=build/electron.js
This is working well and I am getting a dist and a build folders with the compiled app and a build.
But when I am clicking the app I am getting:
A JavaScript error occurred in the main process
Uncaught Exception:
undefined: undefined
Compilation success messages
When running the app via electron-dev (on the build folder or on the public folder) I am getting no errors, but I am getting 3 warning messages, 2 from firebase - "When deploying Firebase apps to production, it is advisable to only import the individual SDK components you intend to use.", "Warning: This is a browser-targeted Firebase bundle but it appears it is being run in a Node environment." and 1 about security "Electron Security Warning (Insecure Content-Security-Policy) This renderer process has either no Content Security Policy set or a policy with "unsafe-eval" enabled.".
TD;DR: How can I understand where the error is coming from and why, if the error shows only undefined: undefined?
Maybe through try and catch but than how can I display it on the error I am getting?
I'm working on Mac OSX (But it does not looks like this is the problem), I am using opencv4nodejs which takes a long time to compile, also I am using some json files to store app data using electron-json-storage.

Error when migrating to macOS: TypeError: Cannot read property 'apply' of undefined

I am building a web app using React and Redux on the front end and Node on the back end with Express and MongoDB.
My app runs fine on my Windows machine. Today, I cloned the repository onto my macOS device and ran npm install inside the client and the root directory and then I tried running the application to find this error message pop up:
I'm not sure what this error message means and stack trace displays that the error originates from Redux inside the node_modules folder, which is code I did not write or touch. Here is the repo: https://github.com/furtivepygmy/devconnector
I'm new here, so please go easy on me. I always face issues when moving my workspace between macOS and Windows, however I can't seem to fix this one. Is there something I need to do when migrating between operating systems?

Service Worker not working with create-react-app

I'm using create-react-app for generating a react.js project. It automatically implements a service-worker for progressive web app funtionality if a production build was made by using the command npm run build.
Two weeks ago everything worked fine and I was able to cache all files with the generated service-worker. But since today I always get errors:
On Chrome: Uncaught (in promise) Error: Request for http://localhost:5000/index.html?_sw-precache=aee80fca0f83208cc4d82ae2ccfda3c1 returned a response with status 301 at service-worker.js:1.
On Firefox: Service worker event waitUntil() was passed a promise that rejected with 'TypeError: NetworkError when attempting to fetch resource.'.
I have absolutely not idea why the error occurs.
Even if I create a new app and don't touch any of the generated files, the error shows up in the browsers console.
Steps to reproduce:
npx create-react-app my-app
cd my-app
npm run build
serve -s build
open app in browser
I tested it on two separate machines but get the same result. Any help is very appreciated.
Edit:
Console output after running npm run build:
C:PATH-TO-PROJECT>npm run build
> frontend#0.1.0 build C:\xampp\htdocs\gitlab\BA\App-PWA-progetraenke.app\frontend
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
164.04 KB build\static\js\main.d2519277.js
781 B build\static\css\main.77261875.css
The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:
"homepage" : "http://myname.github.io/myapp",
The build folder is ready to be deployed.
You may serve it with a static server:
serve -s build
Find out more about deployment here:
https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment
I had the same issue with a VueJS app I created by using the PWA template of Vue. What did the trick for me was updating to the latest version of vue-cli and serve.
Updating to the latest serve version (8.1.4) probably solved my problem.

Categories