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
Related
Hello I am new to flutter and i want to do native function calls using flutter, i wrote an sample native code app and it is working as expected. Now i want to use some packages on my android code, which is platform specific.
I have added my dependcies in my build.gradle file and it the gradle build is success,
But i cannot use the package there,
say for example: i have added the dependency for the com.squareup.okhttp3:okhttp:3.4.2 and gradle build is success and now icannot access their methods and other stuffs. Please let me know to what to do with it. Thanks in advance.enter image description here
Finally it worked, i opened the android project as an new android project in android studio which resolved the issue.
I have an outdated 32-bit application to react native, now I want to update that application with the latest versions, my question is, I have to work on that application or I can create a new one with the same package name and the same keystore, in such a way that it helps me to update the previous one, I hope you have explained, thanks in advance.
I recently had to upgrade a react native app from 0.49 to the latest, 0.61. There's some tools available, react-native upgrade and react-native-git-upgrade, but I had little luck with either one.
For me the easiest way was performing the update on the current codebase, with the help of RN diff purge: react-native-community/rn-diff-purge
From their README.md :
This repository exposes an untouched React Native app generated with the CLI npx >react-native init RnDiffApp. Each new React Native release causes a new project to >be created, removing the old one, and getting a diff between them. This way, the >diff is always clean, always in sync with the changes of the init template.
For whichever version you're currently at, you can look up the diff of a clean project in that version to whichever other version you'd like to upgrade to. You can check all the changes that happened between those two versions, and apply them to you own project. When I upgraded, I just applied the changes in rn-diff-purge/compare/release0.49.1..release/0.61.5 to my project.
Some things to conider:
If you only need to upgrade react native to be able to get 64 bit builds, it's going to be way less work to update to 0.59 (first version to support 64bit), than to upgrade to 0.60 or later. On version 0.60 they introduced auto-linking, meaning that you no longer need to run react-native link after installing a native dependency, but you'll need to unlink all of your current native dependencies if you don't want to see some "duplicate dependency" errors.
If you do decide to upgrade to 0.60 or later, and you have some dependency that you don't want to unlink (maybe you've added react-native-code-push, and you set the deploymentKey when you initialize the package in your MainApplication.java), you need to add them to the file react-native.config.js (if you don't have one, you should create one at the root of your project). The file should look like this:
module.exports = {
dependencies: {
'react-native-code-push': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
},
},
},
};
That's all, good luck!
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.
I've created a project using Cordova CLI, version 3.5.0.
I've successfully deployed the project for Android platform by using the CLI.
cordova run android
However, I'm having problem to deploy the project for iOS.
cordova run ios
I encountered this error:
mv: dest file already exists: /Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS/MyPKS-Info.plist
mv: dest file already exists: /Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS/MyPKS-Prefix.pch
shell.js: internal error
Error: EINVAL, invalid argument '/Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS.xcodeproj'
at Object.fs.renameSync (fs.js:543:18)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:495:8
at Array.forEach (native)
at Object._mv (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:471:11)
at Object.mv (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:1491:23)
at pbxProject. (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ios_parser.js:126:27)
at pbxProject.EventEmitter.emit (events.js:98:17)
at pbxProject. (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/xcode/lib/pbxProject.js:30:18)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at handleMessage (child_process.js:322:10)
This problem only occur after I access the Xcode project manually to add the Icon & splash screen since the icon & splash screens are not automatically added to the project even though declared in config.xml.
I've tried to remove the Info.plist & Prefix.pch file, but then this error appeared.
Error: ENOENT, no such file or directory '/Users/amirfazwan/Documents/workspace/MyPKS/platforms/ios/MYPKS/MYPKS-Info.plist'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.readFileSync (fs.js:284:15)
at Object.exports.parseFileSync (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/plist-with-patches/lib/plist.js:18:19)
at Object.module.exports.update_from_config (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ios_parser.js:66:31)
at Object.module.exports.update_project (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ios_parser.js:189:21)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:113:31
at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
The project works just fine if launched from Xcode, but I no longer can build the project from CLI or launch the "serve" command from CLI for debugging purpose.
Please guide me, thanks.
SOLVED
Solved by renaming the project name using Xcode. Thanks Jason for the tips.
Just remove the platforms and then add them again.
cordova platform rm ios
cordova platform rm android
cordova platform add ios
cordova platform add android
EDIT: Try this other solution first! It works for most issues: https://stackoverflow.com/a/28300528/1250444
I struggled with this as well. Finally found a solution by trial and error. D:
What happened for me was renaming the project name to have capitals. This caused all sorts of confusion for Cordova.
The first thing I did was rename the problematic plist and pch files to match the correct capitalization. So, in your case, if it was myPKS, but now is MyPKS, you'd need to rename the files to be MyPKS-Info.plist and MyPKS-Prefix.pch.
I then had to rename the .xcodproj to match capitalization.
After that, another issue happened:
xcodebuild: error: The project 'NewName.xcodeproj' does not contain a target named 'NewName'.
To solve this, I had to rename the target to have the proper capitalization as well. Since I'm new to iOS dev, I have not idea how to describe how to get there. I just finally stumbled upon it, made the change, and it worked!
Best of luck!
What solved my problem was by doing the following
Removing the ios platform; ionic platform remove ios
Removing the android platform; ionic platform remove android
Adding the Ios platform back; ionic platform add ios
Adding the android platform back; ionic platform add android
Rebuild; ionic build
Hope this helps anyone else.
Jason Cox's answer helped me - but I did not rename any files, I just had to change the name of the app in my config.xml
<name>myApp</name>
to
<name>MyApp</name>
This worked in Meteor 1.3.x
Remove a particular platform and re-add again via meteor command via console.
For ex.
meteor list-platforms
meteor remove-platform ios
meteor add-platform ios
I got this same error. The reason why this happen to me was because i changed the name in the xml from myapp to MyApp. It worked again once i changed it back to the old name.
Renaming in xcode also worked so thanks for that.
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.