I am starting working over react-native for development of android application. I am quite familiar with android studio structure. In android sdk to create view XML is present and for controller java is present. But in react-native how to create view and controller for android application ?
But in react-native how to create view and controller for android application ?
This question is like given an apple but analyze as an orange.
For react-native, exactly for React part, we don't explicitly manage it as view and controller as we did for android or ios.
I suggest you read about React first. It is the core idea. The Native part is just meaning build the native mobile app by React way (you have totally 100% ways to touch the native part - android/ios code - without any restriction as you want).
Related
I want to make an android app using Kotlin for the back end and Android Studio. For the front end, I understand that React Native would be a powerful choice, however I cannot figure out how to add ReactN to my Kotlin project.
I also tried creating a project in ReactN and then adding Kotlin: installed nodejs, npm and create-react-native-app, made the project. Then I tried opening it in Android Studio, but I wasn't getting any options to actually compile and run the project. So another question would be: can you work on ReactN projects in Android Studio or not?
If you could give me some resources on how exactly to do this, or if you can walk me through it step by step, it would be very helpful. I want to mention that I've never developed for Android or Web before (I'm mentioning about Web because I cannot rely on any Reactjs knowledge from Web dev).
React Native is whole framework, for front and back end, and have nothing to do with Kotlin (well, some Kotlin snippets may be integrated into RN app, thats all). RN projects are in fact multiplatform web/js based apps and Kotlin is used for writing pure Android apps, so this isn't a front/back end separation in here, these are just different approaches to development. Mixing both, while possible, makes no sense in most cases
I generally like to automatically bake-in the results of a git describe --always --dirty in any website, app, etc I am developing so that I can easily trace behaviors. Right now, I can't figure out a way to get this in a React Native app.
I am using Android, but am certainly looking for a solution to both Android and iOS.
I found a way using a mix of other existing answers:
Call git-describe during the build to access from gradle
Call PackageManager to access the gradle config from Java
Then use a React NativeModule in Java to access from JS
Update (3 years later): Here's a minimal diff that shows how to implement in Android.
Has anyone had any success using react native to create both iOS and Android apps that can be used as libraries/sub-projects in other iOS and Android native projects that were created without react native? My goal is to create new functionality for an existing app that has both a iOS and Android codebase that was developed without react native.
As a simple example, lets image that I need to create a series of screens and logic to allow a user to 'create a new account'. Ideally I would like to create the new functionality (controller, views, api-client, etc.) using react native and then export it as a self contained iOS and Android app. In addition to being able to run these apps on their own, I would also like to be able to include them in other native iOS/Android projects as sub-projects. The native iOS project would then create a new storyboard/ViewController/segue(s) and link the main-view of the react native iOS App to it.
I know on iOS/xcode I can add a sub-project by drag-and-dropping an .xcodepro into another one. If I did this with a .xcodepro that was created with react native, how would I go about linking the top level view to the existing non-react native iOS project? Is there a similar process on the Android side to achieve the same functionality?
I would like to explore React Native as well. We have similar needs as you - to develop a common library/framework for iOS and Android. Our solution was to code the library in C++ and use it in XCode on iOS and through a JNI (Java Native Interface) converter on Android as well. The JNI is a pain as not everything translates 1 to 1. I researched using Ruby/RubyMotion but that also has a JNI conversion step. There are other languages that do not require a JNI conversion - but from my last read these are also eperimental. Trying all of these will require effort and results are not guaranteed. Assuming aside from the shared library you still want Native for the rest of the App (UI etc), this will require developers with a combination of Swift, React, and Java (which could get expensive) The approach that makes most sense would be to use Swift for the iOS framework and Kotlin for the Android library and use the same style (functional/react-swift/react-java style code) That way, while the libraries are still different, they are coded in the same style so development/maintenance effort on one can be quickly copied/applied to the other.
I have an app build using cordova. However, making it look properly on android is being a bit though. I read reac-native documentation and I thought about combining the current state of the app, embedding it on a web view and building the rest of the app using react-native.
The reason behind this is that I feel more comfortable building the android specific ui of the app (like sidebars, and menus) using react-native than cordova, and I want to know if this approach makes sense. Is react native web view as powerful as cordova? Does this make any sense?
Thanks and regards
Despite React Native owns a WebView component I believe that this component is not appropriate for your approach.
From the docs:
WebView renders web content in a native view. You can use this
component to navigate back and forth in the web view's history and
configure various properties for the web content.
The purpose of React Native WebView is simply "renders web content".
I believe that you can not simply put your current Cordova code inside a React Native Web View and "it works". If your current Cordova app is more than simple HTML pages and use some Cordova Plugin, for example, you will have problems at this point.
Added to this the fact that strange architecture will probably increase the maintenance cost.
And about React Native to be as powerful as Cordova: I would say that React Native is more promising and very powerful, but actually Cordova has a ecosystem more mature and consistent. Maybe you should take a look at NativeScript.
Is react native web view as powerful as Cordova?
Answer: It's more powerful than Cordova
Unlike Cordova/PhoneGap your code runs in a JS runtime on the OS, but the UI is rendered as native components. This makes it very different than Cordova/PhoneGap.
You can use the standard platform components such as UITabBar on iOS and Drawer on Android. This gives your app a consistent look and feel with the rest of the platform ecosystem, and keeps the quality bar high. These components are easily incorporated into your app using their React component counterparts, such as TabBarIOS and DrawerLayoutAndroid.
As for Cordova, you're bound to the limitations of the WebView.And since JavaScript is single threaded, you will at one point run into issues if there are too many things going on in your application code. Such as sluggish animations etc...
I'm working on a android application
I would like to create a application for android using phone gap.
Is this possible? can I create a front end design in Android XML and back end controller functions in phonegap and make it an app in android studio ?
Any thoughts / experiences?
YOu can use cordova/phone gap to develop mobile apps. But these framework uses HTML5/css/JS technologies to do so. Sn android.xml would not work. You need to create your UI using HTML+CSS and code your business lodic in JS.