I'm trying to add in a built-in application with react-native-expo a series of tools from firebase.I managed to add the following features Cloud Messaging and Firebase Analitycs.But I have to integrate In-app-messaging and Dynamic links
First time I install all firebase module/dependencies to do this task.
"#react-native-firebase/app": "^12.9.3",
"#react-native-firebase/in-app-messaging": "^12.9.3",
and my file looks like:
.......
import inAppMessaging from '#react-native-firebase/in-app-messaging
.......
useEffect(()=>{
await inAppMessaging().setMessagesDisplaySuppressed(true);
}[])
but I recive a warning:
]Unhandled promise rejection: Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app().
After that I try to find a solution,I learn that expo allow to create plugins to extend expo functionality
I tty to salve problem fallow expo documentation but I couldn't figure out how to create these plugins.
Next I find a module that can help me with-rn-firebase but is not working and the module is depeciated.
Then I searched the internet until I discovered other people with the same problem this is the link I see in their app.json a basic config of plugin and I try to implement in my project,after I install dependencies that I need i add in my file:
"plugins": [
"#react-native-firebase/app",
"#react-native-firebase/analytics",
"#react-native-firebase/in-app-messaging"
],
But the fallowing error occure:
Package "#react-native-firebase/analytics" does not contain a valid config plugin.
Learn more: https://docs.expo.io/guides/config-plugins/#creating-a-plugin
Cannot use import statement outside a module
What I mean is, if anyone has ever faced this problem, I want in my project to be able to use in-app-messaging and dynamyc-links if someone has tried an implementation with expo and has any idea
Eventually I solved the problem,expo when I use the command expo:build android it only compiles my javascript files,but some of the code was written in java and other optional files in the android / ios folder.So instead of compiling with expo I used eas.
Faloowing command:
Run as administrator cmd and write this line npm install -g eas-cli.
Initialize new module in your expo/react native project with this line eas init.
Build aplication using this line for android: eas build --platform android
*For ios is a bit different you mast edit your file eas.json:
{
"cli": {
"version": ">= 0.43.0"
},
"build": {
"development": {
"distribution": "internal",
"android": {
"gradleCommand": ":app:assembleDebug"
},
"ios": {
"buildConfiguration": "Debug"
}
},
"preview": {
"distribution": "internal"
},
"production": {
"ios": {
"cocoapods": "1.11.2"
}
}
},
"submit": {
"production": {}
}
}
Build aplication using this line for ios: eas build --platform ios
Eas build include in complile all app file .gradle/.js/.java/.xml/.m/.h and this thing offer your posibility to build mobile app in expo with same functionality and complexity like react native cli.
Usefull Link
https://docs.expo.dev/build/setup/
React Native Expo Build Failing due to cocoapods version
I think you need to run locally using expo dev client
https://docs.expo.dev/development/getting-started/
Mostly, the package that is not supported by expo can run natively. But you need successfully built in eas build.
Related
I saw that this file react-native.config.js can configure platform-specific dependency configurations
module.exports = {
dependencies: {
'react-native-webview': {
platforms: {
ios: null,
},
},
},
};
here the documentation
https://github.com/react-native-community/cli/blob/main/docs/projects.md#dependencies
But I didn't understand how to set a specific version for a library.
I need expo-modules-core to be at version 0.5.0 for IOS and 0.4.9 for Android
How can I do that?
(by the way, if there are other ways to do this, without using react-native.config.js, I'll use them anyway)
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.
When I transitioned to Expo's Managed Workflow (SDK 37 and now 38 as well), in-app update checking broke.
My code:
import * as Updates from 'expo-updates';
async checkForUpdate() {
const update = await Updates.checkForUpdateAsync();
if (update.isAvailable) {
this.updateApp();
}
}
async updateApp() {
await Updates.fetchUpdateAsync();
Updates.reloadAsync();
}
Logcat shows me that the checkForUpdateAsync() promise is being rejected with this message:
Error: The method or property Updates.checkForUpdateAsync is not available on android, are you sure you’ve linked all the native dependencies properly?
For the record I did install it via expo install expo-updates
Thanks.
I solved this by creating a new Expo project and looking for differences from my many-times-upgraded one. I found two:
I was using off-the-shelf React Native instead of the Expo build, so I changed the dependency in package.json to "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.1.tar.gz"
I also updated my expo version to ^38.0.8, as used by the new project.
Finally, I also deleted some build relics that I had generated during the way, but I think the fix came from one of the steps above.
Issue Description
I installed the library via npx react-native link react-native-navigation (and modifying the minSdkVersion in andoid/build.gradle).
When I run npx react-native run-android, the app is built and works fine, though I get the following error in the terminal:
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
- react-native-navigation (to unlink run: "react-native unlink react-native-navigation")
Since the lib has been linked manually, I add an entry in the react-native.config.js file to prevent react native to try to autolink the lib, as in:
module.exports = {
dependencies: {
'react-native-navigation': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
},
}
}
};
Now, the CLI error is not longer shown and the app is successfully built, but I get an error in the emulator:
TypeError: null is not an object (evaluating "this.nativeCommandsModule.setRoot()").
Which comes about at my first Navigation.setRoot(...); call:
[index.js]
const start = () => {
Navigation.events().registerAppLaunchedListener(() => {
registerScreens();
gotoInitialising();
// gotoLogin();
});
};
start();
My question is, what extra step should I take to get the lib to work and to not have a React Native CLI error, at the same time.
Environment
React Native Navigation version: 6.0.1
React Native version: 0.61.5
Platform(s) (iOS, Android, or both?): Android
Device info (Simulator/Device? OS version? Debug/Release?): Android emulator API 28 - (emulator version 29.2.1-5889189) - Debug build
FYI, since react-native-navigation#6.1.0, the link script has been fixed to update the minSDK for android as well.
Also you should not add react-native-navigation in react-native.config.js as the RNN library is required to be used in your native code. The team has updated the documentation to make the installation guide clearer: https://wix.github.io/react-native-navigation/docs/installing. If you follow the guide, it should be quite straightforward.
run the following command: react-native unlink react-native-navigation
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();