StripeModule failing for android React Native project - android

We have a project using Tipsi Stripe React module, when trying to build for Android I get the following error message: Native Module StripeModule tried to override StripeModule for module name StripeModule.
The error message does not make sense to me and I don't really know where to begin looking since i'm fairly new to mobile and React Native development.
Building for iOS works fine.

I have the same problem, i've tried adding
#Override
public boolean canOverrideExistingModule() {
return true;
}
to: /tipsi-stripe/android/src/main/java/com/gettipsi/stripe/StripeModule.java based on what i found here How to set canOverrideExistingModule=true.
It compiles, but I haven't tested if it keeps working, if it works i'll fork tipsi-stripe and create a PR later

Related

KMM - Unresolved reference: platform for IOS application

Hellow.
I have a trouble with template KMM application. It got an error after I created new KMM application - in shared IOS app module it cannot find package platform. It's on kotlin. Adroid app works well.
Need to say, that I works on window by Android studio. I know there are troubles to start IOS app on window, but I do not want to start or build app - I want to just it find the reference platform.
I tried to find some dicisions. There are the same questions, but nobody can answer them.
Code with trouble:
import platform.UIKit.UIDevice // here there is the error
actual class Platform actual constructor() {
actual val platform: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}
This question is a bit strange: how do you think iOS application will compile and work on a Windows computer?
To make KMM work on both OS you need a Mac. This is the reason why you are not able to find "platform.UIKit.UIDevice" on your machine.

React Native Facebook Login Android - Embedded Browser is disabled

I'm developing a facebook login feature for react native using react-native-fbsdk-next. However when testing on android I get this error when trying to login with facebook: "For your account security, logging into Facebook from an embedded browser is disabled."
From looking at node modules it does seem like it's using facebookSdkVersion v12.+. Another thing to note is that I'm testing on an android emulator, could that affect things?
And is there any workaround for this issue or is it just something the client has to deal with?
The library react-native-fbsdk has moved to react-native-fbsdk-next, they error you are facing may be due to the gradle cache issue, please use gradle clean and in the app/build.gradle add this code
ext{
...
facebookSdkVersion = "13.1.0"
}
Try to open the url by Linking react-native package
Linking.openURL(url);

null is not an object (evaluating 'RCTToastAndroid.SHORT')

I am attempting to convert my react-native project into an expo project, one small issue I've encountered is when I run the expo project I get an error as such
null is not an object (evaluating 'RCTToastAndroid.SHORT')
After doing some research online on how to fix this problem a user requested that a problem like this can simply be resolved by removing the Android part of RCTToastAndroid.SHORT this user stated that RCTToast is universally compatible with both iOS and Android. However when I do this I receive an error saying null is not an object (evaluating 'RCTToast.SHORT')
What can I do that will help ease the transition from my react-native project to an expo project?
All apps created with create-react-native-app, are compatible with Expo CLI without changes.
Ref link:- https://github.com/react-community/create-react-native-app/blob/master/CHANGELOG.md#upgrading-from-1140-to-201
only do like this
import {ToastAndroid}from 'react-native '
return ToastAndroid.show("some error msg", ToastAndroid.LONG);
I had the same exact problem.
Check to see if you've imported a library called 'react-native-simple-toast'. Remove it from your dependencies.
According to this issue:
this library has a custom native module for ios, and expo does not support that. This lib will not work with expo
it will only work with a bare React Native project.
If you do need to use Toasts
Here's a library that will work with Expo on both Android and iOS. The only downside is that it's pure Javascript.
You can use it like this:
import Toast from 'react-native-root-toast'
Toast.show('Your message here', {
duration: Toast.durations.SHORT,
position: Toast.positions.BOTTOM,
shadow: true,
animation: true
});

Load custom native component in react native using expo kit

Im trying to load a custom Android WebView to be able to upload files using html file inputs (by default Android webview wont work with input file). Im using this code, the only difference is that im using expo kit, so my MainApplication.java is different (inherits from another class by default):
public class MainApplication extends MultiDexApplication {
// Needed for `react-native link`
public List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new CustomWebViewPackage()
);
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
Basically what the git code do is override the default react native webview to make it use the CustomWebView.java in Android, using requireNativeComponent with this code (this is on CustomWebView.android.js):
var RCTWebView = requireNativeComponent('CustomWebView', WebView, {
nativeOnly: {
messagingEnabled: PropTypes.bool,
},
});
But when i run the application using exp start and navigate to the screen that has the CustomWebView i receive this error:
Summarizing the problem is that my custom native component is not being read by React Native. Can someone help me please?
Expo by default will not support any custom native modules. This is because they have a single perbuilt binary and they only load the JS bundle that you write. So any code you write with Expo can only be pure Javascript.
But Expo documentation does say that you can add custom native modules after detaching.
More info here:
https://docs.expo.io/versions/latest/guides/detach.html#should-i-detach
https://docs.expo.io/versions/latest/introduction/faq.html#what-is-the-difference-between-expo-and-react-native
https://github.com/expo/expo/issues/56
You can't use native code when using expo, you can use only what they give you. Ejecting will allow you to use native code but then you can't use expo anymore and I'm pretty sure it's irreversible.
You can see more about the caveats of using expo here: https://facebook.github.io/react-native/docs/getting-started.html#caveats
You can start with the best generator of code for React Native Known as Ignite it is very easy to use it has some BoilerPlates.
From the given useful boilerplates you can use Ignite Expo BoilerPlate which will setup all the code with expo + native modules support. After installing ignite-cli as global package and running ignite new [AppName] -b ignite-expo
So this will be an easy step for you. Also it adds some useful other modules as well.
After you eject a project, trying to use it via exp start will not give you the result you wish to achieve. While expo kit is still supported, you are now in need of new native code, as such you need to run it using react-native run-android. When you do so, it will not only serve JS as exp start does, but also compile your native code and put it in your device.
Right now, using exp start serves the JS bundle, however said bundle cannot find your native module as it does not exist within the generic expo client.
As said in the previous answers, expo and native modules don’t go hand in hand.
As expo only provides the capability to edit the javascript code and not the native modules, native modules can be considered black-box in the expo.
But if you are trying to integrate native modules into the expo, or are trying to run both expo and react-native native module together. Here is a very interesting read https://codersera.com/blog/running-expo-react-native-together/

Use custom system service in app (Android Studio)

First of all, thank you for your help.
Here is my problem.
I have made a custom system service (it does connect through the binder, and hooks into the system server, then into the HAL, etc). One of the main commands is isBacklightOn(). I also ran the make update-api to include it in my ROM build.
I am now ready to test the functionality using an app. I am using the following code:
import android.os.BacklightManager; //My service manager name
...
BacklightManager bm = (BacklightManager) getSystemService(BACKLIGHT_SERVICE);
...
if(!bm.isBacklightOn()) {
//Turn it on.
} else {
//Other Things...
}
My problem occurs because Android Studio will not build the application due to not knowing what the BacklightManager is. How can I build this application to test my code? (import something into Android Manager, force a build ignoring errors, etc.)
It looks like the solution is to build a custom SDK within the AOSP build environment. And then import that into Android Studio

Categories

Resources