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.
I am new in JNI and trying to use a [library][1] in android project using ndk. It seems the
It seems the library is loaded in the android project properly using the following code :
static{
System.loadLibrary("usb1.0");
}
but when I try to call a native method following the libusb API like libusb_init() I get following error :
No implementation found for void com.example.hellojni.MainActivity.libusb_init() (tried Java_com_example_hellojni_MainActivity_libusb_1init and Java_com_example_hellojni_MainActivity_libusb_1init__)
what am I missing ? Do you have any better beginner examples ?
[1]: https://libusb.sourceforge.io/api-1.0/index.html
I have an android aar which is used in ReactNative and Xamarin android. I need to find the native api is called from which hybrid framework. For ReactNative I used Class reactClass = Class.forClass("com.facebook.react.ReactActivity") , if reactClass is not null then it was called from ReactNative. How do I find for Xamarin
Do you try to do like below ?
Java.Lang.Class.FromType(typeof(YourClass)).Name
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/
I'm developing a Cordova plugin on Android, but with Cordova Android new version (v 4.0.0) some methods I'm using have changed.
In my plugin.java I am using (on cordova android <= 3.7.1) :
//Adding listener on scroll when my plugin is initiated
webView.getViewTreeObserver().addOnScrollChangedListener(this);
//Then later
#Override
public void onScrollChanged() {
//custom actions when scrolling
}
Seem that now with cordova-android V.4.0.0, the way to access webView has changed
"onScrollChanged" message removed. Use view.getViewTreeObserver().addOnScrollChangedListener(...) instead
So now I have to do it this way with cordova-android 4.0.0 :
webView.getView().getViewTreeObserver().addOnScrollChangedListener(this);
Since my plugin has to be compatible with cordova-android < 4.0.0 and cordova-android >= 4.0.0, I was looking for a simple way to check cordova-android current version in my plugin.java to do one or the other method, but so far I haven't found how to do it...
So is there a public method to access corodova-android from an android plugin ? Have I missed an already common method to all cordova-android version do to what I want ?
Thank you all
Solution found for this problem : use of Reflection