I'm trying my app on Android Device and when I start the app the dubbuger give me 1 Error and 1 Warning.
The Error is:
Async Storage 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-community/async-storage' instead of 'react-native'. See https://github.com/react-native-community/react-native-async-storage
and the Warning:
Require cycle:
node_modules/pouchdb-find/node_modules/pouchdb-utils/lib/index-browser.js
-> node_modules/pouchdb-find/node_modules/pouchdb-utils/lib/index-browser.js
Require cycles are allowed, but can result in uninitialized values.
Consider refactoring to remove the need for a cycle.
About the Error, I have follow what it said, I have done:
npm i --save #react-native-community/async-storage;
on my root project folder. And then
react-native link #react-native-community/async-storage
And At the last I have imported this: import AsyncStorage from '#react-native-community/async-storage'; on my project.
But I have always the same error.
How can I solve in your opinion this error and this warning?
Thank you!
The first step its correct and you're installing and linking the project
dependencies into your project.
# Install
$ yarn add #react-native-community/async-storage
# Link
$ react-native link #react-native-community/async-storage
The second step seems correct too.
import AsyncStorage from '#react-native-community/async-storage';
Note: Sometimes the error message comes from how you are storing the data
Can you write this part for me, I'll check the issue ?
For remove yellow warning you can:
To disable the yellow box place console.disableYellowBox = true;
anywhere in your application. Typically in the root file so it will apply to both iOS and Android.
console.ignoredYellowBox = ['Warning: Each', 'Warning: Failed'];
Can you try this ?
import {YellowBox} from 'react-native';
YellowBox.ignoreWarnings(['Warning: Each', 'Warning: Failed']);
AsyncStorage used to be a part of the react-native library, but it is now deprecated. The module was removed from the standard library and is now a part of a separate library called #react-native-community/async-storage.
You did not mention if you are using Expo and you did not mention what version of React Native you are using, but in any case, this is the documentation for it:
https://github.com/react-native-community/async-storage
If you are using RN 60+ you need to undo that link, as RN 60+ now uses autolinking. So you would run: react-native unlink #react-native-community/async-storage per the above documentation.
If you are using react-native-cli and not Expo, you probably also need to do a pod deintegrate and pod install to add
- "RNCAsyncStorage (from `../node_modules/#react-native-community/async-storage`)"
to your Podfile.lock file.
first thing: these messages are warnings and they are safe to ignore in this case
console.disableYellowBox = true;
is your friend.
second: you probably are doing things correctly, but you are not the only one who uses AsyncStorages. Probably some packages inside node_modules are using AsyngStorage too, and they are your source of warning. The only solution to this to get updated packages and/or edit them yourself and remove incorrect imports.
Related
I've upgraded react-native to latest version (0.68) through react-native CLI, and now every time I'm trying to build for android I get this error:
error: cannot find symbol reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
I tried to clean the bundle, made sure my package name is correct (like others issues suggested) and nothing so far..
If you're using the latest version of React Native (i.e: v >= 68), you've to rebuild your projects. it works for me.
Going through react-native migrations file, I've found out that somehow I missed a few migrations related to react-native new architecture (although I would expect it to be automatic when using react-native CLI upgrade command).
I suggest to follow the migrations changes especially on MainActivity.java and MainApplication.java - don't forget to change the "from" and "to" versions to your case:
https://react-native-community.github.io/upgrade-helper/?from=0.65.1&to=0.68.1
For the past 1.5 days or so, I tried to get react-native-track-player working and I just can't make it happen. No matter what I try I always end up running into the same error block:
ERROR TypeError: null is not an object (evaluating 'TrackPlayer.RATING_HEART')
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
I set it up both with react-native expo and 'normal' react-native (according to react-native docu) both with JS and TS. And for all variants of that I tried:
Deleting/reinstalling node-modules
npm cache verify (as described here),react-native start --reset-cache (from here) and some other cache reset/deletion things.
I've copied the example from their GitHub repo.
I updated and/or reinstalled pretty much every library (incl. node)
All of those efforts ended in the exact same error.
So ye, I literally don't know what to do anymore. I'm a beginner at both react-native and app dev in general. So to be honest, it's very likely the mistake I'm making is super stupid/simple. But I just can't find it. I would be more than grateful for any advise.
EDIT - Dependency error:
EDIT 2: Solution - react-native removed jcenter between v0.64 v0.65 which was root of all my problems, check my answer below for details.
EDIT: jcenter() will be removed for sure. Check this GitHub thread for more infos on how to procede with react-native-track-player.
Ok, while cloning the example from their repo worked (thanks #AngwarGul) I still wanted to figure out why that was. So it turns out, that the fundamental reason for the error was in the build.gradle file.
I've been using react-native#0.65.1 and wasn't aware that from v0.64 to v0.65 jcenter was removed from react-native. So, when running react-native run-android the app couldn't be built since it couldn't find jcenter. So ye, I probably could have realized that earlier, but I was looking anywhere but there.
TL;DR: Adding jcenter() to the build.gradle file solved the whole issue for me (see pic below). So, in case anyone else does the same stupid mistake, here's your solution ;)
Unfortunately by Looking the Documentation of react-native-track-player , This package doesn't support expo Expo and Expokit support
How I manage to run the Example Project from Package
Steps:
Cloned react-native-track-player
Separate out the example project from package
Remove postinstall from package.json's scripts
add package in dependencies "react-native-track-player": "^2.0.1",
yarn install or npm install
yarn android or npm run android
Result
I'm asking again because my case wasn't solved on previous answers.
I created a React Native App that works perfectly on Snack, but then I wanted to try it on Expo(I want to add some modules that Snack can't load).
So, I used create-react-native-app to make my project.
Then, after editing the code, I tried to launch it using the Genymotion emulator, but everytime I do it, the below error occurs :
I can't understand what's wrong with it?
I already tried removing node_modules folder, changing React Native and Babel version and reinstalling the project with npm install.
Also, in console, it shows me this error:
22:33:56: Unable to resolve ./components/AssetExample" from "./C:\\Users\\danie\\HC\\App.js`: The module `./components/AssetExample` could not be found"
22:33:56: Failed building JavaScript bundle
but I don't know where should this module be imported? package.json or package-lock.json?
I launch it in Genymotion using the following:
cd HC
npm start android
What can I do? Please help me.
React Native version: 0.55.2
Babel(preset React Native) version: ^4.0.0
Edit: Project Structure & code as requested, I created the repository on GitHub: https://github.com/DanielVip3/HC
^ I didn't push the node_modules folder because it was too large, but I think you already know: it contains all the modules that React Native uses.
The application is looking for ./components/AssetExample in your own application folder.
Please give us your project structure and the code in App.js file (also make sure you export AssetExample class in AssetExample.js file.
What i understand you are trying to do is (probably) that in App.js you import AssetExample from "./components/AssetExample", so possible errors are:
1) path is wrong
2) you don't export default AssetExample in AssetExample.js
I don't know why react-native link is creating duplicated entries in MainApplication.java (at imports and in getPackages function) and in app\build.gradle the compile project entry is not being added, but if I run again the command, I receive the same message instead of that the module is already linked.
When I run react-native link, I receive the messages that the module has been linked successfully on Android (duplicated) and in iOS it was already linked.
Many users are encountering the issue on Android (me included). It is due to difference between iOs and Android code-signin.
There is an opened (and recent) PR for this on the react-native project https://github.com/facebook/react-native/pull/18131 - hopefully it will be merged soon!
Faced a similar issue when I tried to link a library to my code. On running the react-native link command, it displayed that the library has been linked successfully though the entries were never created. What I did was to manually modify these 3 files:
android/settings.gradle: Add the module using include() and specify the path of your project directory.
include ':your_package_name'
project(':your_package_name').projectDir = new File(rootProject.projectDir,'../node_modules/your_package_name')
android/app/build.gradle: Add the compile statement
compile project(':your_package_name')
android/app/src/main/java/[..project_name..]/MainApplication.java: Import the package and make sure that the getPackages() is returning your package along with the previous ones.
Would have answered you better if you specified the name of the required library
In my case, It was related with RN version and local libraries.
I solved it by removing the duplicated libraries on Xcode.
Here is link
Hope it give you some help.
I am using phonegap-2.9.0 with file plugin. When I build project for android platform it creates two packages within the src/ folder:
org.apache.cordova.file
org.apache.cordova.filetransfer
I get below errors within these two packages:
1 - org.apache.cordova.file.FileUtils
Method testSaveLocationExists() from the type DirectoryManager is not visible
Method getFreeDiskSpace() from the type DirectoryManager is not visible
Method testFileExists() from the type DirectoryManager is not visible
2 - org.apache.cordova.filetransfer.FileTransfer
import org.apache.cordova.CordovaResourceApi unresolved
import org.apache.cordova.CordovaResourceApi.OpenForReadResult unresolved
Could someone please tell me what I should do to resolve these?
Thanks.
You have two problems.
1) Version of Phonegap is outdated
2) The way to install a plugin is:
-> phonegap plugin add "urlofplugin" or "/path""
-> phonegap platform add android
-> phonegap prepare
-> phonegap build
sometimes the plugin has a different default installation, the files need to change the platform.
Well, I dont know if I can help you, but I had similar problems. When I installed exactly those two plugins I got an error too. A different one, which I dont perticularly remember, something to do with a missing file that I can easily find in the file manager. Anyway, what helped me was:
I updated to a more recent version, if you are able to I advice for it.
After installing the plugins through cordova cmd api (.nodejs command prompt ... you know what I mean) I was forgetting to build in the api itself. It sounds stupid but I was using wp8 and thus using a template for visual studio. The studio gave me the error, the building process (in cmd) also gave errors, but it was fixed by updating to the newer version.
You need to configure you build path and then add library from external source and select the library then it will resolve or u can make copy and paste cordova library .jar file in your lib folder. then it will remove, if not happen then tell me .......
I am not sure if that will work but first uninstall these plugins using phonegap/cordova CLI and than reinstall it in the root of application folder using the CLI only like this:
phonegap local plugin add <required plugin>
This worked for me after reinstallation.