<?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 Seiya Kokushi on Medium]]></title>
        <description><![CDATA[Stories by Seiya Kokushi on Medium]]></description>
        <link>https://medium.com/@ronnnnn_jp?source=rss-820806221f80------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FR7q_f4fkR3XiWu9FpDUAw.png</url>
            <title>Stories by Seiya Kokushi on Medium</title>
            <link>https://medium.com/@ronnnnn_jp?source=rss-820806221f80------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 14:17:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ronnnnn_jp/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[GitHub の merge queue を試してみて分かったこと]]></title>
            <link>https://medium.com/@ronnnnn_jp/github-%E3%81%AE-merge-queue-%E3%82%92%E8%A9%A6%E3%81%97%E3%81%A6%E3%81%BF%E3%81%A6%E5%88%86%E3%81%8B%E3%81%A3%E3%81%9F%E3%81%93%E3%81%A8-5c5b94cf477b?source=rss-820806221f80------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c5b94cf477b</guid>
            <category><![CDATA[merge]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[queue]]></category>
            <dc:creator><![CDATA[Seiya Kokushi]]></dc:creator>
            <pubDate>Thu, 09 Feb 2023 14:21:21 GMT</pubDate>
            <atom:updated>2023-02-16T01:29:48.177Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aGKvNJ7IQPbSdtGV" /><figcaption>Photo by <a href="https://unsplash.com/@ryutarouozumi?utm_source=medium&amp;utm_medium=referral">Ryutaro Uozumi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>モチベーション</h3><p>2023/02/09 に GitHub の Pull request merge queue が public beta ステータスでリリースされた。<br>うまく動かないところや、ドキュメントからは読み取れない動きがあったのでまとめる。</p><blockquote>public beta リリース時点での検証のため、今後の修正や仕様変更で動作が変わる可能性が大いにある</blockquote><h3>概要</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pZfYmQfjl1bL9AHh-bwe9A.png" /></figure><ul><li><strong>branch protetion のルールを守りながら</strong>、更新頻度の高いブランチ (main ブランチなど) へのマージを、安全に行えるもの。</li><li><strong>branch protection が設定された branch に対して</strong> merge queue を有効化できる。</li><li>branch protection のルールを<strong>全て満たした PR のみ</strong> merge queue に追加することができる。</li><li>merge queue 上でのステータスチェックやコンフリクトによってマージできない場合は、merge queue から取り除かれる。merge queue から取り除かれた理由は、各 PR に表示される。</li></ul><h3>何が嬉しいか</h3><p>先述の特徴により、PR マージ時にベースブランチのアップデートを気に掛けることなく、merge queue に詰めることができる。<br>ステータスチェックを通れば、ベースブランチにマージされ、コンフリクトやステータスチェックでコケた場合は、マージされない。これにより、<strong>ベースブランチが壊れる可能性を大きく抑えることができる</strong>。</p><p>日々の開発で 1 つのブランチに多くのマージが同時多発的に発生するようなリポジトリに向いている。</p><h3>有効にするには</h3><p>merge queue を有効にしたいブランチに branch protection を設定し、branch protection rule 内の Require merge queue にチェックを入れる。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3B7VKJshZvatVpY4SqhZwg.png" /></figure><h3>設定時に気にしたいポイント</h3><p>merge queue の振る舞いは、merge queue 自体の設定と、branch protection rule が関わってくる。</p><h4>merge queue 追加時のイベント</h4><p>公式ドキュメントだと merge_group: を workflow のトリガーに設定すると、merge queue 追加時に job を実行できそうだが、これがうまく動かなかった。<a href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group">merge_group: イベントのドキュメント</a>を確認し、 types: の有無や他のトリガーとの組み合わせも試したが、動かなかった。</p><p><a href="https://github.com/community/community/discussions/46757#discussioncomment-4909983">公式の Discussions</a> にも報告されているが、特定ブランチに対する push で動いた。merge queue は、一時的なブランチ (gh-readonly-queue/{base_branch}/pr-{pr_num}-{base_branch_hash}) を queue ごとに作成するため、 下記のように設定する。</p><pre>on:<br>  push:<br>    branches:<br>      - gh-readonly-queue/main/*</pre><p>なお、このトリガーによる workflow の変更は、<strong>merge queue 上のその変更を含むコミット以降</strong>の workflow で反映される。</p><p><strong><em>追記</em></strong></p><p>merge_group: が正しく動かない問題は解消された模様。</p><p><a href="https://github.com/community/community/discussions/46757#discussioncomment-4918697">Pull Request Merge Queue Public Beta Feedback · Discussion #46757 · community/community</a></p><h4>merge queue 追加時に GitHub Action を動かす</h4><p>merge queue 内で GitHub Action を動かすには Require status checks to pass before merging で動かしたい job を指定しておく必要がある。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7FOtngCPvKudvkWfQvXrA.png" /></figure><p>これを指定しておかないと、merge queue に PR の変更が詰められても、<strong>ステータスチェックを待たずに</strong>ベースブランチにマージされてしまう。</p><p>さらに、ここに指定する job の workflow は、先述の merge queue 追加時のイベントがないと、merge queue 追加時に job がトリガーされない。そ<strong>のため、</strong>ステータスチェックが終わらずベースブランチにマージできないという現象が発生する。</p><pre>name: PR では動くが merge queue 追加時に動かないやつ<br><br>on:<br>  pull_request:<br><br># merge_group:<br># が必要<br><br>job:<br>  build:<br>    steps:</pre><h4>Merge queue に詰められた後のコミット順</h4><p>merge queue は、queue ごとに一時的なブランチを作成すると説明したが、そのブランチが含むコミットの順番は Merge method の設定によって変わる。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rbtWWxP8N7mrh-c4H6fFOg.png" /></figure><p>次を例に説明する。</p><pre>main ブランチから A ブランチ、 B ブランチを切る。<br><br>時系列順に、<br><br>1. A ブランチにコミット (コミット a1)<br>2. B ブランチにコミット (コミット b1)<br>3. A ブランチにコミット (コミット a2)<br>4. B ブランチにコミット (コミット b2)<br><br>を作成し、<br><br>5. B ブランチの PR をマージ<br>6. A ブランチの PR をマージ<br><br>という順で merge queue に詰める。</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K-wnr9gYUkcCKcXLal_2iw.png" /></figure><p><strong>Merge commit の場合</strong></p><p>この設定では、コミットの時系列に沿って merge queue のコミットが並ぶ。</p><p>つまり、<strong>a1 → b1 → a2 → b2 → b3 (B ブランチのマージコミット) → a3 (A ブランチのマージコミット)</strong> と完全にコミットの時系列順になる。</p><p>そして、merge queue 上でのステータスチェックはマージコミットに対して行われる。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7DozfhdnzbRZzRDFEdxyfw.png" /><figcaption>Merge commit</figcaption></figure><p><strong>Squash and merge の場合</strong></p><p>この設定では、merge queue に追加された順で、squash されたコミットが merge queue のコミットが並ぶ。</p><p>つまり、<strong>b3 (b1 + b2 の squash) → a3 (a1 + a2 の squash) </strong>という順になる。</p><p>merge queue 上でのステータスチェックは、squash されたコミットに対して行われる。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rViztSOMT7AXGxfIkYQAwA.png" /><figcaption>Squash and merge</figcaption></figure><p><strong>Rebase and merge の場合</strong></p><p>この設定では、merge queue に追加された順で、前の queue の最後のコミットに rebase される。前の queue がない場合は merge queue のベースブランチの最後のコミットに rebase される。</p><p>つまり、<strong>b1’ (b1 の main への rebase コミット) → b2’ → a1’ (a1 の b1’ への rebase コミット) → a2’ </strong>という順になる。</p><p>そして、merge queue 上でのステータスチェックは、rebase された各 PR の最後のコミットに対して行われる。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jyH6GxRiEjza8fK7TMmVSQ.png" /><figcaption>Rebase and merge の場合</figcaption></figure><h4>merge queue に詰められた後にコンフリクトが発生した場合</h4><p>merge queue に詰められた後にコンフリクトが発生するケースが起こり得る。この場合、コンフリクトが発生した queue に対するステータスチェックは走らない。そのため、無駄に workflow が走ることはない。</p><h4>merge queue に詰められた後にステータスチェックが失敗した場合</h4><p>コンフリクトだけでなく、merge queue に詰められた後にステータスチェックが失敗するケースも起こり得る。その場合、失敗した queue より後の queue は、成功した queue にリベースされた後、再度ステータスチェックが走る。</p><h3>おわりに</h3><p>これまで main ブランチ push 時に動かしていた workflow は、多くが merge queue 追加時に移行できるはず。Merge method の設定はチームの方針によって、最適なものを選ぶのが良さそう。</p><h3>参考</h3><ul><li><a href="https://github.blog/changelog/2023-02-08-pull-request-merge-queue-public-beta">Pull request merge queue (public beta) | GitHub Changelog</a></li><li><a href="https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue">Managing a merge queue - GitHub Docs</a></li><li><a href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group">Events that trigger workflows - GitHub Docs</a></li><li><a href="https://github.com/community/community/discussions/46757">Pull Request Merge Queue Public Beta Feedback · Discussion #46757 · community/community</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c5b94cf477b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Widgetbook の特徴と Flutter 開発における UI カタログツールの比較]]></title>
            <link>https://medium.com/@ronnnnn_jp/widgetbook-%E3%81%AE%E7%89%B9%E5%BE%B4%E3%81%A8-flutter-%E9%96%8B%E7%99%BA%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8B-ui-%E3%82%AB%E3%82%BF%E3%83%AD%E3%82%B0%E3%83%84%E3%83%BC%E3%83%AB%E3%81%AE%E6%AF%94%E8%BC%83-f9a46a6ae700?source=rss-820806221f80------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9a46a6ae700</guid>
            <category><![CDATA[widgetbook]]></category>
            <category><![CDATA[flutter-ui]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Seiya Kokushi]]></dc:creator>
            <pubDate>Tue, 31 Jan 2023 13:41:37 GMT</pubDate>
            <atom:updated>2023-01-31T13:41:37.176Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UPqgaHiasmmQsuYV" /><figcaption>Photo by <a href="https://unsplash.com/@ninjason?utm_source=medium&amp;utm_medium=referral">Jason Leung</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>モチベーション</h3><p>先日開催された Flutter Forward 2023 において、 Widgetbook 上で UI 実装と UI デザインの比較が簡単になるというアップデート情報が公開された。</p><p><a href="https://www.youtube.com/live/zKQYGKAe5W8?feature=share">Flutter Forward 2023 Livestream</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_-9ZHFW-eutEagM2OuKxg.png" /><figcaption>Widget catalogs from the community</figcaption></figure><p>Flutter コミュニティにおいて有名な、その他の UI カタログツールについても触れられていたため、比較をしてみたい。</p><p>なお、 Widgetbook のより具体的な実装方法はこの記事では解説しない。</p><h3>Widgetbook とは</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqATt6RRbD5rcR3CEUQTbA.png" /><figcaption>Widgetbook demo</figcaption></figure><p>Widget をカタログ化して、ローカルまたはオンラインで閲覧するための package 群を指す。Widgetbook アプリケーションを、自身でビルド・デプロイするか、 Widgetbook Clound というオンラインツールを介して、複数環境(OS 、端末、向き、言語設定、テーマ)での Widget の見え方を確認することができる。Storybook.js にインスパイヤされて作られている。</p><ul><li>公式ホームページ: <a href="https://www.widgetbook.io/">https://www.widgetbook.io/</a></li><li>GitHub: <a href="https://github.com/widgetbook/widgetbook">https://github.com/widgetbook/widgetbook</a></li><li>Docs: <a href="https://docs.widgetbook.io/">https://docs.widgetbook.io/</a></li><li>デモ: <a href="https://demo.widgetbook.io/#/">https://demo.widgetbook.io/#/</a></li></ul><h3>特徴まとめ</h3><ul><li>カタログアプリを Desktop または Web で確認できる。</li><li>状態の変わる Widget もWidgetbook 上で動作確認可能。</li><li>アノテーションによるカタログアプリの自動生成。</li><li>UseCase により同じ Component の別表現を確認できる。</li><li>Knobs により、 Component の表現を Widgetbook 上で動的に変えることができる。</li><li>Knobs により、 Component の表現を Widgetbook 上で動的に変えることができる。</li><li>Category/Folder/Component 名を検索できる。</li><li>GitHub との連携 (要 Widgetbook Cloud)。</li><li>Figma との連携 (v3 から)。</li></ul><h3>主要な概念</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*nslpgr7Ae50_FNz9CLKcOw.png" /><figcaption>Widgetbook 上の主要な概念</figcaption></figure><h4>Component</h4><p>Widgetbook 内の中央で確認できる UI コンポーネントの単位。単体の Widget 、または複数の Widget をまとめた単一の Widget で構成される。</p><h4>UseCase</h4><p>任意の Component の種別を表すもの。各 Component に対し1つ以上設定する。</p><h4>Folder</h4><p>Component のグループ。Folder の中に Folder または、 Component を格納できる。</p><h4>Category</h4><p>Folder のグループ。</p><h3>カタログを作るには？</h3><h4>カタログアプリの対応プラットフォーム</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F_XtvHSit28G6-7gjVGIjQ.png" /><figcaption><a href="https://docs.widgetbook.io/widgetbook/run">https://docs.widgetbook.io/widgetbook/run</a></figcaption></figure><p>現状は Desktop か Web が対応している。チームでの共有のしやすさを考えると Web アプリケーションを作成し、ホスティングするのが良さそう。</p><h4>package 群</h4><p>■ <a href="https://pub.dev/packages/widgetbook"><strong>widgetbook</strong></a></p><p>Widget をカタログ化するためのベースとなる package 。</p><p>■ <a href="https://pub.dev/packages/widgetbook_generator">widgetbook_generator</a></p><p>Widgetbook アプリケーションの生成とメンテナンスの簡略化をコード生成によって実現している。そのコード生成機構の package 。<a href="https://pub.dev/packages/source_gen">source_gen</a> によって自動生成を実現している。</p><p>■ <a href="https://pub.dev/packages/widgetbook_annotation">widgetbook_annotation</a></p><p>widgetbook_generator でのコード生成に必要となる annotation が含まれる package。</p><h4>① widgetbook package を利用して作成する</h4><p>widgetbook package により提供されている API を用いて、 Component/UseCase/Folder/Category などを組み合わせて Widgetbook を手動で構築する。</p><p><a href="https://docs.widgetbook.io/widgetbook/properties">Widgetbook</a></p><h4>② widgetbook_generater package を利用して作成する</h4><p>Widget を返す関数に対して、 widgetbook_annotation で提供されているアノテーションを付与することで、 Widgetbook の自動生成を行うことができる。付与されたアノテーションは widgetbook_generater により解析され、実行可能な Widgetbook アプリケーションが生成される。</p><p><a href="https://docs.widgetbook.io/widgetbook-annotation/annotations">Widgetbook</a></p><h3>主要機能の紹介</h3><h4>Properties</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*mvMlT6mZRrR1ESWt3CvdeQ.gif" /></figure><p>端末の向き、 OS のテーマ、端末フレームの有無、端末サイズ、言語、テキストのスケールを Widgetbook 上で動的に変更して確認することができる。</p><h4>Knobs</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*by95ajCuntDqquu0kgKwYg.gif" /></figure><p>Component の表現を Widgetbook 上で動的に変えることができる。</p><h4>Widgetbook Cloud</h4><p>Widgetbook Cloud (有料)を使うことで、次の機能が利用できる。</p><p>■ hosting</p><ul><li>Widgetbook の web アプリケーションを Widgetbook Cloud 上で hosting し、 チームメンバーと Widgetbook を共有できる。</li></ul><p>■ レビュー機能 (beta)</p><ul><li>GitHub との連携により、 Widgetbook で管理されるコンポーネントの変更に対してレビューができる。</li><li>GitHub とは Webhook により連携する。</li></ul><p>実際に Widgetbook Cloud を触れていないので、招待されたら別途書きたい。</p><p>Widgetbook Cloud は有料機能であり、課金が必要になる。<br>課金は<a href="https://docs.widgetbook.io/widgetbook-cloud/billing">メールアドレスに基づくユーザー数</a>で決まる。<br>Plan の種別は Pro と Enterprise が存在するが、金額は招待が承認されるまで不明。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FtZPrQXUnZrOfaVw5QEoOg.png" /><figcaption><a href="https://www.widgetbook.io/plans">https://www.widgetbook.io/plans</a></figcaption></figure><h4>Figma との連携</h4><p>Widgetbook v3 から designLink という property が UseCase に追加されている。 Flutter Forward で発表のあった機能はこれで実現されている。</p><p>Figma の認証が特にないっぽいがそこら辺どうなるのか気になる 🤔</p><ul><li><a href="https://github.com/widgetbook/widgetbook/commit/7aa22dcab851ab0ca42a1902b8e6c08c2caae195">designLinkの対応コミット</a></li><li><a href="https://github.com/widgetbook/widgetbook-demo/pull/64">デモアプリに対する </a><a href="https://github.com/widgetbook/widgetbook-demo/pull/64">designLink 対応</a></li></ul><p>手元でビルドしてみたけど、 Figma がうまく表示されなかった 🥲</p><h3>他ツールとの比較</h3><h4><a href="https://github.com/playbook-ui/playbook-flutter">playbook-flutter</a></h4><ul><li>Snapshot を生成できるので、 VRT しやすい</li><li>PlaybookGallery で Snapshot 群を閲覧・検索できる</li><li>Story と Scenario の自動生成の定義ファイルを *.story.dart の拡張子で書かないといけないので実体の Widget と区別しやすい</li></ul><h4><a href="https://github.com/ookami-kb/storybook_flutter">storybook-flutter</a></h4><ul><li>自動生成は対応していない</li><li>カタログの機能は Widgetbook や dashbookとほぼ同等</li></ul><h4><a href="https://github.com/bluefireteam/dashbook">dashbook</a></h4><ul><li>自動生成は対応していない</li><li>カタログの機能は Widgetbook/dashbook とほぼ同等</li><li>codeLink を設定することで任意のURLにすぐ飛べる</li></ul><h4><a href="https://github.com/Dropsource/monarch">monarch</a></h4><ul><li>カタログと E2Eテストツールの中間という感じ</li><li>カタログ機能 + <a href="https://docs.flutter.dev/development/tools/devtools/inspector#visual-debugging">Visual Debugging</a> + 動的な状態の確認</li><li>自動生成は対応していない</li><li>デスクトップアプリケーションを使う必要がある</li><li>Story の定義ファイルを *_story.dart の拡張子で書かないといけないので実体の Widget と区別しやすい</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9a46a6ae700" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin Multiplatform Mobile Recap — 2022 Autumn]]></title>
            <link>https://medium.com/@ronnnnn_jp/kotlin-multiplatform-mobile-recap-2022-autumn-486fad816df5?source=rss-820806221f80------2</link>
            <guid isPermaLink="false">https://medium.com/p/486fad816df5</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Seiya Kokushi]]></dc:creator>
            <pubDate>Fri, 30 Sep 2022 06:57:02 GMT</pubDate>
            <atom:updated>2022-09-30T06:57:02.396Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kotlin Multiplatform Mobile Recap — 2022 Autumn</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rtanGufnYW_b3TVqImMjjg.png" /></figure><blockquote>Our company, CyberAgent, held a technical knowledge-sharing event called <a href="https://ca-base-next.cyberagent.co.jp/2022/">CA BASE NEXT 2022</a> on 27th and 28th July. This article is a translated version from “<a href="https://developers.cyberagent.co.jp/blog/archives/37611/">Kotlin Multiplatform MobileのおさらいとABEMAでのマルチプラットフォーム対応</a>” which summarizes <a href="https://ca-base-next.cyberagent.co.jp/2022/sessions/kmm-abema/">my session</a>. If you are interested in the original talk or other sessions in our events, refer to the official page or YouTube.</blockquote><p>Today, multiplatform/cross-platform development is one of the technology trends — such as Flutter, React Native, .NET MAUI, or Kotlin Multiplatform. Kotlin provides a feature to share some logics on multiple platforms including Android, iOS, and others since version 1.3. JetBrains plans to release KMM (Kotlin Multiplatform Mobile) Beta in this year (2022). We, at our company (CyberAgent and AbemaTV) have also been trying to share some code over platforms with Kotlin Multiplatform. In this article, I will introduce a lot of Kotlin Multiplatform features particularly KMM with Kotlin history. Moreover, I will provide tips gained from our development experience with KMM.</p><h3>What is Kotlin Multiplatform Mobile (KMM)</h3><h4>Kotlin Multiplatform?</h4><p>Before I explain Kotlin Multiplatform Mobile (KMM), let me introduce Kotlin Multiplatform (KMP) first. Kotlin Multiplatform is a technology that can develop applications for multiple platforms with <a href="https://github.com/JetBrains/kotlin">Kotlin</a>, developed by JetBrains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*7Wl_7hWR-oVqDw5B6hkdug.png" /><figcaption><a href="https://kotlinlang.org/"><em>https://kotlinlang.org</em></a></figcaption></figure><p>There are some similar keywords: Koltin Multiplatform Project (Kotlin MPP) and Kotlin Multiplatform Mobile (KMM). What is the difference between them?</p><p><strong>Kotlin Multiplatform (KMP)</strong> is a technology and the ecosystem that can develop applications for multiple platforms with Kotlin.<br><strong>Kotlin Multiplatform Project (Kotlin MPP)</strong> represents projects developed with Kotlin Multiplatform.<br>Last but not least, <strong>Kotlin Multiplatform Mobile (KMM)</strong> is an <a href="https://kotlinlang.org/lp/mobile/">SDK for iOS and Android app development</a>. KMM equals Kotlin Multiplatform plus the mobile-specific stuff around it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*PccCve03dgxkUVpd1jN17g.png" /><figcaption><a href="https://youtu.be/PW-jkOLucjM?t=341">It’s Time for Kotlin Multiplatform Mobile by Ekaterina Petrova</a></figcaption></figure><h4>Benefits of Kotlin Multiplatform and KMM</h4><p>Kotlin Multiplatfrom and KMM provide developers with a lot of benefits.</p><p>First, we can <strong>share some logics and source sets with Kotlin’s powerful API</strong>. Developments using Kotlin’s great features are the most helpful benefit. This year is the <a href="https://android-developers.googleblog.com/2022/08/celebrating-5-years-of-kotlin-on-android.html">5 anniversary since Google announced Kotlin’s official support for Android application development</a>. Kotlin now is used by developers worldwide.</p><p>And, <strong>almost all platform-specific APIs are available on Kotlin Multiplatform</strong>. For example, <a href="https://developer.apple.com/documentation/foundation/nsuserdefaults"><em>NSUserDefault</em></a> can be referenced from Kotlin with Kotlin Multiplatform. With <a href="https://www.jetbrains.com/lp/compose-mpp/">Compose Multiplatform</a>, you can make your UI run on Android application, desktop application and web application. <a href="https://kotlinlang.org/docs/multiplatform-dsl-reference.html#targets">The feature that Kotlin Multiplatform supports a lot of platforms as development targets</a> is also helpful.</p><p>Moreover, <strong>JetBrains provides and maintains essential features on mobile application developments</strong>, such as HTTP (<a href="https://github.com/ktorio/ktor">Ktor</a>), serialization (<a href="https://github.com/Kotlin/kotlinx.serialization">kotlinx.serialization</a>) and concurrency programming (<a href="https://github.com/Kotlin/kotlinx.coroutines">Kotlin Coroutines</a>). Of course, Kotlin Multiplatform community has been developing excellent third-party libraries.</p><p>It is also a huge merit that <strong>Kotlin Multiplatform can be gradually introduced as a part of your system</strong>. In our team, ABEMA, we introduced Kotlin Multiplatform to share logics that communicate with backend systems. Because of this merit, you can introduce Kotlin Multiplatform easily with various situations of your teams and be flexible to future changes. And also, Kotlin Multiplatform provides some choices to integrate source codes with your mobile applications, for example, you can distribute source codes as libraries.</p><h4>VS. Flutter, Unity and other technologies</h4><p>There are many choices to develop multiplatform/cross-platform applications, like <a href="https://flutter.dev/">Flutter</a>, <a href="https://unity.com/">Unity</a>, <a href="https://dotnet.microsoft.com/en-us/apps/maui">.NET MAUI</a> and so on.<br><strong>The biggest difference between Kotlin Multiplatform and them is if the technology needs a particular runtime environment</strong>. Kotlin Multiplatform compiles Kotlin codes to each platforms’ native code. So, source codes by Kotlin Multiplatform can perform like source codes by standard development environment of each platform. UI performance is one of the most important indexes on mobile applications. This is an advanced strength of Kotlin Multiplatform about performing on native environments without a particular runtime environment.<br>On the other hand, Kotlin Multiplatform doesn’t support UI development on iOS, tvOS and watchOS officially now. (However, JetBrains has been working on experiments about it!! I will discuss it in a later section.)</p><h3>Kotlin Multiplatform history</h3><p>In this section, I will dive into the history of Kotlin Multiplatform with Kotlin versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rfFARVnkycyrVWiL" /></figure><p>JetBrains has <a href="https://blog.jetbrains.com/kotlin/2012/01/the-road-ahead/">planned to compile Kotlin into native code from 2012</a> before Kotlin 1.0 released. On Kotlin 1.1, stable Kotlin/JS was released and we can <a href="https://blog.jetbrains.com/kotlin/2017/11/kotlin-1-2-released/">share source codes between JVM and JS environments from Kotlin 1.2</a>. As you can see, the history of Kotlin Multiplatform is so long.<br>Kotlin 1.3 that has a feature of sharing source codes with native platforms including iOS was released. This is known as Kotlin/Native. Eventually, <a href="https://blog.jetbrains.com/kotlin/2020/08/kotlin-multiplatform-mobile-goes-alpha/">KMM Alpha</a> was announced on Kotlin 1.4. Previously, <a href="https://github.com/JetBrains/kotlin-native">Kotlin/Native was not managed in the Kotlin project repository</a>. Since Kotlin 1.5, it has been <a href="https://github.com/JetBrains/kotlin/commit/f77ba914c7523f1569d213268222c648bcb9f4f7">merged with the Kotlin project repository</a>.</p><p>At the Keynote of Kotlin 2021 Premier Online Event, JetBrains announced <a href="https://youtu.be/3uVUDsoE_5U?t=735">a plan to <strong>release KMM Beta in spring 2022</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*62_BroOSKCtfS-Ft" /><figcaption><a href="https://youtu.be/3uVUDsoE_5U?t=735">Kotlin 2021 Premier Online Event Keynote</a></figcaption></figure><p><a href="https://blog.jetbrains.com/kotlin/2022/05/kotlin-multiplatform-mobile-beta-roadmap-update/">The plan had been postponed until 2022 autumn</a> to improve the stability of the new memory manager in Kotlin/Native. However, we can estimate that <strong>KMM Beta may be released in the near future</strong> because <a href="https://blog.jetbrains.com/kotlin/2022/09/kotlin-1-7-20-released/">the new memory manager is enabled by default on Kotlin 1.7.20</a>. Moreover, the release of KMM beta will make mobile application development faster, safer and more stable as a result of improvement for Kotlin/Native performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v3ClMeoUJ-w_eOKL" /><figcaption><a href="https://youtu.be/LE-Dy9XCLxk?t=557">Kotlin Multiplatform Mobile Beta Roadmap</a></figcaption></figure><p>A roadmap after the KMM Beta release has already been announced. This includes more intuitive and concise DSL for KMP, universal Kotlin libraries, open expects and more. You can check <a href="https://kotlinlang.org/docs/roadmap.html">other roadmaps</a> and <a href="https://kotlinlang.org/docs/components-stability.html#stability-of-subcomponents">stability of each Kotlin component</a> through official Kotlin documentation.</p><h3>How Kotlin Multiplatform works</h3><p>The ecosystem of Kotlin consists of libraries, framework, tools and compilers for various platforms. Platform specific APIs (Kotlin/JVM, Kotlin/JS, Kotlin/Wasm and Kotlin/Native) depend on them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IjSX2U2PX_2gYy0l" /><figcaption><a href="https://youtu.be/3uVUDsoE_5U?t=570">Kotlin 2021 Premier Online Event Keynote</a></figcaption></figure><p>There are two types of Kotlin compiler. Frontend compiler is common and translate source code into intermediate representations (IR). Backend compilers for each platform generate binary code. Recently, a new compiler (a.k.a K2) is developed and replaced gradually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NuHr06X9vfExmuDb" /><figcaption><a href="https://youtu.be/3uVUDsoE_5U?t=312">Kotlin 2021 Premier Online Event Keynote</a></figcaption></figure><p>If you want to get more information about K2 compiler, I recommend this video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fdb19VFLZqJM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Ddb19VFLZqJM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fdb19VFLZqJM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e08290835431b5dfb4991bcfd6f0196/href">https://medium.com/media/5e08290835431b5dfb4991bcfd6f0196/href</a></iframe><h4>Sharing source codes</h4><p>You can place shared source codes on a common source set by Kotlin Multiplatform’s technology. Of course, you can define platform specific source sets and similar platform source sets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*ettMGYpu7uUKIlkt" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sv3Fzj3Z0HSY4PYq" /><figcaption><a href="https://kotlinlang.org/docs/multiplatform.html#how-kotlin-multiplatform-works">multiplatform.html</a></figcaption></figure><h4>expect/actual</h4><p>Do you want to define interfaces on a common source set and implement them on platform specific source sets? The dream comes true. You can do this with <em>expect/actual</em> declarations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PbPiQ7_3WvlkiG8J" /><figcaption><a href="https://kotlinlang.org/docs/multiplatform-connect-to-apis.html"><em>https://kotlinlang.org/docs/multiplatform-connect-to-apis.html</em></a></figcaption></figure><p>First, you should define class, function or property with <em>expect</em>. After that, you can implement platform specific behavior with <em>actual</em>. Moreover, you can define declarations with <em>expect</em> on similar platform source sets (like iosMain).</p><h4>Target platforms</h4><p>Kotlin Multiplatform supports so many platforms (JVM, Android, iOS, JS and more!) as target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y2bKXE1wX5ujzMBX" /></figure><p>Read <a href="https://kotlinlang.org/docs/multiplatform-dsl-reference.html#targets">this documentation</a> of Supported targets’ list for their details.</p><h4>Project structure and configurations</h4><p>I will show you an overview of structure and configurations about Kotlin Multiplatform Project.<br>I will explain them with an Android and iOS target project, however, you can configure projects for other platforms in the same way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NKJp8Jsq5BpEwRJz" /></figure><p>First of all, create a commonMain directory for common, an androidMain directory for Android platform and an iosMain directory for iOS platform on any module.<br>Next, define build configurations on build.gradle.kts for the module.</p><p>On the build.gradle.kts, add definition of target platforms for the module. You can also add <a href="https://kotlinlang.org/docs/multiplatform-dsl-reference.html#native-targets">additional gradle tasks and artifact settings for each platform</a>.</p><pre>kotlin {<br>  android()<br>  listOf(<br>    iosX64(),<br>    iosArm64(),<br>    iosSimulatorArm64()<br>  ).forEach {<br>    it.binaries.framework {<br>      baseName = &quot;base&quot;<br>    }<br>  }<br>  // ...<br>}</pre><p>And then, add dependencies between source sets and dependencies for some libraries. You can inherit dependencies of the parent source set with dependsOn declaration. Libraries which are dependent on the parent source set must support the platform.<br>If you want to <a href="https://kotlinlang.org/docs/multiplatform-share-on-platforms.html#configure-the-hierarchical-structure-manually">define your own names of the source set (not like androidMain and iosMain) or similar platform source sets</a>, you can configure them here.</p><pre>kotlin {<br>  // ...<br>  sourceSets {<br>    val commonMain by getting {<br>      dependencies {<br>        // add dependencies of libraries and modules<br>      }<br>    }<br>    val commonTest by getting<br>    val androidMain by getting<br>    val androidTest by getting<br>    val iosX64Main by getting<br>    val iosArm64Main by getting<br>    val iosSimulatorArm64Main by getting<br>    val iosMain by creating {<br>      dependsOn(commonMain)<br>      iosX64Main.dependsOn(this)<br>      iosArm64Main.dependsOn(this)<br>      iosSimulatorArm64Main.dependsOn(this)<br>    }<br>    // ...<br>  }<br>}</pre><p>There are also some shortcuts for target platforms.</p><p><a href="https://github.com/JetBrains/kotlin/blob/v1.7.20-Beta/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithNativeShortcuts.kt">https://github.com/JetBrains/kotlin/blob/v1.7.20-Beta/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithNativeShortcuts.kt</a></p><ul><li>ios (iosArm64/iosX64)</li><li>tvos (tvosArm64/tvosX64)</li><li>watchos (watchosArm32/watchosArm64/watchosX64)</li></ul><p>Now, these shortcuts <strong>don’t include targets for simulators on Apple Silicon devices (like iosSimulatorArm64)</strong>.</p><h3>Introduce to your team</h3><p>In previous sections, I explained the history of Kotlin Multiplatform and how it works. I will show you some helpful resources to introduce Kotlin Multiplatform to your team.</p><p>It is very important that you dive into Kotlin and Kotlin Multiplatform. JetBrains who develop Kotlin provides excellent resources and communities.</p><p><a href="https://kotlinlang.org/docs/home.html"><strong>Kotlin Docs</strong></a></p><ul><li>official documentations are maintained constantly and <a href="https://kotlinlang.org/docs/multiplatform-mobile-getting-started.html">Get Started of KMM</a> are updated recently</li><li>the documents are managed on <a href="https://github.com/JetBrains/kotlin-web-site">GitHub</a></li></ul><p><a href="https://blog.jetbrains.com/kotlin/"><strong>The Kotlin Blog</strong></a></p><ul><li>articles about new releases or communities for Kotlin</li></ul><p><a href="https://www.youtube.com/c/Kotlin"><strong>YouTube Channel</strong></a></p><ul><li>tips and introductions of new feature for Kotlin</li><li>event videos are also uploaded</li></ul><p><a href="https://surveys.jetbrains.com/s3/kotlin-slack-sign-up"><strong>Slack</strong></a></p><ul><li>communicate with developers on JetBrains and member of community</li><li><a href="https://slack-chats.kotlinlang.org/?_ga=2.18805244.49543047.1662814406-1905135962.1662423662&amp;_gl=1*7p0n4*_ga*MTkwNTEzNTk2Mi4xNjYyNDIzNjYy*_ga_9J976DJZ68*MTY2MjkzNzc3NC43LjEuMTY2MjkzODMyOC4wLjAuMA..">read messages on slack without having membership for the workspace</a></li></ul><p><a href="https://twitter.com/kotlin"><strong>Twitter</strong></a></p><ul><li>check new releases, articles, video uploads and more</li></ul><p><a href="https://github.com/JetBrains/kotlin"><strong>GitHub</strong></a></p><ul><li>source codes of Kotlin</li><li>anyone can contribute because of open source</li></ul><p><a href="https://youtrack.jetbrains.com/issues"><strong>YouTrack</strong></a></p><ul><li>issues of Kotlin, IDEs, new feature and roadmap are managed</li></ul><p><a href="https://github.com/Kotlin/KEEP"><strong>Kotlin/KEEP</strong></a></p><ul><li>proposals for Kotlin language features</li><li>read discussions, use cases and ideas for language features</li></ul><p><a href="https://play.kotlinlang.org/hands-on/overview"><strong>Kotlin Hands-On</strong></a></p><ul><li>learn features of Kotlin with sample applications</li></ul><p>You can also discuss your ideas and get information on <a href="https://www.reddit.com/r/Kotlin/">Reddit</a> and <a href="https://stackoverflow.com/questions/tagged/kotlin">StackOverflow</a>.</p><p>Moreover, there are various sample projects and projects organized by the community. You can learn more practical ways of Kotlin Multiplatform development through them. I will introduce a part of them.</p><p><a href="https://github.com/Kotlin/kmm-basic-sample"><strong>Kotlin Multiplatform Mobile Sample</strong></a></p><ul><li>a simple sample project of KMM managed by JetBrains</li><li>good for beginners</li></ul><p><a href="https://github.com/Kotlin/kmm-production-sample"><strong>KMM RSS Reader</strong></a></p><ul><li>a sample project of KMM managed by JetBrains</li><li>including features of network and persistence</li></ul><p><a href="https://github.com/touchlab/KaMPKit"><strong>KaMP Kit</strong></a></p><ul><li>a sample application maintained by Touchlab, Inc. supports mobile application development by KMM</li><li>very practical development with KMM and how to use tools they provide</li></ul><p><a href="https://github.com/touchlab/DroidconKotlin"><strong>Sessionize/Droidcon Mobile Clients</strong></a></p><ul><li>session information application for Droidcon NYC by Touchlab and community</li><li>challenge to share UI implementations with Compose</li></ul><p><a href="https://github.com/DroidKaigi/conference-app-2022"><strong>DroidKaigi 2022 official app</strong></a></p><ul><li>an official application for DroidKaigi, a most famous conference of Android in Japan</li><li>developed by Japan Android community</li><li>sharing data layer with KMM</li><li><a href="https://twitter.com/_takahirom_">takahirom</a> who is GDE for Android and my colleague has been contributing mainly</li></ul><h4>How to introduce</h4><p>Before you try to introduce Kotlin Multiplatform to your project, you should consider how to adapt and where to introduce if your project already exists or what scope is commonized for new projects.<br>For the others, I recommend you should discuss the following points before introducing.</p><p><strong>How to manage your project</strong></p><ul><li>Mono repository? Multiple repositories? You may manage multiple applications.</li></ul><p><strong>How to refer to shared assets by Kotlin Multiplatform.</strong></p><ul><li>The ways to refer to shared source codes on iOS are through <a href="https://kotlinlang.org/docs/multiplatform-mobile-integrate-in-existing-app.html#connect-the-framework-to-your-ios-project">build scripts</a> or <a href="https://kotlinlang.org/docs/native-cocoapods.html">CocoaPods</a>.</li></ul><p><strong>What scope to share, Where to introduce from</strong></p><ul><li>If shared source sets depend on SDK or libraries, check if they are adapted for Kotlin Multiplatform (If not, you can share only the interface on Kotlin Multiplatform).</li><li>As close as shared source code is UI layer, effects from differences between platform APIs. You may try to introduce grateful libraries for logics affected by the lifecycle of the platform (like <a href="https://github.com/arkivanov/Decompose">Decompose</a>).</li></ul><p><strong>Architecture</strong></p><ul><li>Project architecture may be affected by what scope you share. Consider how to separate modules and their dependencies.</li></ul><p><strong>Libraries and tools</strong></p><ul><li>Mobile applications have many features like HTTP transactions, persistence, serialization, concurrency, loging, debugging and more.</li><li>There are incredible libraries and tools to simplify the usease of these technologies. You should choose which you use with multiple perspectives.</li><li>I list a part of them on the end.</li></ul><p>Our team members talked about how we introduce Kotlin Multiplatform, how our project consists of and more on other events (Japanese only 😭).</p><ul><li><a href="https://youtu.be/EejL0dDI_5c">ABEMAのKotlinMultiplatform | Flutter × Kotlin Multiplatform by CyberAgent #3</a></li><li><a href="https://youtu.be/baP7shKzEEE?t=3456">Flutter × Kotlin Multiplatform by CyberAgent #6</a></li><li><a href="https://youtu.be/gL_ZPTw_5nQ">ABEMAモバイルアプリ開発のDevOps戦略【CADC2022】</a></li><li><a href="https://youtu.be/uWwB-2BHRmw">Multiplatform Engineering Roadmap for the Future | ABEMA Developer Conference 2021</a></li></ul><h4>Introduce to teammates</h4><p>To introduce Kotlin Multiplatform to your projects, you must pay some costs. With technical consideration, you must discuss them with your teammates and managers to get time and human resources.<br>It is too difficult to imagine how much it will cost to introduce new technologies. And, you will find problems and difficulties after you decide to introduce them.<br>JetBrains provides some cases on world wide companies for introducing KMM as <a href="https://kotlinlang.org/lp/mobile/case-studies/">Case Studies</a>. These cases may be very helpful to introduce and discuss for your team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DXxWseqMTZtY-H-X" /><figcaption><a href="https://kotlinlang.org/lp/mobile/case-studies/">Case Studies</a></figcaption></figure><p>After you decide to introduce, you should support teammates not comfortable with Kotlin and Kotlin Multiplatform. We provide documentation and presentations for supporting them in our team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UUTuIbh7534mXisq" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rR2MByt69aEPzcIA" /></figure><p>Moreover, <a href="https://kotlinlang.org/docs/multiplatform-mobile-introduce-your-team.html">this docs page</a> is great for help to introduce.</p><h3>Expectation for KMM</h3><p>KMM will probably be in Beta state soon, but there are some difficulties.</p><h4>Sharing UI implementation</h4><p>Although This may not be a problem, almost all other multiplatform and closs-platform technologies can develop UI with single source sets. Kotlin Multiplatform provides <a href="https://www.jetbrains.com/lp/compose-mpp/">Compose Multiplatform</a> to share implementations on UI for Android, web and desktop applications. However, Apple platform targets (iOS, watchOS and tvOS) are not included in it currently.</p><p>On the other hand, developers and companies in the world try to share UI implementations with Kotlin Multiplatform. For example, <a href="https://github.com/cashapp/redwood">Redwood</a> is shown at <a href="https://nyc.droidcon.com/">DroidCon NYC</a> and <a href="https://github.com/JetBrains/compose-jb">JetBrains has been trying it as an experiment on Compose Multiplatform project</a>. Moreover, iOS target is added to some AndroidX libraries.<br>This is a featured topic on mobile application development.<br>I talked about Compose Multiplatform for iOS at another event (Japanese only 😭).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fs0LCzt5vmZU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Ds0LCzt5vmZU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fs0LCzt5vmZU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/739de6a9c410223b276d1fd08f4e81f0/href">https://medium.com/media/739de6a9c410223b276d1fd08f4e81f0/href</a></iframe><h4>Compatibility with Swift</h4><p>Binaries for iOS platform are generated with LLVM as Objective-C after shared source sets are translated to IR on Kotlin Compiler Frontend. Because Swift has compatibility with Objective-C, we can refer to implementations on KMM.<br>Of course, Kotlin, Objective-C and Swift are different programming languages and these features are also different. Therefore, complete compatibility with different languages is too difficult. You may need some workarounds to use KMM implementations easily on Swift or Objective-C in some cases.<br>Language features are similar because Kotlin and Swift are relatively newer languages. Community wants to translate Kotlin codes to Swift codes. Nevertheless JetBrains had tried it, This feature was postponed once. I hope to restart the project after problems are solved in the future.</p><p><a href="https://kotlinlang.org/docs/native-objc-interop.html">Kotlin Docs summarizes compatibility between Kotlin and Swift/Objective-C</a>.</p><h4>Build time</h4><p>Long time for Kotlin/Native builds has been a problem from before. <a href="https://youtrack.jetbrains.com/issue/KT-42294">JetBrains has been trying to improve it particularly after Kotlin 1.5</a>. Time to compile and generate artifacts is shorter than before, however, it still takes a long time. I hope it will be faster with improving cache mechanisms and incremental compiles.</p><p>Our team introduces <a href="https://github.com/dropbox/AffectedModuleDetector">Affected Module Detector</a> provided by Dropbox and <a href="https://github.com/takahirom/kotlin-multiplatform-affected-module-detector">customizes it to use on Kotlin Multiplatform</a>. Compiles and tests on only affected modules make build time to be short.</p><h3>For KMM Beta</h3><h4>Hierarchical Project Structure</h4><p>You can commonize multi source sets into one source set with Hierarchical Project Structure introduced in Kotlin 1.4.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*odDgpb0cW7OpVMmK" /></figure><p>After Kotlin 1.6.20, Hierarchical Project Structure is enabled as the default on creating new projects.<br>To enable the configuration, add these on gradle.properties of project root.</p><pre>kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.native.enableDependencyPropagation=false</pre><p>Libraries project depends on must adapt to Hierarchical Project Structure to adapt whole your project to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vwP-88DnKwKWe45a.png" /><figcaption><a href="https://kotlinlang.org/docs/multiplatform-hierarchy.html#compatibility"><em>multiplatform-hierarchy.html</em></a></figcaption></figure><p>There is a workaround to adapt to Hierarchical Project Structure before waiting for libraries’ adaptations. You can adapt to Hierarchical Project Structure by depending from each platform to the libraries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p2V4uFp9o7T3xn4S" /></figure><p>This workaround has a problem that you must add the same implementation to each platform. Therefore, I recommend escaping double management with symbolic links.</p><p>You can also make Hierarchical Project Structure be disabled.</p><pre>kotlin.mpp.hierarchicalStructureSupport=false</pre><p>Introductions for changes of projects and binaries with Hierarchical Project Structure are explained deeply on this video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F5QPPZV04-50%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D5QPPZV04-50&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F5QPPZV04-50%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ada5326c4ec61e19b9bf2b05b71fbe0/href">https://medium.com/media/0ada5326c4ec61e19b9bf2b05b71fbe0/href</a></iframe><h4>Kotlin/Native Memory Management</h4><p>Kotlin/Native has two rules for state sharing on multi threads.</p><ol><li>Mutable State == 1 thread</li><li>Immutable State == many thread</li></ol><p>Immutable State is not compile time static values defined with <em>val</em>. On Kotlin/Native, you can make any instance to be frozen state with <em>freeze()</em> function. Frozen state equals immutable state on Kotlin/Native concurrency. In other words, you can share only frozen state instances on multi threads with <em>freeze()</em> functions.<br>However, it is not practical that you can’t share mutable instances on multi threads. With AtomicXxx or Thread-isolated State, you can mutate states on multi threads. Which should you use? You can use AcomicXxx (like AtomicReference) if you want to mutate primitive values or small size objects. On the other hand, you should choose Thread-isolated state when you want to mutate collections which must pay a lot of costs with operations. Moreover, Thread-isolated state preserves race conditions which happened on AtomicReference because Thread-isolated state control operations on scheduled single threads.</p><p><a href="https://kotlinlang.org/docs/multiplatform-mobile-concurrent-mutability.html">https://kotlinlang.org/docs/multiplatform-mobile-concurrent-mutability.html</a></p><p>You can use AtomicXxx or Thread-isolated State easily with <a href="https://github.com/Kotlin/kotlinx.atomicfu">Kotlin/kotlinx.atomicfu</a> or <a href="https://github.com/touchlab/Stately">touchlab/Stately</a>.<br>Although, these limitations are not good for developers to handle concurrency specially on only Kotlin/Native. JetBrains has been <a href="https://blog.jetbrains.com/kotlin/2021/08/try-the-new-kotlin-native-memory-manager-development-preview/">developing Kotlin/Native New Memory Manager</a>. <a href="https://blog.jetbrains.com/kotlin/2022/05/kotlin-multiplatform-mobile-beta-roadmap-update/">KMM Beta is postponed because of improvement for stability of this New Memory Manager</a>.<br>What is happening with New Memory Manager?</p><ul><li>Reference-counting GC -&gt; Tracing GC</li><li>concurrency GC</li><li>no more <em>freeze()</em>!!</li><li>refer and modify top level properties without <em>SharedImmutable</em></li><li>cyclic reference including AtomicReference doesn’t make memory leaks</li></ul><p>You can use New Memory Manager as experimental since Kotlin 1.6.20 and this status was alpha on 1.7.0. <a href="https://kotlinlang.org/docs/whatsnew1720.html#the-new-kotlin-native-memory-manager-enabled-by-default">On Kotlin 1.7.20, it is beta and New Memory Manager is enabled by default</a>.</p><p>Some libraries have been adapted with New Memory Manager. You can depend on <a href="https://github.com/Kotlin/kotlinx.coroutines">kotlinx.coroutines</a> with not native-mt version after 1.6.0. Your project must be adapted to New Memory Manager for <a href="https://ktor.io/">ktor</a> 2.0.0 or newer.</p><p>JetBrains provides <a href="https://kotlinlang.org/docs/native-migration-guide.html">migration guides</a> to adapt to New Memory Manager.</p><h3>Wrap up</h3><p>I introduced know-how about introductions and expectations of Kotlin Multiplatform through the history of Kotlin Multiplatform and KMM. Kotlin Multiplatform is still in the process of improving, however, I hope it will evolve and be more stable and useful technologies.<br>Enjoy with Kotlin Multiplatform! And, have a nice Kotlin!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aUeOnT83u6dgTmme" /></figure><h4>Libraries and tools</h4><p><strong>HTTP transactions</strong></p><ul><li><a href="https://github.com/ktorio/ktor">ktorio/ktor</a></li></ul><p><strong>Persistence</strong></p><ul><li><a href="https://github.com/cashapp/sqldelight">cashapp/sqldelight</a></li><li><a href="https://github.com/realm/realm-kotlin">realm/realm-kotlin</a></li><li><a href="https://github.com/russhwolf/multiplatform-settings">russhwolf/multiplatform-settings</a></li></ul><p><strong>Serialization</strong></p><ul><li><a href="https://github.com/Kotlin/kotlinx.serialization">Kotlin/kotlinx.serialization</a></li><li><a href="https://github.com/square/wire/">square/wire</a></li></ul><p><strong>Concurrency</strong></p><ul><li><a href="https://github.com/Kotlin/kotlinx.coroutines">Kotlin/kotlinx.coroutines</a></li><li><a href="https://github.com/FutureMind/koru">FutureMind/koru</a></li><li><a href="https://github.com/rickclephas/KMP-NativeCoroutines">rickclephas/KMP-NativeCoroutines</a></li><li><a href="https://github.com/touchlab/Stately">touchlab/Stately</a></li></ul><p><strong>Logging</strong></p><ul><li><a href="https://github.com/AAkira/Napier">AAkira/Napier</a></li><li><a href="https://github.com/touchlab/Kermit">touchlab/Kermit</a></li></ul><p><strong>Debugging</strong></p><ul><li><a href="https://github.com/touchlab/xcode-kotlin">touchlab/xcode-kotlin</a></li></ul><p><strong>Date/Time</strong></p><ul><li><a href="https://github.com/Kotlin/kotlinx-datetime">Kotlin/kotlinx-datetime</a></li></ul><p><strong>BLoC</strong></p><ul><li><a href="https://github.com/arkivanov/Decompose">arkivanov/Decompose</a></li></ul><p><strong>Testing</strong></p><ul><li><a href="https://github.com/kotest/kotest">kotest/kotest</a></li></ul><p><strong>API Docs</strong></p><ul><li><a href="https://github.com/Kotlin/dokka">Kotlin/dokka</a></li></ul><p><strong>Build</strong></p><ul><li><a href="https://github.com/yshrsmz/BuildKonfig">yshrsmz/BuildKonfig</a></li></ul><p><strong>Develop Environment</strong></p><ul><li><a href="https://github.com/Kotlin/kdoctor">Kotlin/kdoctor</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=486fad816df5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ideaコマンドでファイル間の差分を確認する]]></title>
            <link>https://medium.com/@ronnnnn_jp/idea%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%A7%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E9%96%93%E3%81%AE%E5%B7%AE%E5%88%86%E3%82%92%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B-1a9d93bbf77c?source=rss-820806221f80------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a9d93bbf77c</guid>
            <category><![CDATA[intellij]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[intellij-idea]]></category>
            <dc:creator><![CDATA[Seiya Kokushi]]></dc:creator>
            <pubDate>Sun, 28 Aug 2022 09:05:29 GMT</pubDate>
            <atom:updated>2022-08-28T09:05:29.116Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XkghyORw2aJGZP8A" /><figcaption>Photo by <a href="https://unsplash.com/@thejohnnyme?utm_source=medium&amp;utm_medium=referral">Nikola Johnny Mirkovic</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>モチベーション</h3><p>IntelliJ IDEAやAndroid Studioアプリケーションを介して、ファイル間の差分を確認する方法がある。あまり知られていなさそうな機能なのと、自分自身も知らなかったのでメモしておく。</p><h3>JetBrains Toolboxを使用している人向け</h3><p>JetBrains Toolbox &gt; Settings &gt; Toolsに<em>Generate shell scripts</em>という項目がある。これをオンにしておくと、設定されたpathにダウンロードしているアプリケーションごとのスクリプトファイルが自動生成される。</p><figure><img alt="JetBrains Toolbox Settings" src="https://cdn-images-1.medium.com/max/1024/1*DKKlUPjtWxhnuRLMKvpz9A.png" /><figcaption>JetBrains Toolbox &gt; Settings</figcaption></figure><p>例えば、IntelliJ IDEAをインストールしている場合はidea、Android Studioをインストールしている場合はstudioという名前のスクリプトファイルが生成される。</p><p>スクリプトファイルが生成されるpathはデフォルトで/usr/local/binに設定される。もしこのディレクトリに書き込み権限がなければ追加する必要がある。ディレクトリに書き込み権限を付与していなかった場合は、ディレクトリに書き込み権限を付与後、JetBranis Toolboxを再起動するとスクリプトが自動生成される。</p><p>スクリプトファイルが生成されるpathは変更可能だが、変更する場合はコマンドラインでどこからでも実行できるよう、pathを通すことを忘れないよう注意。</p><p>生成されるideaコマンドは次のようなものが生成される。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a4c0354002919de5f9f573875ba7588/href">https://medium.com/media/7a4c0354002919de5f9f573875ba7588/href</a></iframe><p>studioコマンドについても最後のアプリケーションへのpathが異なるが同じようなスクリプトが生成される。</p><h3>JetBrains Toolboxを使用していない人向け</h3><p>JetBrains Toolboxを使用していない場合は、自分でideaコマンドを作成すれば良い。</p><p>先で紹介した自動生成されるideaコマンドの中では、openコマンドでIntelliJ IDEAアプリケーションのpathを指定している箇所がある。これをIntelliJ IDEA(もしくはAndroid Studio)アプリケーションがインストールされているpathに変える。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/431b7e1395a8c0d9355c7ac622c54b9c/href">https://medium.com/media/431b7e1395a8c0d9355c7ac622c54b9c/href</a></iframe><p>このスクリプトをideaという名前で保存しpathを通しておけば、ideaコマンドが利用できる。</p><h3>ideaコマンドでファイル間の差分を比較する</h3><p>diffコマンドを利用することで、ファイル間の差分を比較することができる。</p><pre>idea diff &lt;path1&gt; &lt;path2&gt;</pre><figure><img alt="diff between two files" src="https://cdn-images-1.medium.com/max/1024/1*R5MsQX3eZRxJefHxykcwTg.png" /><figcaption>差分が確認できるウィンドウが立ち上がる</figcaption></figure><p>見慣れたウィンドウで差分比較をすることができる。</p><p>また、ideaコマンドは、diff以外にもmergeやformat、inspectコマンドが利用できる。<br>これらの詳細に関しては公式ドキュメントを読んでほしい。</p><p>Android Studioに関しても上記のコマンドを利用できる。</p><pre>studio diff &lt;path1&gt; &lt;path2&gt;</pre><h3>参考</h3><p><a href="https://pleiades.io/help/idea/working-with-the-ide-features-from-command-line.html">コマンドラインインターフェース | IntelliJ IDEA</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a9d93bbf77c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SubcomposeLayoutを使ってTabRowとScrollTabRowを動的にレイアウトする]]></title>
            <link>https://medium.com/@ronnnnn_jp/subcomposelayout%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6tabrow%E3%81%A8scrolltabrow%E3%82%92%E5%8B%95%E7%9A%84%E3%81%AB%E3%83%AC%E3%82%A4%E3%82%A2%E3%82%A6%E3%83%88%E3%81%99%E3%82%8B-6c0f2b0dbc89?source=rss-820806221f80------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c0f2b0dbc89</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Seiya Kokushi]]></dc:creator>
            <pubDate>Thu, 30 Jun 2022 11:26:41 GMT</pubDate>
            <atom:updated>2022-06-30T13:11:25.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xKRtaAQBZgLsn-Eg" /><figcaption>Photo by <a href="https://unsplash.com/@alevisionco?utm_source=medium&amp;utm_medium=referral">alevision.co</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>⚠️ composeのバージョン: androidx.compose.material:material:1.2.0-rc03 ⚠️</p><h3>モチベーション</h3><p>Jetpack Composeでは、タブを配置するcomposableとして、<a href="https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#TabRow(kotlin.Int,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function1,kotlin.Function0,kotlin.Function0)"><em>TabRow</em></a>と<a href="https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#ScrollableTabRow(kotlin.Int,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,kotlin.Function1,kotlin.Function0,kotlin.Function0)"><em>ScrollableTabRow</em></a>が提供されている。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZBlINRDBZnq1eLj7jHMDw.png" /><figcaption>TabRowとScrollableTabRow</figcaption></figure><p><em>TabRow</em>は子に指定する<em>Tab</em>を均等幅に配置し、<em>ScrollableTabRow</em>は子の<em>Tab</em>の幅(厳密には<em>minWidth</em>が設定されている)で配置する。<br><em>Tab</em>の数が多い場合は、<em>ScrollableTabRow</em>を使って<em>Tab</em>をスクロールさせることが可能である。</p><p>しかし、<em>ScrollableTabRow</em>を利用する<em>と</em>次のような不都合が生じる。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AZ3pYfN7H0EId9sTscYNmQ.png" /><figcaption>Tabの数が少ない時のScrollableTabRow</figcaption></figure><p><em>Tab</em>の合計幅が画面幅に満たない場合に、<em>Tab</em>が左寄せになってしまう。<br>このようなケースでは、TabRowのような表現をしたくなるだろう。<br>動的に<em>Tab</em>の数が変わる場合や、画面幅が動的に変わる場合において、<em>TabRow</em>と<em>ScrollableTabRow</em>を動的に使い分けるにはどうしたらいいだろうか。</p><h3><em>Tab</em>がどう配置されるか</h3><p>まず、問題となっている<em>ScrollableTabRow</em>の挙動がどのように実装されているか確かめたい。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/891f5a84b5afdedef7d05a285b04350e/href">https://medium.com/media/891f5a84b5afdedef7d05a285b04350e/href</a></iframe><p><em>ScrollableTabRow</em>は親として<em>Surface</em>を配置し、その中で<em>SubcomposeLayout</em>を使って<em>Tab</em>や<em>Indicator</em>、<em>Divider</em>を配置している。</p><p><em>Tab</em>の幅は<em>minWidth</em>を固定値で設定しつつ、それらを足し合わせた数を全ての<em>Tab</em>の幅としている。<br><em>SubcomposeLayout</em>の<em>Modifier</em>に<em>wrapContentSize(align = Alignment.CenterStart)</em>が設定されているため、<em>Tab</em>の数が少ない時に左に寄ったレイアウトになるようだ。<br>また、<em>ScrollableTabRow</em>の引数で渡した<em>modifier</em>は<em>Surface</em>に適用される。(つまり、<em>ScrollableTabRow</em>の<em>modifier</em>をいじっても<em>ScrollableTabRow</em>の中の<em>SubcomposeLayout</em>には影響しない！)</p><p>次に、<em>TabRow</em>の<em>Tab</em>がどう配置されるか見てみる。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9220c60add7582a7a868cc1b4ac91697/href">https://medium.com/media/9220c60add7582a7a868cc1b4ac91697/href</a></iframe><p><em>SubcomposeLayout</em>の幅と<em>Tab</em>の数から、<em>Tab</em>ひとつあたりの幅を計算し、<em>Tab</em>が均等幅で配置されるよう計算している。</p><p><em>Tab</em>の幅が<em>TabRow</em>や<em>ScrollableTabRow</em>の中で決定されることが分かった。では、<em>Tab</em>の幅が画面幅に満たない場合に<em>TabRow</em>、画面幅を超える場合に<em>ScrollableTabRow</em>を使うにはどうしたら良いだろうか。</p><h3>SubcomposeLayoutを利用して事前にTabの幅を計測する</h3><p><em>TabRow</em>や<em>ScrollableTabRow</em>をcompositionする前に、<em>Tab</em>の幅を計測し画面幅を越えるか否かを判定できれば良さそうである。</p><p>composableを配置前に計測する方法として、<em>Layout</em>を使う方法があるが、今回のケースでは、</p><pre>画面幅 &lt; <em>Tab</em>の合計幅  -&gt; <em>ScrollableTabRow</em><br>画面幅 &gt;= <em>Tab</em>の合計幅 -&gt; <em>TabRow</em></pre><p>という判定を行った後に<em>ScrollableTabRow</em>と<em>TabRow</em>の<em>composable</em>を計測、配置したい。<br>このようなケースでは<em>TabRow</em>や<em>ScrollableTabRow</em>でも使用されている<a href="https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#SubcomposeLayout(androidx.compose.ui.Modifier,kotlin.Function2)"><em>SubcomposeLayout</em></a>を使うと良い。</p><p><em>SubcomposeLayout</em>のユースケースはドキュメントには次のように記されている。</p><pre>Possible use cases:</pre><pre>・You need to know the constraints passed by the parent during the composition and can&#39;t solve your use case with just custom <a href="https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#Layout(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.layout.MeasurePolicy)">Layout</a> or <a href="https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/LayoutModifier">LayoutModifier</a>. See <a href="https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#BoxWithConstraints(androidx.compose.ui.Modifier,androidx.compose.ui.Alignment,kotlin.Boolean,kotlin.Function1)">androidx.compose.foundation.layout.BoxWithConstraints</a>.<br>・You want to use the size of one child during the composition of the second child.<br>・You want to compose your items lazily based on the available size. For example you have a list of 100 items and instead of composing all of them you only compose the ones which are currently visible(say 5 of them) and compose next items when the component is scrolled.</pre><p>今回のケースは<em>ScrollableTabRow</em>と<em>TabRow</em>のcomposition中に<em>Tab</em>のサイズを計測したいので、おそらく2番目のユースケースになる。</p><p>実際に<em>SubcomposableLayout</em>を使ってみる。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/74292b1c6c3274a335583d73634f2229/href">https://medium.com/media/74292b1c6c3274a335583d73634f2229/href</a></iframe><p>まず、引数で受け取った<em>Tab</em>のcomposableを<em>SubcomposeLayout</em>の中で計測し、<em>Tab</em>の幅の合計が画面幅よりも大きいか否かを判定する。<br>この際、<em>Tab</em>はデフォルトで固定幅のpaddingが設定されているので注意したい。</p><p>上記の判定ができたら、その結果をもとに<em>TabRow</em>か<em>ScrollableTabRow</em>をcompositionする。</p><p>こうすることで、<em>Tab</em>の計測が必要になるものの、画面幅と<em>Tab</em>の幅をもとに<em>TabRow</em>か<em>ScrollableTabRow</em>をcompositionすることができた。</p><h3>おまけ</h3><p><em>ScrollableTabRow</em>は引数に<em>edgePadding</em>を渡すことができるが、<em>TabRow</em>はそのAPIが用意されていない。</p><p>そのため、<em>TabRow</em>に対しても<em>edgePadding</em>を設定したい場合は、<em>TabRow</em>の<em>modifier</em>で<em>padding</em>を設定することで対応できる。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bee8c44a3fc2e5bd5970064f44429a3/href">https://medium.com/media/1bee8c44a3fc2e5bd5970064f44429a3/href</a></iframe><p>ただし、このやり方では、</p><ul><li><em>Tab</em>の合計幅計算時に<em>edgePadding</em>の考慮が必要になる</li><li><em>TabRow</em>のdividerやbackgroundに対してもpaddingが設定されてしまうため、paddingを無視して画面幅いっぱいにdividerやbackgroundを表示したい場合は、<em>TabRow</em>のcomposition後に別途compositionする必要がある</li></ul><p>という点に注意したい。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c0f2b0dbc89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jetpack ComposeでTextの最小表示行数を指定できるようにする]]></title>
            <link>https://medium.com/@ronnnnn_jp/jetpack-compose%E3%81%A7text%E3%81%AE%E6%9C%80%E5%B0%8F%E8%A1%A8%E7%A4%BA%E8%A1%8C%E6%95%B0%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%A7%E3%81%8D%E3%82%8B%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B-8976523d4da5?source=rss-820806221f80------2</link>
            <guid isPermaLink="false">https://medium.com/p/8976523d4da5</guid>
            <category><![CDATA[layout]]></category>
            <category><![CDATA[compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Seiya Kokushi]]></dc:creator>
            <pubDate>Fri, 17 Jun 2022 01:20:14 GMT</pubDate>
            <atom:updated>2022-06-17T03:30:51.931Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DXGY_WPIwpKCnuKf" /><figcaption>Photo by <a href="https://unsplash.com/@finnmund?utm_source=medium&amp;utm_medium=referral">Finn Mund</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>⚠️ composeのバージョンは1.2.0-rc01 ⚠️</p><h3>モチベーション</h3><p>AndroidViewのTextViewには、<a href="https://developer.android.com/reference/android/widget/TextView#attr_android:lines"><em>android:lines</em></a>というattributeがあり、TextViewをこのattributeで指定された行数の高さで表示することが可能だった。</p><p>一方、Jetpack Composeの<a href="https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary?hl=ja&amp;authuser=19#Text(kotlin.String,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontFamily,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.style.TextDecoration,androidx.compose.ui.text.style.TextAlign,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.style.TextOverflow,kotlin.Boolean,kotlin.Int,kotlin.Function1,androidx.compose.ui.text.TextStyle)"><em>Text</em></a>では、<em>maxLines</em>は指定できるものの、最小表示行数を指定できるAPIは現状ない。</p><p>すでにstack overflowでも色々な解決策が議論されており、Issue Trackerにもかなり前から<a href="https://issuetracker.google.com/issues/122476634">Feature Request</a>が挙げられている。</p><p>stack overflowで紹介されている方法は、改行文字列のみの<em>Text</em>を別途追加する方法や、<em>Text</em>の<em>onTextLayout</em>コールバックから取得できる<em>lineCount</em>を用いてrecomposeする方法などがある。<br>しかし、これらの方法には、無駄なcomposableを配置する必要がある、最低でもlayoutが2回行われてしまうといった問題がある。</p><p>無駄なcomposableを配置せず、layoutも1回で済ませるにはどうしたらいいだろうか。</p><h3>Layoutでカスタムレイアウトを作成する</h3><p>Jetpack Composeには<a href="https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary?hl=ja&amp;authuser=19#Layout(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.layout.MeasurePolicy)"><em>Layout</em></a>というcomposable関数が用意されており、これを使うことで、カスタムレイアウトを作成することができる。</p><p>公式ドキュメントにも<a href="https://developer.android.com/jetpack/compose/layout?hl=ja#create-custom">カスタムレイアウトの作成方法</a>が紹介されている。</p><p><em>Layout</em>を使用することで、composableをlayoutする前にmeasureで計測したcomposableの幅や高さなどの情報(<em>Placeable</em>)を取得することができる。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec4711e092940ea0882d3f93a7775267/href">https://medium.com/media/ec4711e092940ea0882d3f93a7775267/href</a></iframe><p>この<em>Layout</em>を使用し、layout前に最低行数分の高さを測定できれば<em>android:lines</em>に近い動きが実現できそうである。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e0e035ce5f355ede8fb0d38e30e86e5/href">https://medium.com/media/8e0e035ce5f355ede8fb0d38e30e86e5/href</a></iframe><p><em>Layout</em>の<em>content</em>引数に渡すcomposableに改行文字列を含んだ<em>Text</em>を渡すことで、layout前に改行文字列のみのcomposableを計測することができる。<br>これによって、最低限確保したいTextの行数分の高さのレイアウトを作成することができた。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*EqqrU5eIezTWJJDnUWiP4A.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/199abb2c6ad0fcd60fa5799289bad69b/href">https://medium.com/media/199abb2c6ad0fcd60fa5799289bad69b/href</a></iframe><p>最大表示行数を<em>FixedLinesText</em>の<em>text</em>で渡すcomposableに任せたい場合は、</p><pre>layout(<br>  textPlaceable.width,<br>  <em>maxOf</em>(virtualTextPlaceable.height, textPlaceable.height),<br>) {<br>  textPlaceable.<em>placeRelative</em>(0, 0)<br>}</pre><p>とすればいい。</p><p><em>Layout</em>を使用することで、不要なcomposableをlayout、drawすることなく、更に1回のlayoutで最小表示行数を指定できるカスタムレイアウトを実現することができた。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8976523d4da5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[contentPaddingを使わずにLazyGridのpaddingを変更する]]></title>
            <link>https://medium.com/@ronnnnn_jp/contentpadding%E3%82%92%E4%BD%BF%E3%82%8F%E3%81%9A%E3%81%ABlazygrid%E3%81%AEpadding%E3%82%92%E5%A4%89%E6%9B%B4%E3%81%99%E3%82%8B-a41fecf144e3?source=rss-820806221f80------2</link>
            <guid isPermaLink="false">https://medium.com/p/a41fecf144e3</guid>
            <category><![CDATA[lazygrid]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[lazyvgrid]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Seiya Kokushi]]></dc:creator>
            <pubDate>Sun, 12 Jun 2022 12:28:00 GMT</pubDate>
            <atom:updated>2022-06-12T14:01:56.217Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kGHVgW8FL5-Oj9DS" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>⚠️ composeのバージョンは、1.2.0-beta03 ⚠️</p><h3>モチベーション</h3><p>次のようなレイアウトをJetpack Composeで実現したい。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L7yky6Au4JoahR5CePWJ3Q.png" /><figcaption>grid部分にのみ両端のpaddingがあるレイアウト</figcaption></figure><p>Jetpack Composeのfoundationには、<a href="https://developer.android.com/jetpack/compose/lists?hl=ja#lazy-grids"><em>LazyVerticalGrid</em>と<em>LazyHorizontalGrid</em>というcomposable関数が用意されており</a>、Gridのレイアウトを簡単に作成することができる。<br>また、itemごとに<em>span</em>を設定できるため、上図のHEADER部分のように行スパン全体にまたがるようなitemを配置することができる。</p><p>しかし、単純に<em>LazyVerticalGrid</em>を使って実現しようとすると、grid部分の両端のpaddingを上図のように正確に表現できない。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-0_sRUAleGemVqw9WvoD5g.png" /><figcaption>grid部分の両端のpaddingが足りない！</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d12b8e270bf58ac09a1ceebd76dc8987/href">https://medium.com/media/d12b8e270bf58ac09a1ceebd76dc8987/href</a></iframe><p><em>LazyVerticalGrid</em>の引数には<em>contentPadding</em>が用意されているが、これを設定するとHEADER部分にもpaddingが設定されてしまう。</p><p>このレイアウトを実現するためのアプローチをいくつか考える。</p><h3>1. GridCellsを実装して各itemのサイズを調整する</h3><p>まず、両端のpadding部分を、<em>Spacer</em>を含むitemで埋めるアプローチを試してみる。<br>単純に、Gridのspanの数を、表現したい列の数+2 (両端の<em>Spacer</em>分) にして、最適な場所に<em>Spacer</em>を含むitemを配置してみる。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9ddf410b535fe200b8876991fc57ff4/href">https://medium.com/media/b9ddf410b535fe200b8876991fc57ff4/href</a></iframe><p>うまくいきそうな気がするが、実際には次のようになる。<br>各itemの幅を固定値で設定しても、itemの幅が均等になるように配置されてしまう。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bBS7l9AAez3qlz9SJ1MrXA.png" /><figcaption>itemが均等に配置されてしまう</figcaption></figure><p>では、<em>LazyVerticalGrid</em>は、itemの幅をどのように決定しているのだろうか？</p><p><em>LazyVerticalGrid</em>の中を追っていくと、<em>rememberColumnWidthSums</em>の中で<em>calculateCrossAxisCellSizes</em>を呼んでおり、ここで各itemの幅を計算しているようである。</p><p><em>calculateCrossAxisCellSizes</em>は<a href="https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridDsl.kt;l=215?q=LazyGridDsl"><em>GridCells</em>というinterface</a>に定義されており、次の実装が用意されている。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/486860e7e9463eb1d6dc34e7b8fc71fc/href">https://medium.com/media/486860e7e9463eb1d6dc34e7b8fc71fc/href</a></iframe><p><em>calculateCrossAxisCellSizes</em>の実装を見ていく。<br>引数は次の二つ。(<em>LazyHorizontalGrid</em>の場合は縦横を読み替える)</p><pre><em>availableSize : LazyVerticalGrid</em>の最大幅 - <em>LazyVerticalGrid</em>の<em>contentPadding</em>に指定された<em>horizontalPadding</em></pre><pre><em>spacing: LazyVerticalGrid</em>の<em>horizontalArrangement</em>で指定されたitem間のスペース</pre><p>返り値は、1行(<em>LazyHorizontalGrid</em>の場合は1列)に含まれるitemの幅を<em>List</em>にして返すようである。</p><blockquote>Calculates the number of cells and their cross axis size based on <a href="https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)">availableSize</a> and <a href="https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)">spacing</a>.</blockquote><blockquote>For example, in vertical grids, <a href="https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)">spacing</a> is passed from the grid&#39;s <a href="https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/Arrangement.Horizontal">Arrangement.Horizontal</a>. The <a href="https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/Arrangement.Horizontal">Arrangement.Horizontal</a> will also be used to arrange items in a row if the grid is wider than the calculated sum of columns.</blockquote><blockquote>Note that the calculated cross axis sizes will be considered in an RTL-aware manner — if the grid is vertical and the layout direction is RTL, the first width in the returned list will correspond to the rightmost column.</blockquote><p><a href="https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)">https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)</a></p><p><em>GridCells.Fixed</em>の実装はitemの幅が均等になるように計算されるため、<em>GridCells.Fixed</em>を使ったアプローチでは実現できない。<br>だが、<em>calculateCrossAxisCellSizes</em>を実装することでitemの幅の計算方法を変えることができそうである。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2857398a1d922bcf9754f210c5affbb/href">https://medium.com/media/d2857398a1d922bcf9754f210c5affbb/href</a></iframe><p><em>Spacer</em>部分のindexの時には<em>Spacer</em>幅を指定し、その他のindexの時には均等幅になるようにする。</p><p>ちなみに、<strong><em>calculateCrossAxisCellSizes</em>で返すitem幅のListの値の合計が<em>LazyVerticalGrid</em>の幅に満たない場合</strong>は、行の最後に満たない分のスペースができる。<br>行全体を真ん中寄せにするなど、いい感じに残りの部分のスペースの挙動を<em>Arrangement</em>で指定できるといいが、今のところできない。<br>詳しくは、issue trackerに書いている。<br><a href="https://issuetracker.google.com/issues/235121277">https://issuetracker.google.com/issues/235121277</a></p><p>利用する側では、<em>Spacer</em>分を除いたitemの数と<em>Spacer</em>の幅を指定するようにしてみた。<br>最終的には次のような形になった。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/718e6280a79fef082c805e610ea8bf3c/href">https://medium.com/media/718e6280a79fef082c805e610ea8bf3c/href</a></iframe><p>利用する側で可能な限りSpacerのitemに対する関心を分離したいため、<em>LazyGridScope.itemsWithEdgeSpace</em>を定義している。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L7yky6Au4JoahR5CePWJ3Q.png" /><figcaption>🎉</figcaption></figure><p>ただし、これだと<em>Spacer</em>用のitemを追加しないといけなく、見た目のspanと実装のspanの数に乖離が生まれてしまう。</p><p>見た目のspanと実装のspanを同じにしたまま実現するには、GridのItemにpaddingを設定して調整することができる。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97f7c00431933ab76915ac3c0ad0b78e/href">https://medium.com/media/97f7c00431933ab76915ac3c0ad0b78e/href</a></iframe><h3>2. LazyColumnの中にRowを配置する</h3><p>LazyColumnの中に1行ずつRowを配置して、Gridに見せるアプローチ。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/833ffaa6c70804580c5344602bfab388/href">https://medium.com/media/833ffaa6c70804580c5344602bfab388/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ra8KhcP8aCYIovrOyadzQA.png" /><figcaption>🎉</figcaption></figure><h3>3. LazyColumnの中にFlowRowを配置する</h3><p>2のアプローチに近いが、1行ずつRowを配置するのではなく、<a href="https://github.com/google/accompanist">accompanist</a>で提供されているFlowRowを使って、Grid部分をまとめて配置するアプローチ。</p><p><a href="https://google.github.io/accompanist/flowlayout/">Guide - Accompanist</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25e5305b4f8ffad8a9dc576d1fa0ca4c/href">https://medium.com/media/25e5305b4f8ffad8a9dc576d1fa0ca4c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jXVlkBAq0wYp-Jdj-S1DaQ.png" /><figcaption>🎉</figcaption></figure><h3>どのアプローチがよさそうか</h3><p>3つのアプローチのメリットとデメリットを検討してみる。</p><h4><strong>1. </strong>GridCellsを実装して各itemのサイズを調整する</h4><p><strong>■ メリット</strong><br>・各itemに<em>contentType</em>や<em>key</em>の指定ができるため、LazyListのメリットを享受しやすい<br>・<em>calculateCrossAxisCellSizes</em>が<em>Density</em>の拡張関数なので、px値でitemのサイズを計算しやすい</p><p><strong>■ デメリット</strong><br>・もし別のpaddingのサイズのGridをさらに配置したいとなると実現が難しそう</p><h4><strong>2. <em>LazyColumn</em>の中に<em>Row</em>を配置する</strong></h4><p><strong>■ メリット<br></strong>・<em>Spacer</em>のitemを配置しなくていい<br>・spanやpaddingの異なるGridを複数配置したいなど、より複雑なレイアウトも実現しやすい</p><p><strong>■ デメリット<br></strong>・各<em>Row</em>ごとにしか<em>contentType</em>や<em>key</em>の指定ができない</p><h4><strong><em>3. LazyColumn</em>の中に<em>FlowRow</em>を配置する</strong></h4><p><strong>■ メリット<br></strong>・<em>Spacer</em>のitemを配置しなくていい<br>・他のアプローチと比べて実装はシンプル<br>・spanやpaddingの異なるGridを複数配置したいなど、より複雑なレイアウトも実現しやすい</p><p><strong>■ デメリット<br></strong>・LazyListでなく、Grid部分を一気に配置してしまうため、itemの数が多くなるとパフォーマンスに影響が出るかもしれない</p><p>ちなみに、2と3のアプローチで示した実装例では、itemの幅を<em>Dp</em>で計算しているが、より正確に表現するためには、px値に直して計算するのがいいだろう。</p><p>より柔軟なGridを作成できるAPIができますように🙏</p><h3>おまけ (ボツになったアプローチ)</h3><h4>LazyColumnにLazyVerticalGridをネストさせる</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a598938eb1e8675b253651a1f264a58/href">https://medium.com/media/8a598938eb1e8675b253651a1f264a58/href</a></iframe><p><em>LazyVerticalGrid</em>は<em>Constraint.maxHeight</em>が<em>Constraints.Infinity</em>になるため、<em>LazyVerticalGrid</em>の高さを固定値にできない限り、例外が発生してしまう。</p><pre>java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll()). If you want to add a header before the list of items please add a header as a separate item() before the main items() inside the LazyColumn scope. There are could be other reasons for this to happen: your ComposeView was added into a LinearLayout with some weight, you applied Modifier.wrapContentSize(unbounded = true) or wrote a custom layout. Please try to remove the source of infinite constraints in the hierarchy above the scrolling container.<br>	at androidx.compose.foundation.ScrollKt.assertNotNestingScrollableContainers-K40F9xA(Scroll.kt:378)<br>	at androidx.compose.foundation.lazy.grid.LazyGridKt$rememberLazyGridMeasurePolicy$1$1.invoke-0kLqBqw(LazyGrid.kt:190)<br>	at androidx.compose.foundation.lazy.grid.LazyGridKt$rememberLazyGridMeasurePolicy$1$1.invoke(LazyGrid.kt:189)<br>	at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$2$1.invoke-0kLqBqw(LazyLayout.kt:74)<br>	at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$2$1.invoke(LazyLayout.kt:70)<br>...</pre><p>ドキュメントやGoogle IOでもアンチパターンとして紹介されている。</p><p><a href="https://developer.android.com/jetpack/compose/lists?hl=ja#lazy-layouts-tips">https://developer.android.com/jetpack/compose/lists?hl=ja#lazy-layouts-tips</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F1ANt65eoNhQ%3Fstart%3D897%26feature%3Doembed%26start%3D897&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D1ANt65eoNhQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F1ANt65eoNhQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e91de6beb4fa14bd3a221c1b5c5834dd/href">https://medium.com/media/e91de6beb4fa14bd3a221c1b5c5834dd/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a41fecf144e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GradleでAndroid StudioとIntelliJ IDEAを区別する]]></title>
            <link>https://medium.com/@ronnnnn_jp/gradle%E3%81%A7android-studio%E3%81%A8intellij-idea%E3%82%92%E5%8C%BA%E5%88%A5%E3%81%99%E3%82%8B-4ffbce54c11c?source=rss-820806221f80------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ffbce54c11c</guid>
            <category><![CDATA[intellij]]></category>
            <category><![CDATA[gradle-plugin]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Seiya Kokushi]]></dc:creator>
            <pubDate>Sun, 22 May 2022 14:55:48 GMT</pubDate>
            <atom:updated>2022-05-22T14:55:48.242Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x8x19AlSDpQ7iS4y" /><figcaption>Photo by <a href="https://unsplash.com/@jordanheinrichs?utm_source=medium&amp;utm_medium=referral">Jordan Heinrichs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>TL;DL</h3><pre>System.getProperty(&quot;idea.paths.selector&quot;)<br>// Android Studio Chipmunk | 2021.2.1 -&gt; AndroidStudio2021.2<br>// IntelliJ IDEA 2022.1.1 (Ultimate Edition) -&gt; IntelliJIdea2022.1<br>// IntelliJ IDEA 2022.1.1 (Community Edition) -&gt; IdeaIC2022.1</pre><p>もしくは、</p><pre>System.getProperty(&quot;idea.platform.prefix&quot;)<br>// Android Studio Chipmunk | 2021.2.1 -&gt; AndroidStudio<br>// IntelliJ IDEA 2022.1.1 (Ultimate Edition) -&gt; null<br>// IntelliJ IDEA 2022.1.1 (Community Edition) -&gt; Idea</pre><p>で判定することができる。</p><h3>モチベーション</h3><p><a href="https://medium.com/yazio-engineering/speeding-up-kotlin-multiplatform-61ebf8dae560">Speeding up Kotlin Multiplatform</a></p><p>こちらの記事や<a href="https://www.reddit.com/r/androiddev/comments/ut3g5p/speeding_up_kotlin_multiplatform/?utm_source=share&amp;utm_medium=web2x&amp;context=3">Redditの反応</a>を読んでいて、Kotlin Multiplatformの開発にはIntelliJ IDEAを使用するのは確かにいいかもしれないが、最新のAndroid Gradle Pluginの機能を使いたいこともありそうだよなあと感じた。</p><p>ちなみに、IntelliJ IDEAのAndroid pluginのアップデートはAndroid Studioの正式リリースから結構遅れてリリースされる傾向にある。<br><a href="https://youtrack.jetbrains.com/issue/IDEA-288735/This-version-of-the-Android-Support-plugin-for-IntelliJ-IDEA-or-">https://youtrack.jetbrains.com/issue/IDEA-288735</a></p><p>最新のIntelliJ IDEA 2022.1.1は、Android Studio Bumblebeeのバージョンも未対応である。</p><p>そこで、プロジェクトを開くIDEによって、Gradleの設定を動的に変更できればよさそうと思い、調べてみた。</p><h3>調査</h3><p>まず、”detect intellij android studio” で検索してみると、次のstack overflowがヒットする。</p><p><a href="https://stackoverflow.com/a/68997727">Is there a way to programmatically distinguish between IntelliJ IDEA and Android Studio</a></p><p>どうやら、</p><pre>System.getProperty(&quot;idea.paths.selector&quot;)</pre><p>もしくは、</p><pre>System.getProperty(&quot;idea.platform.prefix&quot;)</pre><p>で判定することができるらしい。</p><p>でも、このプロパティはどこから取ってきているのだろう。しかも、この回答は1年近く前のものだし、今も使えるのか分からない。</p><p><a href="https://github.com/JetBrains/gradle-intellij-plugin">JetBrains/gradle-intellij-plugin</a>にヒントがあるかもと思い、”idea.platform.prefix” で検索してみると、<em>RunIdeBase.kt</em>がヒットした。</p><p><a href="https://github.com/JetBrains/gradle-intellij-plugin/blob/6512f50bfbcdbc2de1f9b8a45cfb487b93f50174/src/main/kotlin/org/jetbrains/intellij/tasks/RunIdeBase.kt#L165">gradle-intellij-plugin/RunIdeBase.kt at 6512f50bfbcdbc2de1f9b8a45cfb487b93f50174 · JetBrains/gradle-intellij-plugin</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b9ff0b4822e01300c6c99a0a240ce6b/href">https://medium.com/media/5b9ff0b4822e01300c6c99a0a240ce6b/href</a></iframe><p><em>findIdePrefix()</em>という関数で、<em>idea.platform.prefix</em>の値を取ってきているらしい。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f6dabb01345cb7288cf2bb8abb439f8/href">https://medium.com/media/0f6dabb01345cb7288cf2bb8abb439f8/href</a></iframe><p>Macの場合は、IDEのアプリケーションのディレクトリ内の<em>Info.plist</em>から取ってきているようだ。</p><p><em>各IDEのアプリケーションのパス/Contents/Info.plist</em>は、次のようになっていた。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68513a918c3ffeaaa3c67bcd755f06ac/href">https://medium.com/media/68513a918c3ffeaaa3c67bcd755f06ac/href</a></iframe><p>IntelliJ IDEA Ultimate Editionには<em>idea.platform.prefix</em>がない。<em>RunIdeBase.kt</em>を追ってみると、IntelliJ IDEA Ultimate Editionの場合だけ例外的にExceptionをthrowしないようになっているようだ。</p><h3>まとめ</h3><p>Android StudioとIntelliJ IDEAをgradleのスクリプトで区別するには、</p><pre>System.getProperty(&quot;idea.paths.selector&quot;)<br>// Android Studio Chipmunk | 2021.2.1 -&gt; AndroidStudio2021.2<br>// IntelliJ IDEA 2022.1.1 (Ultimate Edition) -&gt; IntelliJIdea2022.1<br>// IntelliJ IDEA 2022.1.1 (Community Edition) -&gt; IdeaIC2022.1</pre><p>もしくは、</p><pre>System.getProperty(&quot;idea.platform.prefix&quot;)<br>// Android Studio Chipmunk | 2021.2.1 -&gt; AndroidStudio<br>// IntelliJ IDEA 2022.1.1 (Ultimate Edition) -&gt; null<br>// IntelliJ IDEA 2022.1.1 (Community Edition) -&gt; Idea</pre><p>で判定することができる。</p><p>プロパティの値は、<em>IDEのアプリケーションのパス/Contents/Info.plist</em>に記載されている。</p><h3>おまけ(Info.plistについて)</h3><p><a href="https://developer.apple.com/documentation/bundleresources/information_property_list">Apple Developer Documentation</a></p><p>Appleのアプリケーションで使われるプロパティのリストファイル。置き場所はbundleの種別とプラットフォームによって変わる。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ffbce54c11c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[スカラシッププログラムを利用してDroidKaigi 2018に参加してきた]]></title>
            <link>https://medium.com/@ronnnnn_jp/%E3%82%B9%E3%82%AB%E3%83%A9%E3%82%B7%E3%83%83%E3%83%97%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%82%92%E5%88%A9%E7%94%A8%E3%81%97%E3%81%A6droidkaigi-2018%E3%81%AB%E5%8F%82%E5%8A%A0%E3%81%97%E3%81%A6%E3%81%8D%E3%81%9F-c9e635e9276?source=rss-820806221f80------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9e635e9276</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[droidkaigi]]></category>
            <dc:creator><![CDATA[Seiya Kokushi]]></dc:creator>
            <pubDate>Sun, 18 Feb 2018 11:38:02 GMT</pubDate>
            <atom:updated>2018-02-18T11:38:02.663Z</atom:updated>
            <content:encoded><![CDATA[<h3>はじめに</h3><p>本記事では、先日2月8–9日に開催されたDroidKaigi 2018に、スカラシッププログラムを利用して参加した感想などを書いていきます。</p><h3>DroidKaigiとは？</h3><p>まず、DroidKaigiとは何ぞやという方のために、<a href="https://droidkaigi.jp/2018/">公式HP</a>の言葉を引用して紹介させていただきます。</p><blockquote>DroidKaigiはエンジニアが主役のAndroidカンファレンスです。<br>Android技術情報の共有とコミュニケーションを目的に、2018年2月8日(木)、9日(金)の2日間開催します。<br>今回は「ニッチな技術とコミュニケーション」を重視する予定です。</blockquote><p>もう少し補足しますと、DroidKaigiは2015年から年に一回のペースで開催されている、Android技術情報共有とAndroidエンジニア同士のコミュニケーションを目的としたカンファレンスです。<br>主に、セッション発表をベースとしたカンファレンスとなっており、参加者は事前に公開されているタイムテーブルを基に、自分の聞きたいセッションを自由に聞きに行けるスタイルになっています。</p><h3>スカラシッププログラムとは？</h3><p>スカラシッププログラムは、今年のDroidKaigiから始められた取り組みの一つであり、学生にとっては大変嬉しいプログラムとなっています。<br>このプログラムを簡単に説明すると、学生であればDroidKaigi参加にかかる費用をWantedly株式会社様が協賛となって、補助してもらえるというものです。ただし、学生であれば誰でも補助するよという訳ではなく、簡単な選考がありました。<br>スカラシッププログラムに関する詳しい内容は、以下のページをご覧ください。</p><p><a href="https://medium.com/droidkaigi/scholarship-program-2a44e404124">スカラーシッププログラムの案内</a></p><p>大変ありがたいことに、僕もスカラシッププログラム対象者として選出していただいたので、無料でDroidKaigiに参加することが出来ました！</p><p>それでは、この後はDroidKaigi 2018の様子を振り返ってみようと思います。</p><h3>ウェルカムトーク</h3><p>今年はDroidKaigi代表の日高(<a href="https://twitter.com/mhidaka">mhidaka</a>)さんによるウェルカムトークが会場内のイベントホールで行われました。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jh2oxVRGuN4lKGDMdzmzIQ.jpeg" /><figcaption>ウェルカムトーク前の会場スクリーン</figcaption></figure><p>ウェルカムトークでは、DroidKaigi2018の様々な情報の提供や、DroidKaigi参加における諸注意などがありました。<br>発表された内容を下に簡単にまとめます。</p><p>・技術共有とコミュニケーションが目的<br>・DroidKaigiは2015年から始まり、今回で4回目<br>・全セッションYouTubeで後日公開<br>・様々な企業スポンサーに支えられている(飲食、電源、Wi-Fi提供等)<br>・DroidKaigi 2018 Official Applicationを作成<br>・初心者大歓迎(新しい技術にチャレンジしてほしい)</p><p>今回で4回目の開催となるDroidKaigiは、これまでで最大規模の開催となったようです。参加者数は1000人以上で、セッション数も85とかなり多い印象を受けました。</p><p>DroidKaigi 2018 Official Applicationは、<a href="https://twitter.com/new_runnable">takahiromさん</a>が中心となってオープンソースで開発されました。</p><p><a href="https://github.com/DroidKaigi/conference-app-2018">DroidKaigi/conference-app-2018</a></p><p>ウェルカムトークの時点で、Pull Request数は413、issue数は235、contributor数は133でした。この情報から、短期間にも関わらず、多くの人が開発に携わり、repository上で多くのやりとりが行われたことが分かります。<br>実際に僕も簡単なPRを2つほど投げて、マージしていただけました！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mimvvx7MXm6KRctIyuWAoQ.jpeg" /><figcaption>公式アプリのcontributorsの一部 (僕もいるぞー！わーい🎉)</figcaption></figure><p>また、この公式アプリには、<strong>Android開発における最先端の技術がふんだんに盛り込まれています</strong>。Android開発者にとっては、是非とも押さえておきたい技術ばかりなので、ソースコードを読み漁ってみることを強くオススメします！<br>公式アプリがオープンソースで開発されたことで、Androidエンジニア同士の技術共有がコードベースで行われて、これは非常にいい取り組みだなあと感じました。<br>今年contributeできなかったーという方は、来年はcontributeしてみましょう！</p><p>そして、ウェルカムトークの最後には、日本Kotlinユーザーグループ代表であり、Kotlinエバンジェリストのたろう(<a href="https://twitter.com/ngsw_taro">ngsw_taro</a>)さんから重大発表がありました。<br>それは、近年広く普及しているJVM言語のKotlinのカンファレンスである、<strong>Kotlin Confが日本で今年開催される！！</strong>という内容でした。<br>この発表には会場も大きく盛り上がりました。開催日時などの詳細はまだ決まっていないとのことでしたが、開催が非常に楽しみです。</p><h3>セッション</h3><p>DroidKaigiの醍醐味は何と言っても、セッションです。<br>セッションは事前公募により選出された人が登壇者として発表します。セッション内容は人によって様々ですが、今回のDroidKaigiは”ニッチな技術”がテーマになっていることもあり、そういったセッションが多く採択されている印象を受けました。<br>各セッションのタイムテーブルは以下をご覧ください。</p><p><a href="https://droidkaigi.jp/2018/timetable/">タイムテーブル | DroidKaigi 2018</a></p><p>同時刻に様々なセッションが発表されるので、どのセッションを聞きに行くか非常に迷います。今回僕は、<strong>”使ったことある技術だけど、きちんと理解できていないものや、まだ使ったことのない技術”</strong>を扱うセッションを中心に聞きました。</p><p>僕が聞いたセッションの情報と簡単な感想などをまとめておきます。</p><h4>Kotlinアンチパターン (<a href="https://twitter.com/oxsoft">oxsoftさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2FETn6cTgeA4Fz3M&amp;url=https%3A%2F%2Fwww.slideshare.net%2FRecruitLifestyle%2Fkotlin-87339759&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2Fkotlin-180206231140-thumbnail-4.jpg%3Fcb%3D1517958798&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea5fae2d845febae29ff3c0bc5a095b1/href">https://medium.com/media/ea5fae2d845febae29ff3c0bc5a095b1/href</a></iframe><p>Kotlinを業務で利用してみて、実際に直面した問題やその解決策が発表されました。実務で直面しやすい問題を中心に取り上げてくださっていたので、実践的で非常に有用な情報ばかりでした。また、コードベースで説明をしてくださったので、非常に理解しやすかったです。</p><h4>Inside Architecture Components (<a href="https://twitter.com/moridroid">moridroidさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2Fdda33180ee3f4cd4be702afdb7c14d6a&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fkobitokaba%2Finside-architecture-components&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2Fdda33180ee3f4cd4be702afdb7c14d6a%2Fslide_0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="463" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd115ab07094174cee8937bfc53b89e4/href">https://medium.com/media/dd115ab07094174cee8937bfc53b89e4/href</a></iframe><p>LifecycleやLiveData、ViewModelの話を中心にAndroid Architecture Componentsの仕組みを解説して下さいました。各技術がどういったものかというだけでなく、各技術がどのようにして実現されているかを説明されていたので、Android Architecture Componentsへの理解が深まりました。クラス関係などを図でまとめて下さっていたので、非常に分かりやすかったです。</p><h4>AndroidにおけるModel-View-Intentアーキテクチャ (<a href="https://twitter.com/oldergod">oldergodさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F5f72cbf29417498aa87dd27b0d31fe94&amp;url=https%3A%2F%2Fspeakerdeck.com%2Foldergod%2Fandroid-niokeru-model-view-intent-akitekutiya&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F5f72cbf29417498aa87dd27b0d31fe94%2Fslide_0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="463" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc17e8f86f8708a135e10ba7df26de6d/href">https://medium.com/media/bc17e8f86f8708a135e10ba7df26de6d/href</a></iframe><p>MVIに関しては、僕も耳にしたことがあり、興味のあるアーキテクチャだったので、このセッションを聞けてよかったです。コードの説明だけでなく、MVIの概念を各層ごとに図を用いて説明して下さったので、非常に分かりやすかったです。MVI自体はデータの流れがかなりシンプルになるのがいい反面、クラス数が多くなりがちなので、簡単なアプリケーションには向かないのかなあという印象を受けました。</p><h4>DataBindingのコードを読む (<a href="https://twitter.com/STAR_ZERO">STAR_ZEROさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2Fc03a04f1456d48b2844239d15b343297&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fstar_zero%2Fdatabindingfalsekodowodu-mu-droidkaigi-2018&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2Fc03a04f1456d48b2844239d15b343297%2Fslide_0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/92c99d1fb358fef8e60b5c31b7d5a200/href">https://medium.com/media/92c99d1fb358fef8e60b5c31b7d5a200/href</a></iframe><p>DataBindingは僕も利用する機会が多いのですが、詳しい仕組みなどを知らなかったので、新しい知識を多く吸収できた発表でした。特に、印象に残ったのはDataBindingのadapterパッケージ内にBindingAdapterがあらかじめいくつか用意されているということでした。これは全く知らなかったので、今後BindingAdapterを作成するときは気をつけようと思いました。</p><h4>まだAPI定義管理で消耗してるの？〜Swaggerを用いた大規模アプリ時代のAPI定義管理とコードジェネレート〜 (<a href="https://twitter.com/magie_pooh">magiepoohさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F88d7e9cac0464ca48bbce4bfc05702ac&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fmagiepooh%2Fmadaapiding-yi-guan-li-dexiao-hao-siterufalse-swaggerwoyong-itada-gui-mo-apurishi-dai-falseapiding-yi-guan-li-tokodozienereto&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F88d7e9cac0464ca48bbce4bfc05702ac%2Fslide_0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc4a494da6bbaf5b415d181ddce6bd82/href">https://medium.com/media/cc4a494da6bbaf5b415d181ddce6bd82/href</a></iframe><p>Swaggerを用いて、API定義を管理したり、コードの生成までやってしまおうという内容でした。APIドキュメントを見ながらAPI定義のクラスを作成すると、ドキュメントの間違いやコード側の間違いなど様々な要因から不整合がおきがちですが、それをSwaggerを用いて解決できるのはいい知見になりました。コード生成におけるKotlin対応がイマイチな部分が惜しい！という感じでしたが、ぜひ使ってみたいなあと思いました。</p><h4>実例で理解するMaterial Design Animation (<a href="https://twitter.com/wakwak3125">wakwak3125さん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F3db19ab7c24c49d79b0421ec4640c36e&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fwakwak3125%2Fshi-li-deli-jie-suru-material-design-animation&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F3db19ab7c24c49d79b0421ec4640c36e%2Fslide_0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/5984d9dc10d4f6e5f84d9ab90e9ac9e8/href">https://medium.com/media/5984d9dc10d4f6e5f84d9ab90e9ac9e8/href</a></iframe><p>Material Design Animationを実装する上での知見を多く得られたセッションでした。実際のアプリケーションでの挙動と合わせて説明して下さったので、理解しやすく、見ているだけでも楽しいセッションでした。Material Design Animationを実装するのはなかなか一筋縄でいかない場合が多いので、参考になる情報ばかりでした。</p><h4>マルチモジュールのすヽめ (<a href="https://twitter.com/kgmyshin">kgmyshinさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F0982b3f104e447fa83d2753f3c9ab245&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fkgmyshin%2Fmulti-module-no-susume&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F0982b3f104e447fa83d2753f3c9ab245%2Fslide_0.jpg%3F427420&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="532" frameborder="0" scrolling="no"><a href="https://medium.com/media/3abdbba9dde9bf0076ec85796b349ecd/href">https://medium.com/media/3abdbba9dde9bf0076ec85796b349ecd/href</a></iframe><p>Androidアプリをマルチモジュールで実装する利点やどういったまとまりでモジュールを分けるといいかなどを説明されたセッションでした。Instant Appsではモジュールを分けなければいけないなど、マルチモジュール化の波がAndroid界隈に来ていますが、モジュールをどういった基準で分けるか悩む場合が多いので、いい知見を得られました。個人的にはsetting.gradleを利用して、moduleを一つのフォルダにまとめることができるということが一番の収穫でした。</p><h4>Kotlin Backstage (<a href="https://twitter.com/sir_tilbrook">sir_tilbrookさん</a>)</h4><p>Kotlinを利用する際に、Javaコードはどのようになるかを中心にして、Kotlinの裏側やKotlinに関するTipsを発表して下さいました。<br>発表が英語だったのと、スライドを共有されておらず、なかなか全てをキャッチアップできなかったのが、悔しいです。英語力つけなきゃ！</p><h4>既存アプリへのInstantApps導入 (<a href="https://twitter.com/_a_akira">_a_akiraさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F3f3681d06ccf40f88bd16ec7bd96eddf&amp;url=https%3A%2F%2Fspeakerdeck.com%2Faakira%2Fintroduceinstantapps-droidkaigi2018&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F3f3681d06ccf40f88bd16ec7bd96eddf%2Fslide_0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/9708ec68d0b86a82ba40623c866a6fcd/href">https://medium.com/media/9708ec68d0b86a82ba40623c866a6fcd/href</a></iframe><p>既存アプリにInstant Appsを導入する際のTipsをまとめた発表でした。Instant Appsの導入をやったことがなかったので、新しい知識ばかりしたが、説明が非常に丁寧で理解しやすかったです。特にmodule間の画面遷移はAppLinksを利用するという知見が印象的でした。</p><h4>How Android Rendering Works to Provide Pixels on the Screen Faster than You Can Read this Sentence (<a href="https://twitter.com/romainguy">romainguyさん</a>、<a href="https://twitter.com/chethaase">chethaaseさん</a>)</h4><p>なんと、Googlerのお二人による、豪華なセッションでした。AndroidのAPIをどう利用するかというお話ではなく、Android上でユーザに画面が表示されるまでにどのようなことが起こっているかを話して下さいました。Androidの裏側の仕組みを知る機会というのはなかなかないので、このセッションを聞けてよかったです。</p><h4>Dagger2を活用してAndroid SDKの依存関係をクリーンにする (<a href="https://twitter.com/kr9ly">kr9lyさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F3069141940ee4c8aafbe2cf38fb48e91&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fkr9ly%2Fdagger2wohuo-yong-siteandroid-sdkfalseyi-cun-guan-xi-wokurinnisuru&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F3069141940ee4c8aafbe2cf38fb48e91%2Fslide_0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/8761af54cfd251e6756c58bc9751f00b/href">https://medium.com/media/8761af54cfd251e6756c58bc9751f00b/href</a></iframe><p>タイトルのまんまになってしまいますが、Dagger2を活用してAndroid SDKの依存関係をクリーンにするという発表でした。この発表で特に印象に残ったのは、Android Architecture ComponentsのLifecycleにもDIを使うと、ViewModelでのライフサイクルイベントのハンドリングがいい感じにかけるというものでした。<br>Dagger2を利用すると、クラス間の依存を無くし、テストが書きやすくなったり、クラス間の依存を無くすためのboiler plateなコードを書く必要がなくなったりします。Dagger2をきちんと理解しようとするとかなり学習にコストがかかり、とっつきにくい技術という印象を持たれがちですが、Dagger2を使いこなせるようになると先で述べたように利点が多いです。僕もまだまだDagger2の全てを使いこなせているわけではないので、きちんと理解してDagger2の利点を最大限に活かせるようになりたいと改めて思えた発表でした！</p><h4>すばらしきGraphQLのSEKAIへようこそ (<a href="https://twitter.com/__gfx__">__gfx__さん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2F307a4755046e4e14965084d29c45593f&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fgfx%2Fsubarasikigraphqlfalsesekaiheyoukoso&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2F307a4755046e4e14965084d29c45593f%2Fslide_0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa7f32985eeedde31396b84d9ec63712/href">https://medium.com/media/aa7f32985eeedde31396b84d9ec63712/href</a></iframe><p>GraphQLを利用して、APIとデータ構造の定義を行い、コードの生成までやってしまおうという発表内容でした。Swaggerのセッションと近い内容ですが、用いている技術は全く違います。GraphQLはFacebook社が開発しており、GitHub社でも実際に利用されていることから、近年注目の集まっている技術です。リソース取得に特化したWeb APIが作成できるというのは好印象でした。まだ使ったことのない技術なので、ぜひチャレンジしてみたいなあと思いました。</p><h4>ConstraintLayout, now and future (<a href="https://twitter.com/thagikura">thagikuraさん</a>、<a href="https://twitter.com/camaelon">camaelonさん</a>、<a href="https://twitter.com/johnhoford">johnhofordさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2FbCYG0bb2J7WH9e&amp;url=https%3A%2F%2Fwww.slideshare.net%2Fhagikuratakeshi%2Fconstraintlayout-now-and-future&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2Fconstraintlayoutnowandfuture-180212105737-thumbnail-4.jpg%3Fcb%3D1518433873&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/fcdaba28a485bf63d8202f3725fff183/href">https://medium.com/media/fcdaba28a485bf63d8202f3725fff183/href</a></iframe><p>こちらはGooglerのお3方による、ConstraintLayoutに関するセッションでした。ConstraintLayoutをあまり使ったことがなかったので、色々なことができることを知れて非常に有益なセッションでした。特に、Constraint SetとTransition Managerを利用してレイアウトを動的に変更できることが印象に残りました。ConstraintLayoutを利用すると、より柔軟にレイアウトを作成できることが知れたので、これからは積極的に利用していこうと思えました！</p><h4>HTTPS通信の基本からNetwork Security Configurationまで (<a href="https://twitter.com/a2kaido">a2kaidoさん</a>)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2Fbe4c1d60d20c453c95984256927c6e06&amp;url=https%3A%2F%2Fspeakerdeck.com%2Fa2kaido%2Fhttpsfalseji-ben-kara-networksecurityconfigmade&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2Fbe4c1d60d20c453c95984256927c6e06%2Fslide_0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="596" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f6f0852c27f728f5ed08ca74c2e16de/href">https://medium.com/media/2f6f0852c27f728f5ed08ca74c2e16de/href</a></iframe><p>通信セキュリティの基本知識から、Androidでは通信セキュリティ対策をどう行なっていけばよいかまで、丁寧に説明してくださり、非常に理解しやすいセッションでした。通信周りはライブラリに処理を任せっぱなしになりがちで、通信セキュリティまで意識がなかなか向きにくいですが、このセッションを聞いて改めて通信セキュリティの大切さを実感できました。これからはセキュリティ対策にももっと気をつけようと思います。</p><p>以上が今回僕が聞いたセッションになります。<br>どのセッションも本当に素晴らしく、みなさんかなり準備をされて発表に挑まれているんだなあという印象を受けました。<br>聞きたかったけど聞けなかったセッションがいくつもあるので、動画が配信されたらチェックしてみようと思います！</p><h3>おまけ</h3><h4>オープニング</h4><p>実はウェルカムトークの前に、めちゃくちゃかっこいいオープニングムービーが流されたのですが、それが共有されていたので、こちらにも掲載しておきます！</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F2y4URgBHS24%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2y4URgBHS24&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2y4URgBHS24%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/392642dc5c5abae3b0410e464e39d02e/href">https://medium.com/media/392642dc5c5abae3b0410e464e39d02e/href</a></iframe><h4>おみやげなど</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MpfoWzHJ4DwvPYL7lJ_qKQ.jpeg" /><figcaption>参加者全員に配られたストラップとおみやげ</figcaption></figure><p>受付の際にDroidKaigi参加者全員に、参加証のストラップとおみやげが配布されました。参加証かわいいですよね。家宝にします。<br>おみやげとして渡されたトートバックには、DroidKaigiのパンフレットやスポンサー企業さんのパンフレット、ステッカーなどが入っていました。</p><h4>ランチ</h4><h3>DroidKaigi on Twitter</h3><p>今日のランチ #DroidKaigi</p><p>ランチは2日間とも洋食と和食を選べました。<br>両方食べましたが、どっちも美味しかった〜！！</p><h4>アフターパーティー</h4><h3>DroidKaigi on Twitter</h3><p>Party night!</p><p>1日目の全セッション終了後、アフターパーティーが開かれました。<br>会場には食べ物や飲み物だけでなく、ゲームコーナーもあり、エンジニア同士がコミュニケーションを取りやすくする工夫がいくつも見られました。</p><h3>DroidKaigi on Twitter</h3><p>！？</p><p>登壇者には風船をつけていただき、登壇者であることが一目で分かる工夫もされていました。<br>コミュニケーションを促進するための取り組みが数多く見られて、DroidKaigiのホスピタリティの高さを感じました！運営の方々本当にすごいなあ。</p><h4>オフィスアワー</h4><h3>DroidKaigi on Twitter</h3><p>オフィス・アワー</p><p>各セッションの後には、登壇者の方がオフィスアワーをしてくださる時間が設けられていました。発表を聞いて分からなかった部分や、自分のプロダクトで実際に直面している問題などを登壇者の方に相談できる機会が設けられているのは非常に嬉しいですね。</p><h4>スポンサーブース</h4><h3>DroidKaigi on Twitter</h3><p>ゴールドスポンサーのサイバーエージェント様です。開発に利用されているKotlinの拡張関数を、本日に限り公開中ですよ！今後はカンファレンス限定でソースコード見せるブースが増えてくかもですね！</p><h3>DroidKaigi on Twitter</h3><p>プラチナスポンサーのメルカリ様のブースです！アンケートからトレンドを確認しよう！Kotlinチートシートもあるぞ！これはDroidKaigi限定品らしいぞ〜！</p><p>スポンサーブースでは、スポンサーである各企業さんがブースを設けて、各社のアピールやおみやげの配布などを行なっていました。<br>企業ごとに色々な展示をしていて、見て回っているだけでも楽しめました。</p><h3>DroidKaigi on Twitter</h3><p>たーのしー！ #droidkaigi</p><p>また、同じ部屋では軽食やコーヒーの配布などがされていたり、記念撮影スポットが設けられていたりしました。<br>このようにセッション以外の部分でも楽しめる部分がたくさんあるのは、本当に素晴らしい取り組みですよね！</p><h3>おわりに</h3><p>DroidKaigi 2018の様子をまとめましたが、ほんの一部しか伝えることができていないので、ぜひTwitterで<a href="https://twitter.com/hashtag/droidkaigi?src=hash">#droidkaigi</a>を検索してみてください！！参加者のみなさんが色々な情報を当日に発信していたり、DroidKaigi終了後にも参加レポートを書かれているもたくさんいらっしゃいます。</p><p>最後になりますが、スカラシッププログラムを提供してくださったDroidKaigi様、Wantedly株式会社様、本当にありがとうございました。学生ながらもDroidKaigiに参加させて頂いたことで、最先端の技術に触れる機会ができ、Androidアプリ開発の目線がグッと引き上がりました。このスカラシッププログラムは今後のAndroidエンジニア育成にも大きく貢献すると思うので、ぜひ次回以降も続けていってほしいです！！</p><p>実は去年のDroidKaigiにも参加をしたのですが、去年に比べて規模が大きくなったにも関わらず、皆が快適にDroidKaigiを楽しめるよう、様々なところでDroidKaigi運営スタッフによる取り組みや工夫がみられて、本当にすばらしい運営チームだなあと感じる場面が多くありました。来年のDroidKaigiも楽しみ！！！<br>DroidKaigiスタッフの皆さま、スピーカーの皆さま、スポンサー企業の皆さま、そしてDroidKaigiに参加した皆さま、お疲れ様でした！</p><p>来年は登壇できるように頑張るぞー💪</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9e635e9276" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>