I am using this component https://github.com/wix/react-native-calendars. It Works good in iphone but having issue with android. When i open calendar page it gives me an error as
Incompatible receiver, Map required!
Environment
List of Packages Installed
"react-native": "^0.52.0",
"react-native-calendars": "^1.20.0"
Seems like there is an issue with core-js.I have also tried everything from this reference link https://github.com/zloirock/core-js/issues/368
Do anybody know, How to resolve this issue.
Thanks in advance!
Reverting back to v2.5.2 of core-js fixed it. We use core-js via babel-preset-env, in order to get it fixed the solution is to set the version hard in the resolutions property of the package.json file:
"resolutions": {
"core-js": "2.5.2"
}
the resolutions section of the package.json file is a yarn feature!
Related
Is #react-native-firebase/admob deprecated? or just.. Why it doesn't work?
I am using #react-native-firebase/admob (https://rnfb-docs.netlify.app/admob/usage).
Everything works fine before to use "admob()". When I add admob() to the code appears this error:
"TypeError: (0, _admob.default) is not a function"
Do someone know why?
My code below (basic usage):
import React from 'react';
import { Text, View} from 'react-native';
import admob, { MaxAdContentRating } from '#react-native-firebase/admob';
import { InterstitialAd, RewardedAd, BannerAd, TestIds } from '#react-native-
firebase/admob';
import { BannerAdSize} from '#react-native-firebase/admob';
class App extends React.Component{
componentDidMount(){
// this was taked of official page: https://rnfb-docs.netlify.app/admob/usage#installation
admob()
.setRequestConfiguration({
// Update all future requests suitable for parental guidance
maxAdContentRating: MaxAdContentRating.PG,
// Indicates that you want your content treated as child-directed for purposes of COPPA.
tagForChildDirectedTreatment: true,
// Indicates that you want the ad request to be handled in a
// manner suitable for users under the age of consent.
tagForUnderAgeOfConsent: true,
})
.then(() => {
// Request config successfully set!
});
}
render(){
return(
<View style={{
alignItems:"center",
justifyContent:"center",
height:"100%"}}>
<Text style={{color:"black"}}>
Hola
</Text>
<BannerAd
unitId={TestIds.BANNER}
size={BannerAdSize.FULL_BANNER} />
</View>
)
}
}
export default App;
Despite #CodeJoe Answer, I still got confused by different Documentations for the React Native Firebase that where around, hence I spend lots of time and energy to get around it.
I open an issue here where is confirmed that Google removed the AdMob Package since v11.5.0.
AdMob is no longer in Firebase APIs, so this module no longer wraps it, there is no documentation to correct.
However it did exist as recently as v11.5.0 here and if you browse the repository at that point, you may consider the e2e tests for AdMob at the time a primer on "How To Use AdMob" https://github.com/invertase/react-native-firebase/tree/0217bff5cbbf233d7915efb4dbbdfe00e82dff23/packages/admob/e2e
Please, don't be like me and check the correct Documentation and website:
Correct
https://rnfirebase.io
Wrong Wrong Wrong, this refers to an older verison
https://rnfb-docs.netlify.app
The internet has a long memory, so there are stale copies of the docs out and about yes, but rnfirebase.io is always the official and current doc site
Admob was removed completely from the firebase ecosystem by Google so it does not exist here no. There are some community packages for it, our v11.5 version that has it, and we hope to peel our implementation out and update it for the community but it takes time and we are unfortunately still backlogged on official firebase apis, so it has not happened yet
So for AdMob solution I would use another Library, and use react-native-firebase for the Solutions that they currently provide
Alternative Library (August 2021)
DISCLAIMER
React Native Firebase is a great library still for the other packages they provide (Firebase, Analitycs...) and the Admob version 11.5 is still a solution. These are just suggestion for alternatives for Admob.
react-native-admob-alpha Simple and fresh library, recently updated.
react-native-admob-native-ads Another brand new library, they implement Admob Native Advanced Ads.
Expo AdMob (Available also for bare React-Native Projects)
To complete your searching I'll add that Admob is removed from React Native Firebase and there is no plan to implement it again. Only re-host code on an external repository.
Last supported version is 11.5.0
It means if you would like to use RN Firebase Admob before re-host you need to use all other services (like RNF analytics) with this version.
For more info please check https://github.com/invertase/react-native-firebase/issues/5329#issuecomment-843272057
Remember to use
dependencies{
"#react-native-firebase/admob": "11.5.0",
"#react-native-firebase/app": "11.5.0",
}
instead of
dependencies{
"#react-native-firebase/admob": "^11.5.0",
"#react-native-firebase/app": "^11.5.0",
}```
I could solve it.
SOLVED
Just check in the file "package.json" that packages of firebase has the same version, example:
dependencies{
"#react-native-firebase/admob": "^11.5.0",
"#react-native-firebase/app": "^11.5.0"
}
TIP
Works to similars errors.
I am able to use 11.5.0 downgrade trick in react native 0.65.1 for my RewardedAds. I edited the package.json file as said. It didn't work but I managed to run it in a different way:
Close any running react-native related terminals. Uninstall #react-native-firebase/app.
npm uninstall #react-native-firebase/app
Install the #react-native-firebase/app version 11.5.0 directly with this command.
npm install #react-native-firebase/app#11.5.0
After the installation, go to package.json>dependencies and do both packages versions the same(11.5.0) and remove ^.
"#react-native-firebase/admob": "11.5.0",
"#react-native-firebase/app": "11.5.0",
Start the react-native with fresh cache then run-android.
npx react-native start --reset-cache
npx react-native run-android
We use Angular in a nx monorepo in which we have been using Capacitor 2.4 for half a year now. We only use the android platform as of now. Now, we need to upgrade to Capacitor 3.0. The app itself is running again, however, as soon as I use any Plugin I always get the following exception: ERROR Error: "Device" plugin is not implemented on android
This is the same for every Plugin I have tried to use. So, if I would use the Storage Plugin I would get the same exception only for "Storage". I have followed the Capacitor migration guide (https://capacitorjs.com/docs/v3/updating/3-0) in detail, but I can't figure out where I went wrong. In general, the app works now, as long as I have any code that uses a Capacitor Plugin commented out. The code using the Plugins did work before the upgrade.
As according to the migration guide, I added import '#capacitor/core'; at the main.ts file, although I also tried putting it in the app.module.ts but had no success there either. I have installed every plugin for the whole app (the root) and for the nx-capacitor app (the capacitor app added with #nxtend-capacitor) as suggested here https://nxtend.dev/docs/capacitor/getting-started/. I also have updated the capacitor cli, the capacitor core and the capacitor android version for both package.json files.
Furthermore, according to the android upgrading guide, I have also updated gradle and the android gradle plugin. I have also updated the Android variables accordingly.
I honestly do not have too much experience or in-depth knowledge of Capacitor and I am aware that Capacitor 3 is still in Beta as of this point. However, maybe someone has already stumbled upon this problem and found a solution. I am also not sure, if this problem could somehow be caused by using this monorepo approach with nx. Has someone had experience in upgrading Capacitor to 3.0 while using a Nx monorepo?
For reference, this is the current package.json for the capacitor app:
{
"name": "app-cap",
"dependencies": {
"#capacitor-community/electron": "^1.3.2",
"#capacitor/android": "^3.0.0-rc.0",
"#capacitor/app": "^0.3.6",
"#capacitor/camera": "^0.4.3",
"#capacitor/cli": "^3.0.0-rc.0",
"#capacitor/core": "^3.0.0-rc.0",
"#capacitor/device": "^0.5.6",
"#capacitor/filesystem": "^0.5.2",
"#capacitor/ios": "^3.0.0-rc.0",
"#capacitor/local-notifications": "^0.6.0",
"#capacitor/push-notifications": "^0.3.6",
"#capacitor/storage": "^0.3.6",
"capacitor-secure-storage-plugin": "^0.5.0",
"com-darryncampbell-cordova-plugin-intent": "^2.0.0",
"com.darktalker.cordova.screenshot": "^0.1.6",
"cordova-plugin-advanced-http": "^3.1.0",
"cordova-plugin-app-launcher": "^0.4.0",
"cordova-plugin-appcenter-analytics": "^0.5.1",
"cordova-plugin-appcenter-crashes": "^0.5.1",
"cordova-plugin-appcenter-shared": "^0.5.1",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-file-opener2": "^3.0.5",
"cordova-plugin-zip": "^3.1.0",
"jetifier": "^1.6.6"
}
}
Both answers are wrong.
Capacitor 3 allows android plugins to auto register, but for that you need to remove the init method from MainActivity.java, if it's there the automatic registration won't work as init is the legacy way of registering plugins.
So you have two options:
Remove the init method from MainActivity.java as explained on the capacitor 3 updating docs
Keep the legacy init method and add plugins as you did on Capacitor 2. I.E. add(DatepickPlugin.class);
By removing android folder as answer 1 suggests, the init method gets removed and that's why that answer works, but it's destructive, it will remove all your manual changes in your projects.
And adding plugins as answer 2 suggests also works, but there is no need for doing that if using automatic plugin registration, that method is really there for non npm plugins.
Try removing android platform
(IMPORTANT: backup your android directory before removing.)
and run:
npm install #capacitor/core#next #capacitor/cli#next
npx cap init
npm install #capacitor/android#next
npx cap add android
then build your project and:
npx cap sync
I had the same problem
You need to add the plugins manually in your MainActivity.java
public class MainActivity extends BridgeActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// --- Remove bridge init as it's deprecated and add these lines
registerPlugin(com.capacitorjs.plugins.app.AppPlugin.class);
registerPlugin(com.capacitorjs.plugins.device.DevicePlugin.class);
// ---
}
}
When using live reload, make sure you have http:// in url.
As per documentation:
"server": {
"url": "http://192.168.1.68:8100",
"cleartext": true
},
When I used just ip, it rendered site, but plugins did not work (not implemented exception).
As per doc, you just need to update MainActivity.java file
https://capacitorjs.com/docs/updating/3-0
In my case, i just need to update my MainActivity.java
import com.getcapacitor.BridgeActivity;
public class MainActivity extends BridgeActivity {}
Using nxtend plugin I found that I also had to add the plugin package name to "includePlugins": [] in capacitor.config in order for sync to identify the needed plugins and populate the downstream gradle files in the android project. From what I understand cap is supposed to inspect the project package.json and automatically determine what plugins are used but this doesn't seem to be working for me.
I'm currently using Nx Monorepo with NxExt and Capacitor 4.0.
I solved the import problem by adding in the package.json of the mobile app (apps/mobile-app/package.json) the relative plugins required:
{
"name": "mobile-ionic-app",
"dependencies": {
"#capacitor/device": "^4.0.1"
},
"devDependencies": {
"#capacitor/android": "^4.2.0",
"#capacitor/cli": "^4.2.0",
"#capacitor/core": "^4.2.0"
}
}
In this way Capacitory can synchronize the plugins in the build phase:
Android Capacitor Build
This is because Capacitor changes the underlying Gradle files but Android Studio doesn't know about it
.
to fix this, go to Android studio click File -> Sync Project with Gradle Files
I have already make a build for android last week and everything works well. I have make some changes and now I want to make another build with expo build:android and I get this error.
Checking if this build already exists…
Entity Not Found.
It works well in ios but I couldn’t make the build for android. any thoughts?
thanks!
I fixed this error by changing the "slug" value to something else in the app.json file
I recently encountered this issue, tried a bunch of things. not sure which resolved it but here is a list.
How it started - a guess of how the issue originated
In app.json file I changed the value of android.package from "io.expo.client" to "com.mydomain.myapp"
"android": {
"package": "com.expo.client", // ---> "com.mydomain.myapp"
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
}
},
Then after that and a few other changes expo build:android resulted in an error Entity Not Found.
The fix - try the following to hopefully resolve your issue
delete all builds of the app from the project in expo
delete the project
create a new project
make sure the slug names match with that in your app.json file
run expo build:android -c on your app terminal to build with new credentials
accept to delete the old credentials
accept to have Keystore generated for you by expo
Deleting all builds of the app from the project in Expo alone helped me.
Don't forget to refresh the page between builds removal as changes do not immediatlety reflected
try to build with --clear-credentials flag...
or try in another expo account.
Recently I tried to update react native version from 0.48.4 to 0.49.0. I have read documentation about breaking changes.I installed react-native v0.49.0. When I am trying to run I got error like this
node_modules\react-native\local-cli\util\findSymlinkedModules.js:37
ignoredRoots? = [])
^
SyntaxError: Unexpected token ?
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at loader (\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
I tried to upgrade using react-native-git-upgrade and react-native upgrade.But getting errors like not recognized as an internal or external command.
I found one change in New features and Enhancements change log in RN 0.49.0 like this
Refactor how symlinks are discovered in local-cli, support scoped modules.
Is there anything to do with this
If you're using a git repo, try deleting the project folder then re-clone the repo. This worked for a friend who was having the same issue.
I found this solution here:
https://github.com/facebook/react-native/issues/16458
To fix this thing I had to use babel-plugin-transform-flow-strip-types plugin.
Steps :
npm install --save-dev babel-plugin-transform-flow-strip-types
In .babelrc
{
"plugins": ["transform-flow-strip-types"]
}
More details https://www.npmjs.com/package/babel-plugin-transform-flow-strip-types
Upgrading to "react-native": "0.54.1", fixed this for me.
Ran into the same issue updating to 0.54.
The root cause here is that Node is trying to interpret JS code with Flow types (in this case, ignoredRoots?).
Normally Babel would have removed these types via babel-plugin-transform-flow-strip-types, as Dinesh suggested. But that transform is contained in the standard react-native Babel preset, which does a bunch of other things too.
So what you really have to do is to make sure you have that preset setup. It should be under a devDependency in package.json:
"devDependencies": {
"babel-preset-react-native": "^4.0.0",
And then configured in .babelrc:
{
"presets": ["react-native"]
}
After that's setup you still may need to reset the packager cache:
npm start -- --reset-cache
This is what did it for me, hope it helps.
removing ? from findSymlinkedModules.js line no 37 worked for me
I'm using React Native 0.29 and developing for Android. I'm trying to lock the device orientation. What I need is to lock the screen in portrait mode. I tried with this repository https://github.com/yamill/react-native-orientation but it is not supporting RN 0.29 yet.
Is there any way I can lock the device orientation? Maybe any native Android hack with android studio?
Just add android:screenOrientation="portrait" to the activity in the AndroidManifest.xml.
2017 Update
Currently, there is also another way to do it once for both Android and iOS by adding:
"orientation": "portrait"
in app.json if you're using Expo:
{
"expo": {
"name": "My app",
"slug": "my-app",
"sdkVersion": "21.0.0",
"privacy": "public",
"orientation": "portrait"
}
}
Or at runtime:
ScreenOrientation.allow()
Example:
ScreenOrientation.allow(ScreenOrientation.Orientation.PORTRAIT);
Note that it only works if you're building with Expo but since this is currently (as of 2017) recommended in official guides on React Native Blog then probably a lot of people are using it so it's worth mentioning as an interesting solution in addition to hacking the Android-specific XML configuration files.
More info:
For more info see:
how to disable rotation in React Native?
There is a pull request for this to work on 0.29.2 and above:
https://github.com/yamill/react-native-orientation/pull/85
If you use his version, it should work on 0.29.2 and above:
https://github.com/youennPennarun/react-native-orientation
Steps:
unlink the previous installation with rnpm unlink react-native-orientation
rm -rf node_modules/react-native-orientation
in your package.json edit the entry of react-native-orientation to be as:
"react-native-orientation": "youennPennarun/react-native-orientation"
npm install
react-native link react-native-orientation
Things should work after this. You can track the progress of the PR and switch to main repo when it has been merged.
react-native-orientation - is no longer compatible with new version (I have tried 0.39.2). After linking this module I have the compiler's error.
As I got it, now we should use react-native-orientation-listener
npm install --save react-native-orientation-listener
rnpm link
Step:1
npm install git+https://github.com/yamill/react-native-orientation.git --save
Step2:
react-native link
Step:3
Modify the MainApplication.java file with:
import com.github.yamill.orientation.OrientationPackage;// import
#Override
protected List getPackages() {
return Arrays.asList(
new MainReactPackage(),
new OrientationPackage() //add this
);
}
You can use react-native-orientation-locker.
The 'react-native-orientation' has been deprecated.
Using the 'react-native-orientation-locker' component, you would be able to detect the current orientation, as well as locking it to Portrait/Landscape by using:
Orientation.lockToPortrait();
Orientation.lockToLandscapeLeft();
Even release the locks using
Orientation.unlockAllOrientations();