Skip to main content

Posts

Showing posts from May, 2017

A Git branching strategy for React Native iOS/Android apps

Developing a React Native app for both iOS and Android at the same time comes with some challenges. One of them is how to best organize your source code in a version control system such as Git. Even though most of the code will run on both platforms, there will also be quite a lot of things that need to be addressed differently for each platform. A good approach for handling these differences is to implement a suitable Git branching strategy. Being a solo developer I have the luxury to decide exactly how I want it to fit my needs, so I started out by writing down the following "requirements": I want to have all my code in a single Git repository I need separate branches for the iOS and Android versions I want to be able to develop all features shared by iOS and Android in a single branch to make everyday development as smooth as possible I want merging to be painless I want to avoid cherry-picking commits between branches I want separate branches for development and

Installing a React Native unsigned debug APK on device

In the React Native documentation it's possible to read about how to create a signed APK for release . But what if you only want to create an unsigned debug APK that doesn't require a developement server to run on device? Couldn't find anything in the official docs about this, but as usual Stack Overflow provided some great information, through  this thread with the following simple and efficient solution: First, from your app's root dir, run the following command: react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug When I ran it the first time I got some strange error, something about not being able to open a .babel.json file. Ran the command again, and no problem the second time. Then the second and final step: cd android ./gradlew assembleDebug After this you should be able

Accessing the developer menu on Android device with React Native using adb

Reloading a React Native app in the Android emulator is as easy as just double tapping the R key on the keyboard. But to do reload on device you need to bring up the developer menu to find the 'Reload' option. Shouldn't be that hard, right? You're just supposed to shake the device, or press the hardware menu button on older devices. Well, my old ASUS device doesn't react to any shakes, and neither does it have a hardware menu button. So how do I open the menu? Couldn't find any information in the current React Native docs about it, but finally found a solution in this documentation for React Native v0.27 ! Don't know if things have changed between v0.27 and v0.43 to render the information obsolete, but at least it did the trick for me. Just type the following command from a command line: adb shell input keyevent 82 It's also possible to exchange 82 for KEYCODE_MENU if you feel like typing a few more characters. :-) adb shell input keyevent KEYCOD

React Native Android bug: Tappable Text component with numeric value

A couple of days back I got this weird error in the Android version of my React Native app that never happens on iOS. The error seemed to be completely random and appeared every once in a while when I tapped an item in a list to view its details. Every time it happened, the app crashed with the following cryptic error message: undefined is not an object (evaluating '_props[registrationName]') Nothing in the stacktrace that caught my eye, and an error that seemingly had no direct connection to my own code. Scanned the Internet and especially Stack Overflow for clues but couldn't find anything related. Today, a few days after the bug first appeared, I decided to try to hammer it out once again. Launched the Android emulator and sure, the bug was still there and just like before it seemed to happen randomly. Ran a desperate Google search for the error message, and this time it resulted in this interesting hit at the top:  http://stackoverflow.com/questions/43674781/und