vincenzoAiello / DArchive

3 stars 4 forks source link

Error when bundling on android #4

Closed alexanderbkl closed 2 years ago

alexanderbkl commented 2 years ago

I get these errors when trying to run Expo Go a`` bundle in an Android emulator or android device:

AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-async-storage/async-storage' instead of 'react-native'. See https://github.com/react-native-async-storage/async-storage
at node_modules\react-native\Libraries\LogBox\LogBox.js:118:10 in registerWarning
at node_modules\react-native\Libraries\LogBox\LogBox.js:64:8 in warnImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:37:4 in console.warn
at node_modules\expo\build\environment\react-native-logs.fx.js:18:4 in warn
at node_modules\react-native\Libraries\Utilities\warnOnce.js:27:2 in warnOnce
at node_modules\react-native\index.js:300:12 in module.exports.get__AsyncStorage
at node_modules\@firebase\webchannel-wrapper\dist\index.js:90:481 in <anonymous>
at node_modules\metro-runtime\src\polyfills\require.js:349:11 in loadModuleImplementation
at node_modules\@firebase\webchannel-wrapper\dist\index.js:85:378 in n.Ja
at node_modules\metro-runtime\src\polyfills\require.js:349:11 in loadModuleImplementation
at Home copy.js:41:0 in <global>
at node_modules\metro-runtime\src\polyfills\require.js:349:11 in loadModuleImplementation
at App.js:6:0 in <global>
at node_modules\metro-runtime\src\polyfills\require.js:349:11 in loadModuleImplementation
at node_modules\expo\AppEntry.js:3:0 in <global>
at node_modules\metro-runtime\src\polyfills\require.js:349:11 in loadModuleImplementation
at node_modules\metro-runtime\src\polyfills\require.js:201:44 in guardedLoadModule
at FileInfo.js:54:2 in FileInfo

ReferenceError: Can't find variable: TextDecoder
at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:172:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\@react-native\polyfills\error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules\metro-runtime\src\polyfills\require.js:204:6 in guardedLoadModule
at FileInfo.js:54:2 in FileInfo

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current 
project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:172:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\@react-native\polyfills\error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:367:8 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue

The main issue is the Reference Error TextDecoder, I gues it is related to the browser inside the Android webview and some polyfill dependencies.

alexanderbkl commented 2 years ago

Got over the problem by doing this; npm install text-encoding npm install big-integer

and pasting this code inside node_modules>react-native>Libraries>LogBox

const TextEncodingPolyfill = require('text-encoding');
const BigInt = require('big-integer')
Object.assign(global, {
  TextEncoder: TextEncodingPolyfill.TextEncoder,
  TextDecoder: TextEncodingPolyfill.TextDecoder,
  BigInt: BigInt,
});