<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Raymond Chan on Medium]]></title>
        <description><![CDATA[Stories by Raymond Chan on Medium]]></description>
        <link>https://medium.com/@raymondctc?source=rss-d7ce7187f442------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DYU_7-cww9pHW43JEX3_iw.jpeg</url>
            <title>Stories by Raymond Chan on Medium</title>
            <link>https://medium.com/@raymondctc?source=rss-d7ce7187f442------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 18:35:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raymondctc/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Configuring your sourceCompatibility, targetCompatibility and kotlinOptions.jvmTarget all at once]]></title>
            <link>https://raymondctc.medium.com/configuring-your-sourcecompatibility-targetcompatibility-and-kotlinoptions-jvmtarget-all-at-once-66bf2198145f?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/66bf2198145f</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[gradle]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Wed, 11 Oct 2023 08:43:06 GMT</pubDate>
            <atom:updated>2023-10-12T05:40:13.241Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I learnt a trick that you can set sourceCompatibility, targetCompatibility and kotlinOptions.jvmTarget all at once:</p><p>Step 1: In your root project’s build.gradle.kts , add the following script:</p><pre>val jvmVersion: Provider&lt;String&gt; = providers.gradleProperty(&quot;kotlin.jvm.target&quot;)<br><br>configure(subprojects) {<br>    // Apply compileOptions to subprojects<br>    plugins.withType&lt;com.android.build.gradle.BasePlugin&gt;().configureEach {<br>        extensions.findByType&lt;com.android.build.gradle.BaseExtension&gt;()?.apply {<br>            jvmVersion.map { JavaVersion.toVersion(it) }.orNull?.let {<br>                compileOptions {<br>                    sourceCompatibility = it<br>                    targetCompatibility = it<br>                }<br><br>            }<br>        }<br>    }<br><br>    // Apply kotlinOptions.jvmTarget to subprojects<br>    tasks.withType&lt;org.jetbrains.kotlin.gradle.tasks.KotlinCompile&gt;().configureEach {<br>        kotlinOptions {<br>            if (jvmVersion.isPresent) jvmTarget = jvmVersion.get()<br>        }<br>    }<br>}</pre><p>Step 2: In your gradle.properties , add the following line:</p><pre>kotlin.jvm.target=17</pre><p>Step 3: Now you can remove all sourceCompatibility, targetCompatibility and kotlinOptions.jvmTarget from your subprojects.</p><p>Done, now you can enjoy single source of truth for your subprojects!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66bf2198145f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Xcode crashed with SwiftUI preview and Koin?]]></title>
            <link>https://raymondctc.medium.com/xcode-crashed-with-swiftui-preview-and-koin-212bfb3c93ad?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/212bfb3c93ad</guid>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Wed, 04 Oct 2023 19:47:17 GMT</pubDate>
            <atom:updated>2023-10-04T19:47:17.251Z</atom:updated>
            <content:encoded><![CDATA[<p>I encountered a crash in Xcode with Koin recently, when I tried to preview a SwiftUI component in Xcode, it kept crashing with the following error:</p><pre>Thread 0 Crashed::  Dispatch queue: BSXPCCnx:com.apple.dt.xcode-previews.systemservices (BSCnx:client:com.apple.dt.uv.agent-preview-scene-service)<br>0   libsystem_kernel.dylib                0x1af2060cc __pthread_kill + 8<br>1   libsystem_pthread.dylib               0x1af25a1e8 pthread_kill + 256<br>2   libsystem_c.dylib                     0x180129eb0 __abort + 124<br>3   libsystem_c.dylib                     0x180129e34 abort + 136<br>4   shared                                0x1060db608 konan::abort() + 12<br>5   shared                                0x106108528 (anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1::operator()() const + 16<br>6   shared                                0x106108340 void (anonymous namespace)::$_0::operator()&lt;(anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1&gt;((anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1) + 80<br>7   shared                                0x106108050 (anonymous namespace)::terminateWithUnhandledException(ObjHeader*) + 12<br>8   shared                                0x10610800c (anonymous namespace)::processUnhandledException(ObjHeader*) + 64<br>9   shared                                0x10611c710 kotlin::ProcessUnhandledException(ObjHeader*) + 188<br>10  shared                                0x10611f288 Kotlin_ObjCExport_trapOnUndeclaredException + 36<br>11  shared                                0x1060cefc8 objc2kotlin_kfun:com.pfp.app.di#initKoin3(){} + 200 (/&lt;compiler-generated&gt;:1)<br>12  SplashScreen.1.preview-thunk.dylib        0x11041cde0 static AScreen_Previews.__preview__previews.getter + 64 (SplashScreen.swift:50)<br>13  iosApp                                0x1026f3378 protocol witness for static PreviewProvider.previews.getter in conformance AScreen_Previews + 12<br>14  SwiftUI                               0x10ba49e68 0x10b0ec000 + 9821800<br>15  iosApp                                0x1026f33bc protocol witness for static _PreviewProvider._previews.getter in conformance AScreen_Previews + 40</pre><p>After some trial-and-error, I figured out that Koin was initialized two times due to how it was written.</p><p>First, there were two classes that extend the AppObservable interface:</p><ul><li>PreviewAppObservable — The class that generate SwiftUI preview.</li><li>DefaultAppObservable — The main class when the app is executed.</li></ul><p>The problem was that Koin’s initialization was done in DefaultAppObservable and also PreviewAppObservable , this was the root cause of the crash — Koin was initialized two times! That was not something I expected… 🤯</p><p>PreviewAppObservable:</p><pre>class PreviewAppObservable: AppObservable {<br>  required init(savedState: ParcelableParcelableContainer? = nil) {<br>    KoinHelper.doInitKoin()<br>    //...<br>  }<br>}</pre><p>DefaultAppObservable</p><pre>class DefaultAppObservable: AppObservable {<br>  required init(savedState: ParcelableParcelableContainer? = nil) {<br>    KoinHelper.doInitKoin()<br>    //...<br>  }<br>}</pre><p>The solution is to remove the doInit() call in both PreviewAppObservable and DefaultAppObservable, moving KoinHelper.doInitKoin() to App class and done!</p><pre>struct iOSApp: App {<br>  init() {<br>    KoinHelper.doInitKoin()<br>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=212bfb3c93ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sending adb command to all of your connected devices]]></title>
            <link>https://raymondctc.medium.com/sending-adb-command-to-all-of-your-connected-devices-aa49df79a924?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa49df79a924</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Mon, 02 Oct 2023 17:37:36 GMT</pubDate>
            <atom:updated>2023-10-02T17:41:28.658Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes you may need to perform adb commands on all of the connected devices during development. For example, I sometimes need to install APKs to different devices at the same time. The script is like this:</p><p>adb devices | tail -n +2 | cut -sf 1 | xargs -I {} -P4 adb -s {} install -r ~/Downloads/android-app.apk</p><p>Breaking down the command:</p><ul><li>adb devices — list out all the Android devices connected.</li><li>tail -n +2 — removing the first line of the input, i.e. “List of devices attached”.</li><li>cut -sf 1 — Extracting the device or emulator serial number.</li><li>xargs -I {} -P4 — reading items from standard input and executes a command with those items as arguments. -I {} specifies a placeholder {} that will be replaced with each item read from standard input.; -P4 specifies that up to four instances of command can be executed at once. (Adjust this value if you have more than four devices.)</li><li>adb -s {} install -r ~/Downloads/android-app.apk — Nothing but just your normal adb -s xxxx ;)</li></ul><p>Enjoy!</p><p><a href="https://gist.github.com/raymondctc/9f1d3841e5af573a3be6">https://gist.github.com/raymondctc/9f1d3841e5af573a3be6</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa49df79a924" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Changing app version without a Gradle sync]]></title>
            <link>https://raymondctc.medium.com/changing-app-version-without-a-gradle-sync-972ea37a04aa?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/972ea37a04aa</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Sat, 01 Jul 2023 00:14:57 GMT</pubDate>
            <atom:updated>2023-07-06T15:43:18.542Z</atom:updated>
            <content:encoded><![CDATA[<p>Every time you would like to test for app upgrade during development, you need to change the versionCode on Android Studio and then followed by a Gradle sync before you can build. That is time consuming right?</p><p>Here is a little trick that we used in our company’s project, it is actually simple:</p><ol><li>Create a file called version.txt in your project folder. It only contains a semver string like this: 1.0.0</li><li>Create a method in your build.gradle(.kts) that read version.txt to calculate your version code dynamically.</li></ol><pre>val getVersionCodeAndName: () -&gt; Pair&lt;Int, String&gt; = {<br>    val versionString = file(&quot;version.txt&quot;).readText()<br>    val versionArray = versionString.split(&quot;.&quot;)<br><br>    val versionMajor = versionArray[0].toInt()<br>    val versionMinor = versionArray[1].toInt()<br>    val versionPatch = versionArray[2].toInt()<br><br>    val versionCode = versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100<br>    val versionName = &quot;$versionMajor.$versionMinor.$versionPatch&quot;<br><br>    versionCode to versionName<br>}</pre><p>3. Now things are simple, simply call getVerisonCodeAndName to retrieve versionCode and versionName like this</p><pre>defaultConfig {<br>  versionCode = getVersionCodeAndName().first<br>  versionName = getVersionCodeAndName().second<br>}</pre><p>You can then modify version.txt to any app version you want!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=972ea37a04aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adopting Kotlin Multiplatform (KMP) on 9GAG App]]></title>
            <link>https://raymondctc.medium.com/adopting-kotlin-multiplatform-mobile-kmm-on-9gag-app-dfe526d9ce04?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfe526d9ce04</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Sat, 17 Dec 2022 23:17:01 GMT</pubDate>
            <atom:updated>2025-11-08T07:49:14.347Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Opinions expressed are solely my own and do not express the views or opinions of my employer.</em></p><blockquote><strong>Note: 2023–10–12</strong> The name <a href="https://blog.jetbrains.com/kotlin/2023/07/update-on-the-name-of-kotlin-multiplatform/">KMM had been officially re to KMP</a></blockquote><blockquote>Other case studies on JetBrains: <a href="https://www.jetbrains.com/help/kotlin-multiplatform-dev/case-studies.html">https://www.jetbrains.com/help/kotlin-multiplatform-dev/case-studies.html</a></blockquote><p>It is so excited to see that Kotlin Multiplatform Mobile (KMM) enters <a href="https://blog.jetbrains.com/kotlin/2022/10/kmm-beta">beta</a> stage and Google has <a href="https://android-developers.googleblog.com/2022/10/announcing-experimental-preview-of-jetpack-multiplatform-libraries.html">announced</a> that they have published experimental Jetpack libraries to KMM. It is so thrilling to see Google jumps in and porting Jetpack libraries to KMM, this could probably give KMM a further push. I believe KMM will be the future of mobile development if more and more frameworks or libraries are supported.</p><h4>React Native</h4><p><a href="https://9gag.com/">9GAG</a> has been trying out various cross-platform solution and yet none of them fully went to production. We tried to re-write the whole application in React Native in the 2016, everything went well at the beginning yet as we were adding more and more features, application’s performance kept degrading, the app size kept increasing. Besides, as we added more and more libraries, we entered into a dependency hell.</p><p>We turned out drop the whole project and going back to native development.</p><h4>Flutter</h4><p>Back in 2020, Flutter was getting the traction. We tried out Flutter on a side project. In my opinion, Flutter has a much better performance than React Native and the Material Theming looks pretty well. In terms of app size, it is quite decent thanks to app bundling support.</p><p>I was asked if Flutter was the right cross-platform solution, I hesitated. The reason was that the support for ads and Firebase was not that good at that moment. Moreover, there was some concern for images and videos handling, I was not comfortable to recommend this to the team.</p><h4>KMM</h4><p>Then in 2021, we knew that Jetbrains is developing their multiplatform solution: Kotlin Multiplatform Mobile. I was a bit skeptical at the very beginning, it looks like something similar to Xamarin and it was still in alpha stage, which may not be a good solution. One of my colleagues suggested to try it out as we had a side feature to develop at that time.</p><h4>Why jumping into KMM?</h4><p>We are still looking for ways to align the behaviour of the app on both platforms. The problem we used to have with React Native and Flutter is that, if the project failed, all the code you have written is wasted and that was what I felt skeptical at the very beginning. However, after a second thought, it was not the case and I agreed to give KMM a try and that is how the journey started.</p><p>Even if our code written in our KMM repository failed to port to iOS, we can still use it on our Android app, no waste at all! That is the simple reason that I would like to give it a try.</p><h4>How</h4><p>The ultimate goal is: existing iOS and Android app can use KMM as the logic layer. I believe that is the most of the cases for many of us instead of creating a completely new app with KMM. The goal seems big, but here are some tips on how to start small. This talk from <a href="https://www.droidcon.com/2022/09/29/adopting-kotlin-multiplatform-in-brownfield-applications/">Droidcon NYC 2022</a> was talking almost about the same thing what we have done!</p><p>To begin with let’s have a high level project structure overview of 9GAG:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*eSOZrg5GLxi_n7EZ0mAwJA@2x.png" /></figure><ul><li>:ninegag-shared-lib — This served as a wrapper project, contains no code inside, but to use it for exporting XCFramwork (NineGagKmm) for iOS</li><li>:ninegag-shared-app — KMM code that contains business logic, app constants, etc</li><li>:core — Another KMM project, but contains some low-level stuff like some util class, password/signature encoding methods, which can be reused by other projects in the future.</li></ul><p>Android project can simply call implementation project(&quot;:ninegag-shared-lib&quot;) to include all KMM code as usual</p><p>iOS project will include the XCFramwork binary built from the project :ninegag-shared-lib .</p><p><em>Step 1: Start from Android</em></p><p>Needless to say, Kotlin is Android’s first class language, the first intuition is to start with existing Android app first. Setup a KMM project that your existing Android app can include it as a dependency. That should be a easy first step.</p><figure><img alt="That’s one small step for man, one giant leap for mankind. — Neil Armstrong" src="https://cdn-images-1.medium.com/max/596/1*dqIFfElbSCM8URleHVgl7Q.jpeg" /><figcaption>“That’s one small step for man, one giant leap for mankind.” — <em>Neil Armstrong</em></figcaption></figure><p><em>Step 2: Making KMM project compilable on iOS</em></p><p>The next step is to include the KMM project into your existing iOS project.</p><p>We took a while to research for the project structure. The <a href="https://github.com/Kotlin/kmm-basic-sample">sample project</a> given did not suit our use case. At last we found an <a href="https://medium.com/wantedly-engineering/different-approaches-in-consuming-kmm-modules-in-ios-7957c722b114">article </a>on how to consume KMM library on iOS. The idea is simple, we treat the logic written in KMM as a library, and then both Android and iOS can just include that library like other libraries.</p><p>Hooray! You have done this step, as an Android developer, this was the most daunting part as I have no knowledge on iOS development and take time to learn. Moreover, I had to communicate with iOS teammates to understand their project structure, how to run the app on Xcode, etc.</p><p><em>Step 3: Start small with constants</em></p><p>Once step 2 is done, you may think about what to do next on code sharing. Implementing or migrating tracking constants to your KMM project will probably be one of the simplest thing you can do. Why? No code logic, no need to include 3rd party libraries, just constants. They can be easily used by iOS and let iOS developers to get a feel of what KMM is. :D</p><p>At the time we implement KMM, we were working on a side feature and we included many KMM related libraries to our codebase. For example, <a href="https://ktor.io/">Ktor</a>, for API call, <a href="https://github.com/cashapp/sqldelight">SQLDelight</a> for caching data to database, <a href="http://multiplatform-settings/">multiplatform-settings</a> for KV store and so on.</p><p>Depends on your situation, you probably not need to include so many things as your start. Therefore, I suggest to keep it simple.</p><p><em>Step 4: Start to migrate your common utils to KMM</em></p><p>I believe there are many util functions in your codebase that are not bounded to Android framework. For example, a util that converts a password to a hash, generate API signatures, or generate a colour code base on the user id or name, etc. These are all good candidates to move to your KMM project.</p><p><em>Step 5: Try writing or migrate business logic in KMM</em></p><p>Now, you should be more confident with KMM. You may start to migrate business logic or writing a new one with KMM, exploring doing some asynchronous stuff with coroutines!</p><p>This is the trickiest part according to my experience due to the time we implemented it as there were bugs that crashed iOS app with the Kotlin version that we were using (1.6.x).</p><p><em>Next</em></p><p>Once we started using KMM, I am thinking to share things as much as possible such that KMM project will act as a single source of truth. Here are some ideas for you:</p><ul><li>Network, API — Ktor</li><li>Database — SQLDelight</li><li>Resource sharing (String resources, Localization, Color code scheme) — <a href="https://github.com/icerockdev/moko-resources">moko-resources</a></li><li>Encryption/Decryption — <a href="https://docs.korge.org/krypto/">Krypto</a></li></ul><p>Here is a curated list of KMM libraries you may check for: <a href="https://github.com/terrakok/kmm-awesome">https://github.com/terrakok/kmm-awesome</a></p><h4>Challenges — Project setup</h4><p>Of course, there were lots of challenges encountered during KMM integration. Here are a list of items that I found challenging:</p><p>On iOS side</p><ul><li>What is Podfile?</li><li>How libraries are related?</li><li>How their dependencies work?</li><li>How Cocoapods works?</li><li>What is XCFramework</li><li>and so on and iOS devleopers are not familiar with Gradle stuff</li></ul><p>On KMM’s Gralde setup side</p><ul><li>How the Gradle script should be setup to produce a framework that can be consumed by iOS?</li></ul><h4>Challenges — Development</h4><ul><li>Not familiar with Swift</li><li>Calling coroutines in iOS</li><li>Strange variable names on iOS (e.g. Kotlinx_coroutines_coreCoroutineDispatcher)</li><li>Auto-complete in Xcode shows lots of unrelated variables</li></ul><h4><strong>Challenges — Workflow</strong></h4><p>As in the past, Android and iOS team has different set of workflows, e.g. in PR creation, branch naming, commit messages, CI provess and so on. With KMM’s integration, it also create an initiative to align our workflow such that we can unify and align the two teams into a single mobile team! (Ultimate goal)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*sYAcr3ook8wug6LUIS5IDA.jpeg" /></figure><h3>Conclusion</h3><p>In my opinion, KMM is definitely the future of mobile development as we are seeing more and more support coming. Though the learning curve is deep, it is a worthy investment, as KMM not only help us to share our code, but it also make us to think about how to align our workflow. As at the end of the day, we code to ship features to our users, how we can ship it faster and provide a consistent experience to our users is the ultimate goal.</p><p>👉 9GAG on <a href="https://play.google.com/store/apps/details?id=com.ninegag.android.app">Android</a> | <a href="https://apps.apple.com/us/app/9gag-best-lol-pics-gifs/id545551605">iOS</a> | <a href="https://9gag.com/">Web</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfe526d9ce04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gson, Kotlin and Proguard is crashing my app!]]></title>
            <link>https://raymondctc.medium.com/gson-kotlin-and-proguard-is-crashing-my-app-b22abb1b07c8?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/b22abb1b07c8</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[proguard]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Tue, 23 Oct 2018 14:40:41 GMT</pubDate>
            <atom:updated>2021-06-02T11:14:21.063Z</atom:updated>
            <content:encoded><![CDATA[<p>Lately I have been working with Kotlin, the code base is mixed with Java and Kotlin. One of the issues I found is that when Java Gson model is turned to Kotlin, the app crashes. With not much idea in head, I have done something like this:</p><pre>data class Message(@JvmField val address, @JvmField val content)</pre><p>It works🎉! The trick is by adding @JvmField annotation in front of class members.</p><p>My guess is that by adding @JvmField annotation, it keeps the field in public in Java level. However, I am not able to replicate the issue in a completely new project. Any ideas?🤔</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b22abb1b07c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fastlane with RVM on macOS]]></title>
            <link>https://raymondctc.medium.com/fastlane-with-rvm-on-macos-147446ce0f09?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/147446ce0f09</guid>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Fri, 27 Jul 2018 06:46:33 GMT</pubDate>
            <atom:updated>2018-07-27T06:46:33.511Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why should you use RVM instead of using system’s Ruby?</h3><p>It turns out that system’s Ruby doesn’t update fast enough, when you try to update Fastlane, it may be broken. :|</p><h4>Installing RVM on macOS</h4><ol><li>Install Homebrew (I think most of you should have it installed)</li><li>Install gnupg with brew install gnupg</li><li>Following the steps in <a href="https://rvm.io/rvm/install">https://rvm.io/rvm/install</a> to install RVM</li><li>If you are using fish shell, you may need to follow this guide to perform some extra steps: <a href="https://rvm.io/integration/fish">https://rvm.io/integration/fish</a></li><li>Select a version of Ruby to install by calling rvm list known</li><li>Install Ruby rvm install 2.5.1 (for example)</li><li>Use that version rvm use 2.5.1</li><li>Verify it ruby -v</li></ol><pre>Last login: Fri Jul 27 14:31:02 on ttys005<br>Welcome to fish, the friendly interactive shell<br>~ ⟩ ruby -v                                                                                                                                                                                                                                                             14:39:18<br>ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]<br>~ ⟩ which ruby                                                                                                                                                                                                                                                          14:39:21<br>/Users/raymond/.rvm/rubies/ruby-2.5.1/bin/ruby<br>~ ⟩</pre><p>Bravo! We are using RVM to manage Ruby now</p><h4>Installing Fastlane</h4><ol><li>Simply call gem install fastlane -NV</li></ol><p>Done!</p><h3>Update Fastlane on your project</h3><ol><li>Calling bundle update fastlane to update Gemfile.lock on your project. :)</li></ol><p>All set!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=147446ce0f09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Surprising API behaviour change for android.text.format.Formatter.formatFileSize]]></title>
            <link>https://raymondctc.medium.com/surprising-api-behaviour-change-for-android-text-format-formatter-formatfilesize-73965bd6b7b7?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/73965bd6b7b7</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Fri, 13 Jul 2018 16:13:55 GMT</pubDate>
            <atom:updated>2018-07-13T16:13:55.590Z</atom:updated>
            <content:encoded><![CDATA[<p>While we are implementing a feature to display the cache size in app for users, we think that there should be a simple function in Android to convert bytes to readable format.</p><p>So what we got is</p><p>android.text.format.Formatter.formatFileSize(Context context, long bytes)</p><p>Looks good, it takes a Context object, a little bit annoying though. But then the interesting part comes up. When I deploy the app on a 7.1 device, it behaves as expected like 10,73,741,824 bytes is showing 1.0 GB, but later when my colleague testing on his 8.1 device, it shows something like 1.1GB</p><p>Then I check the source code immediately, after SDK 25, the method has changed. It used to divide the bytes by 1,024. From SDK 26 on wards, it divides the bytes by 1,000, which is not expected. What a surprise!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*hI5p2tO8JX7TsSXzTc8WSw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73965bd6b7b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PublisherAdView is causing RecyclerView (any scrollable view) to shift?]]></title>
            <link>https://raymondctc.medium.com/publisheradview-is-causing-list-to-shift-6a332b65e370?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a332b65e370</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Tue, 17 Apr 2018 17:01:53 GMT</pubDate>
            <atom:updated>2020-03-18T02:01:34.778Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently the 9GAG Android app has integrated PublisherAdView to post list. We found a strange bug that the list( RecyclerView ) will shift when we scroll to those PublisherAdView and perform tab changes in ViewPager. We switch from tab 1 and then to tab 2 and then back to tab 1. The list will be shifted, it looks as if the advertisement is trying to put it to a visible position! (Smart, huh?)</p><p>Demonstration:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DnDGfVxRi4zI&amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FnDGfVxRi4zI%3Ffeature%3Doembed&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c18902593d057a5b92ee287de47ec874/href">https://medium.com/media/c18902593d057a5b92ee287de47ec874/href</a></iframe><p>After some investigation, and we found <a href="https://stackoverflow.com/questions/19887711/admob-adview-causing-scrollview-to-scroll-when-shown">this StackOverflow question</a>.</p><p>It’s because PublisherAdView is a WebView under the hood, and WebView itself will trigger a focus request. In the question, the answer is to add android:focusableInTouchMode=&quot;true&quot; attribute, however, this will make the LinearLayout focusable, which doesn’t solve the issue.</p><p>Solution is simple, we used this attribute android:descendantFocusability=&quot;beforeDescendants&quot; to its parent view. 🎉 That solves the issue immediately! This trick should applies to any scrollable views (RecyclerView, ListView and ScrollView)</p><p>Example layout:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05f41d8010c61190ebbf2711ba16a2da/href">https://medium.com/media/05f41d8010c61190ebbf2711ba16a2da/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a332b65e370" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My thoughts on React Native]]></title>
            <link>https://raymondctc.medium.com/my-thoughts-on-react-native-e5b858f404f6?source=rss-d7ce7187f442------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5b858f404f6</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Raymond Chan]]></dc:creator>
            <pubDate>Tue, 13 Dec 2016 16:42:52 GMT</pubDate>
            <atom:updated>2016-12-13T16:43:41.893Z</atom:updated>
            <content:encoded><![CDATA[<p>We are trying to use React Native to rebuild the whole app, so that it can be run on iOS and Android with the same code base at the same time. I have been working on this with my teammates for a few weeks, and I would like to share some of my thoughts.</p><p>I have to admitted that it’s quite attractive, as you can use the same code base to make an app that runs on iOS and Android.</p><p>However, as we keep working on this, we found out that many places require us to perform native bridges, that is, writing Java and Objective-C for Android and iOS respectively due to performance issue or some of the libraries that we are using, doesn’t support React Native out of the box.</p><h3>Native code for performance</h3><p>Our app contains many long images, due to performance issue, we cannot load the whole image into memory, we just load what can be seen on the screen to optimize memory usage. Since we have already written this widget in native code, all we need to do is to write a JS interface to bridge the native code. Moreover, there were also some UI glitches when using native views with React Native that take us some time to fix.</p><h3>Native code for existing libraries/SDK</h3><p>Yes, there are quite a number of people wrote native bridges for some popular SDKs or libraries. e.g. Google sign in. However, not all of them suits our use case and requirements, we have to fork out the project and make some of our customization in it. Some lower level handling like <a href="https://github.com/johanneslumpe/react-native-fs">file system</a>, <a href="https://github.com/zo0r/react-native-push-notification">push notification</a>, <a href="https://github.com/wkh237/react-native-fetch-blob">download</a> require native bridges. Yes, these libraries are great already but for example, the push notification library itself doesn’t support showing <a href="https://developer.android.com/reference/android/app/Notification.BigPictureStyle.html">BigPictureStyle </a>on Android yet. Therefore, we have to fork the original project and write our native code (We can contribute back to the project later :D). Some others like crash reporting tools, Ads SDK… Our project consists of more and more native modules, it’s like defeating the purpose of using React Native.</p><h3>Performance</h3><p>This is the part that we concern most. The original app on Android was using about 10–30 MB of heap, however the React Native version, is using about 60–70MB of heap, which is more than a double. Besides, our app heavily use the list view. However, the ListView implementation of React Native is a like a scroll view, where it append view items to the list, no reuse mechanism so far. Even there’s a <a href="https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/recyclerview/RecyclerViewBackedScrollView.java">RecyclerViewBackedScrollView</a>, but if you look at the source code, there isn’t any view reuse at all. The app performance must gradually degrade as the time spending on the app increase. Though some <a href="https://github.com/sghiassy/react-native-sglistview">people </a>tried to optimize the performance of the default ListView, but we are reluctant to use it as the project is not very active and we know that React Native is releasing frequently, we don’t know when it will break the API. Here’s a <a href="https://www.youtube.com/watch?v=0MlT74erp60">talk </a>about how to optimize the performance of React Native, however, the systrace tool is available on iOS only at the moment. Even <a href="https://www.reddit.com/r/androiddev/comments/5fy8mi/epoxy_airbnbs_view_architecture_on_android/">Airbnb’s engineer said that they don’t use React Native on all parts of their Android apps</a> due to performance issue.</p><h3>Development tools</h3><p>We are using Nuclide, which is the official recommended IDE. However, we found that the find reference feature is quite weak when comparing with WebStorm, so some of our teammates has paid for it for better development experience.</p><h3>Conclusion</h3><p>In my opinion, React Native is still young and evolving, it has a great potential. It’s a great framework for fast prototyping and proof of concept. It’s also great for web engineer to participate in mobile app development. They can pick it up very quickly.</p><p>However, if you are talking about more complex usage like us, or performance is your big concern, then you have to think carefully before you move on to this framework. Otherwise, you will need to write lots of native bridges, spending time on tuning the app, which may slow down the development process.</p><p>We hope Facebook could make this framework better and better so that it’s really close to native experience. What’s your thought? Or do you have any experience to share? Feel free to comment! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5b858f404f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>