Skip to main content

Posts

Showing posts with the label Android

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...

React Native & Windows 10: "EPERM: operation not permitted, lstat"

I'm working on the Android version of a React Native (v0.43.4) app on my Windows 10 machine, which has turned out to be a real pain compared to working on the iOS version on my Mac. I've got everything set up with Android Studio, platform tools, the Android emulator and so on. Running my app in the emulator also works, but almost every single time I issue the react-native run-android command, it fails with the following error from the React Packager: EPERM: operation not permitted, lstat <some_path_here> I have no idea what this problem is or why it happens. I don't even have to make any changes to the code or included libraries for it to appear. It's enough to just stop the React Packager and run react-native run-android again to get the error. It's really starting to get on my nerves since rebuilding seems to be required a lot more often on Windows than what I'm used to on OS X. I'd love to know what causes this, but until I manage to figure...

GPGS Corona SDK plugin + Google Drive API

I've been working on implementing Google Play Games Services (GPGS) for Ice Trap the last couple of days, using the new GPGS plugin for Corona SDK. Read all the docs top to bottom, configured everything accordingly, double-checked everything several times, but still got nothing more than an "Internal error" when trying to login from the Android app using one of my test accounts. Finally, I found this thread on the Corona forums . I followed the advice from the thread and enabled Google Drive API from the developers console at https://console.developers.google.com . Ta-dah! That's all that was missing, and now logging in to GPGS works as it should. Happy to have found the solution, but I can't believe that this wasn't mentioned anywhere in the docs or in the Google Play Developer Console. Or did I just miss it? I don't know, but it would have been really nice to somehow get a more descriptive error code/message than just "Internal error"...

A quick introduction

So, who am I and what is this blog about? My name is Markus Ranner, a Swedish software developer with 15+ years of experience, mostly with backend focus using Java but also numerous other programming languages. In 2012 I started looking into mobile development out of curiousity, and began building an iOS app in Objective-C just to learn the language, as well as the iOS platform and the whole Apple eco system. After only about three months of development I released my first version of Avocado Meal Planner on the App Store. And from there on I knew that I wanted to do more mobile development! Avocado Meal Planner for iOS I didn't realize it back then because I had nothing to relate to, but it was actually quite a success right from the start with several hundreds of downloads each day! Unfortunately the first version wasn't all that good, so not many people wanted to pay for the full version. But just knowing that people all around the world were downloading and using ...