<?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 heri sulistiyanto on Medium]]></title>
        <description><![CDATA[Stories by heri sulistiyanto on Medium]]></description>
        <link>https://medium.com/@herisulis?source=rss-218d8f355bf3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gFTkZ7CItJGAWMgjVSlgyg.jpeg</url>
            <title>Stories by heri sulistiyanto on Medium</title>
            <link>https://medium.com/@herisulis?source=rss-218d8f355bf3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:04:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@herisulis/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[Inspect and Mock Flutter HTTP Traffic in Real Time — Using VSCode Extension]]></title>
            <link>https://herisulis.medium.com/inspect-and-mock-flutter-http-traffic-in-real-time-using-vscode-extension-711f46579098?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/711f46579098</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[productivity-tools]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Wed, 15 Apr 2026 16:17:57 GMT</pubDate>
            <atom:updated>2026-04-15T16:17:57.783Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oPpv9iiItXXi9TwE" /><figcaption>Photo by <a href="https://unsplash.com/@emilep?utm_source=medium&amp;utm_medium=referral">Emile Perron</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When building a Flutter app, there comes a moment where you need to test how your app behaves when the server returns an error, an empty list, or some edge-case response. The usual options are:</p><ul><li>Change the server code temporarily (and hope you don’t commit it)</li><li><em>Hardcode</em> a fake response in the app (same risk)</li><li>Set up a mock server (overkill for a quick test)</li><li>Use a proxy tool like Charles or Proxyman (works, but it’s a separate app you have to configure each time)</li></ul><p>None of these feel great. You’re in VSCode, your Flutter app is running — why can’t you just intercept that request right there?</p><p>That’s why I built <strong>Flutter Net Inspector </strong>: a <a href="https://pub.dev/packages/flutter_net_inspector">Dio interceptor</a> + <a href="https://marketplace.visualstudio.com/items?itemName=kjokkenkoddinger.flutter-net-inspector">VSCode extension</a> combo that lets you inspect live HTTP traffic and mock any response, without leaving your editor.</p><h4><strong>What It Does?</strong></h4><ul><li><strong>Live traffic : </strong>every request and response shows up in a VSCode panel as it happens.</li><li><strong>Mock responses</strong> : intercept any URL and return whatever status code, headers, and body you want.</li><li><strong>Breakpoint</strong>s : pause a response mid-flight, edit it, then resume</li><li><strong>Replay :</strong> re-fire any captured request with one click</li><li><strong>Persistent rules :</strong> mock rules are saved to your workspace so your team can share them.</li></ul><h4><strong>How It Works?</strong></h4><p>The Flutter app runs a <a href="https://pub.dev/packages/flutter_net_inspector">Dio interceptor</a> that streams traffic over a WebSocket to a local server run by the <a href="https://marketplace.visualstudio.com/items?itemName=kjokkenkoddinger.flutter-net-inspector">VSCode extension</a>. The dashboard displays everything in real time. When a mock rule matches an outgoing request, the interceptor short-circuits it and returns your custom response the app never hits the real server.</p><p>When no extension is connected, requests pass through normally with zero overhead. Safe to leave wired up permanently in debug mode.</p><h4><strong>The Setup</strong></h4><ol><li><strong>Add the Dart package</strong></li></ol><pre># pubspec.yaml<br>dependencies:<br>  flutter_net_inspector: &lt;latest&gt;</pre><p>2. <strong>Wire up the interceptor</strong></p><pre>import &#39;package:dio/dio.dart&#39;;<br>import &#39;package:flutter/foundation.dart&#39;;<br>import &#39;package:flutter_net_inspector/flutter_net_inspector.dart&#39;;<br><br>final inspector = NetInspectorInterceptor();<br>final dio = Dio();<br><br>if (kDebugMode) {<br>  dio.interceptors.insert(0, inspector); // must add first or insert at idx 0<br>  inspector.attachDio(dio); // enables request replay<br>}</pre><p><strong>3. Connect in `main()` or (<em>anywhere which called only once)</em></strong></p><pre>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br><br>  if (kDebugMode) {<br>    await inspector.connect();<br>  }<br><br>  runApp(const MyApp());<br>}</pre><p><strong>4. Install the VSCode extension</strong></p><p>Search for <strong>Flutter Net Inspector</strong> in the Extensions panel, install it. It can be launch using command pallete :</p><pre>Flutter Net Inspector: Open Dashboard</pre><p>or can launch from VSCode side activity bar :</p><figure><img alt="Flutter Net Inspector VSCode activity bar icon" src="https://cdn-images-1.medium.com/max/688/1*VAd4X9IAC4B1nnC9hclSmA.png" /><figcaption>Flutter Net Inspector activity bar icon</figcaption></figure><p>By default it will use port <strong><em>9555 </em></strong>and the default host is <strong><em>127.0.0.1.</em></strong> Start the server and also run your flutter app. Open the <strong><em>dashboard</em></strong> and notice the indicator for device stream connection. When it connected successfully, network traffic starts appearing immediately.</p><h4><strong>Using Real Device?</strong></h4><p>By default the interceptor connects to `<strong><em>127.0.0.1:9555</em></strong>`, which works for simulators out of the box.</p><p>For an Android physical device, one command is all you need:</p><pre>adb reverse tcp:9555 tcp:9555</pre><p>For iOS device or other cases, set <strong><em>your machine’s LAN IP</em></strong> before constructing the interceptor:</p><pre>NetInspectorConfig.host = &#39;192.168.1.42&#39;; // example IP</pre><h4><strong>In Action</strong></h4><p><strong>Capturing live traffic</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uEVtyaT-eJ8L6d2OUsEHaA.png" /><figcaption>Capturing live traffic</figcaption></figure><p>Every request shows up with its method, status code, URL, and timing. Click a row to open the detail panel with full headers and body. The <strong><em>three-dot</em></strong> menu on each row gives you quick actions.</p><p><strong>Mocking a response</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jBaxH44chZ65xTTRRyndcg.png" /><figcaption>Mocking response</figcaption></figure><p>Open quick action menu from captured traffic and choose <strong>`<em>Mock this</em></strong>`. The editor opens pre-filled with the request’s data — just change what you need (status code, body, simulated delay) and save. The rule takes effect on the next matching request immediately.</p><p><strong>Seeing the mock active</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jDVeAjvjI2gawu3dsgfokQ.png" /><figcaption>Mock response active</figcaption></figure><p>Mocked rows are highlighted so you always know what’s real traffic and what’s intercepted. Your Flutter app receives exactly the response you configured.</p><h4><strong>Wrapping Up</strong></h4><p>Flutter Net Inspector is open source and free. If you’re tired of context-switching to a proxy tool just to test an edge case, give it a try.</p><ul><li><strong>VSCode extension</strong> — search <em>*</em><strong><em>Flutter Net Inspector</em></strong><em>*</em> in the <a href="https://marketplace.visualstudio.com/items?itemName=kjokkenkoddinger.flutter-net-inspector">Marketplace</a> or <a href="https://open-vsx.org/extension/kjokkenkoddinger/flutter-net-inspector">open-vsx</a></li><li><strong>Dart package</strong> — <a href="https://pub.dev/packages/flutter_net_inspector">pub.dev/packages/flutter_net_inspector</a></li><li><strong>Source</strong> — <a href="https://github.com/herisulistiyanto/flutter_net_inspector">github.com/herisulistiyanto/flutter_net_inspector</a></li></ul><p>If you find this article is helpful, might give your warmest clap :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=711f46579098" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WebP4VSCode: Easy WebP Conversion in Visual Studio Code]]></title>
            <link>https://herisulis.medium.com/webp4vscode-easy-webp-conversion-in-visual-studio-code-a68762101257?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a68762101257</guid>
            <category><![CDATA[vscode-extension]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[devtools]]></category>
            <category><![CDATA[converter]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Sun, 07 Dec 2025 07:43:25 GMT</pubDate>
            <atom:updated>2025-12-07T07:43:25.460Z</atom:updated>
            <content:encoded><![CDATA[<p>I created <em>WebP4VSCode</em>, a Visual Studio Code extension to simplify converting images to WebP format. Check it out on the <a href="https://marketplace.visualstudio.com/items?itemName=kjokkenkoddinger.webp4vscode">VSCode Marketplace</a>.</p><h4>Why I Built It</h4><p>While developing Flutter apps in Android Studio, I loved its WebP converter with real-time previews. But Android Studio was heavy, eating up memory. So, I switched to lightweight VSCode. Unfortunately, most VSCode WebP extensions lacked previews, making conversions <em>guess-based</em>. I decided to build my own with the features I needed. The UI is inspired from Android Studio WebP converter.</p><h4>What Makes WebP4VSCode Special</h4><ul><li><strong>Real-Time Preview</strong>: See original vs. converted image side-by-side, updating as you tweak quality.</li><li><strong>Batch Conversion</strong>: Convert multiple images at once.</li><li><strong>Lossless &amp; Lossy Encoding</strong>: Choose high-fidelity or smaller files.</li><li><strong>Supported Formats</strong>: PNG, JPG, JPEG, GIF, BMP, TIFF.</li></ul><h4>The features:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*i5idy_p9hgerOheZ2KzOKg.png" /><figcaption>Right Click assets you want to convert</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PGb9ED7-8wbiVPxpAv3e6A.png" /><figcaption>Batch convert support</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zfMGsCM_udAj26jWeFBW3Q.png" /><figcaption>comparison preview</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LREyUQwLkf6RtvdMa_dpVA.png" /><figcaption>zoom image preview</figcaption></figure><h4>Why It’s Useful</h4><p>WebP reduces image sizes for faster apps and websites. WebP4VSCode makes optimization quick and visual, saving time in development.</p><h4>Try It Out</h4><p>Install <a href="https://marketplace.visualstudio.com/items?itemName=kjokkenkoddinger.webp4vscode">WebP4VSCode</a> for free. Feedback? Drop a review or reach out on GitHub.</p><p><em>Like this? Clap or share for more dev tools!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a68762101257" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LynxJS & TailwindCSS: Setup & Solving the Hot Reload Mystery]]></title>
            <link>https://herisulis.medium.com/lynxjs-tailwindcss-setup-solving-the-hot-reload-mystery-d60a4e03c987?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/d60a4e03c987</guid>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[lynx-js]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[lynx]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Thu, 13 Mar 2025 07:29:39 GMT</pubDate>
            <atom:updated>2025-03-13T07:29:39.792Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we’ll dive into how you can set up TailwindCSS in your LynxJS project to overcome hot reloading challenges. We’ll explore the story behind the existing docs and plugins, and then provide a step-by-step guide to achieve a seamless development workflow with instant updates on your TSX/JSX files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RUdxXEcuT_aidNGx" /><figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=medium&amp;utm_medium=referral">Glenn Carstens-Peters</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>The Backstory: When the Docs Don’t Deliver</strong></h4><p>Developers often rely on official documentation and community plugins to streamline their projects. However, when it comes to integrating TailwindCSS in LynxJS, many have encountered an issue: <strong>hot reloading doesn’t pick up changes made in TSX/JSX files</strong>. Existing plugins like <a href="https://github.com/rspack-contrib/rsbuild-plugin-tailwindcss">rsbuild-plugin-tailwindcss</a> tend to fall short in providing a smooth development experience.</p><p>This problem can slow down your workflow, forcing you to manually rebuild or refresh, which disrupts productivity and creativity. Fortunately, there is a straightforward workaround that can get your hot reload working flawlessly.</p><h4><strong>The Workaround: Step-by-Step Configuration</strong></h4><p>Follow these steps to configure TailwindCSS in your LynxJS project with hot reloading enabled:</p><ol><li><strong>Clean Up Your Environment</strong></li></ol><p>If you’ve previously installed <em>rsbuild-plugin-tailwindcss</em> and configured it in your <em>lynx.config.ts</em>, start by removing it to avoid conflicts. If there is conflicts in plugins, the hot reload won’t work from tsx/jsx.</p><pre>pnpm remove rsbuild-plugin-tailwindcss</pre><p>2. <strong>Install the Required Packages</strong></p><p>Install the necessary packages including TailwindCSS, PostCSS, PostCSS Loader, and Autoprefixer. Using pnpm ensures a fast and efficient installation.</p><pre>pnpm install -D tailwindcss@3 postcss postcss-loader autoprefixer</pre><p><strong>3. Initialize TailwindCSS</strong></p><p>Run the TailwindCSS initialization command to generate both tailwind.config.js and postcss.config.js.</p><pre>npx tailwindcss init -p</pre><p>4. <strong>Install Lynx Tailwind Presets</strong></p><p>Lynx offers a Tailwind preset to enhance your project’s configuration. Install it using:</p><pre>pnpm install -D @lynx-contrib/tailwind-preset</pre><p><strong>5.</strong> <strong>Configure tailwind.config.js</strong></p><pre>const lynxPreset = require(&#39;@lynx-contrib/tailwind-preset&#39;);<br><br>/** @type {import(&#39;tailwindcss&#39;).Config} */<br>export default {<br>  presets: [lynxPreset],<br>  content: [&#39;./src/**/*.{html,js,ts,jsx,tsx}&#39;],<br>  theme: {<br>    extend: {},<br>  },<br>  plugins: [],<br>}</pre><p><strong>6. Update Your CSS File</strong></p><p>Add the Tailwind directives in your main CSS file (for example, src/App.css). Customize your root variables if needed.</p><pre>@tailwind base;<br>@tailwind components;<br>@tailwind utilities;<br><br>:root {<br>  background-color: #000;<br>  --color-text: #fff;<br>}<br><br>/* Additional custom styles can be added here */</pre><p><strong>7. Rebuild and Enjoy Hot Reloading</strong></p><p>Finally, rebuild your project with:</p><pre>pnpm run dev</pre><p>Then, re-run your project in LynxExplorer. With these configurations, you should experience smooth hot reloading even when editing TSX/JSX files.</p><h4><strong>Wrapping Up</strong></h4><p>By following the steps outlined above, you’ve successfully configured TailwindCSS in a LynxJS project while ensuring that hot reloading works as expected. This setup not only saves you time but also enhances your development experience, letting you focus on building great applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*1RH3weKu-2LcYsVMKRROnQ.gif" /><figcaption>Hot-Reload in tsx file with Tailwindcss</figcaption></figure><p>Happy coding, and enjoy a smoother, faster development process with LynxJS and TailwindCSS!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d60a4e03c987" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nested Hive Adapter Pitfalls: How to Fix Type Errors in Flutter]]></title>
            <link>https://herisulis.medium.com/nested-hive-adapter-pitfalls-how-to-fix-type-errors-in-flutter-9d26a371a5c6?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d26a371a5c6</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Mon, 10 Mar 2025 04:24:11 GMT</pubDate>
            <atom:updated>2025-03-10T04:24:11.617Z</atom:updated>
            <content:encoded><![CDATA[<p>Working with Hive in Flutter is great for lightweight local storage, but you may run into some quirks when dealing with nested objects. One common issue is the runtime error:</p><pre>[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: type &#39;SavedEvent&#39; is not a subtype of type &#39;SavedEventCategory&#39; of &#39;obj&#39;</pre><p>In this article, we’ll walk through the problem, understand why it occurs, and how to fix it — making your code more robust and error-free.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FmomVISB_yhTBCA5" /><figcaption>Photo by <a href="https://unsplash.com/@bobajaglicic?utm_source=medium&amp;utm_medium=referral">Boba Jaglicic</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>Understanding the Problem</strong></h4><p>In our setup, we have multiple Hive objects with nested relationships:</p><ul><li><strong>SavedEvent</strong> holds nested objects <strong>SavedEventCategory</strong> and <strong>SavedVendor</strong>.</li><li>The adapters for these objects are registered in a loop during initialization.</li></ul><p>Your adapter initialization looked like this:</p><pre>static Future&lt;void&gt; initDb({<br>  List&lt;TypeAdapter&gt; adapters = const [],<br>}) async {<br>  await Hive.initFlutter();<br><br>  for (final adapter in adapters) {<br>    if (!Hive.isAdapterRegistered(adapter.typeId)) {<br>      Hive.registerAdapter(adapter);<br>    }<br>  }<br>}</pre><p>And you registered your adapters in main():</p><pre>await DbHelper.initDb(<br>  adapters: [<br>    SavedEventCategoryAdapter(),<br>    SavedVendorAdapter(),<br>    SavedEventAdapter(),<br>  ],<br>);</pre><p>The error appears because Hive’s generic adapter registration mechanism doesn’t automatically infer nested types. When you register an adapter for a nested Hive object, such as SavedEventCategory, you must specify the generic type explicitly.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F4JVTF9zR9BicshFAb7%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExemowZGd3ejVzdTQyaWtlb2duaGk0N3QyZG1iZmliM3pkcHFkeWU5NyZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F4JVTF9zR9BicshFAb7%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExY3F1YncwbTl0YWFienN1dmVuNzh5bmlyNmhnb2QyYnk3cDlwbnpxcCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F4JVTF9zR9BicshFAb7%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="313" frameborder="0" scrolling="no"><a href="https://medium.com/media/34f6759201c0953eb4fb6da711a4e95c/href">https://medium.com/media/34f6759201c0953eb4fb6da711a4e95c/href</a></iframe><h4><strong>The Root Cause</strong></h4><p>When Hive registers an adapter, it needs to know the exact type to correctly deserialize your objects. Without specifying the type, Dart may misinterpret the object type, especially with nested objects. This leads to type mismatches where Hive mistakenly treats one type (e.g., SavedEvent) as another (e.g., SavedEventCategory).</p><h4><strong>The Fix: Specify the Object Type</strong></h4><p>The solution is simple: register your nested adapters with the generic type explicitly. Change your adapter registration to include the specific type parameter. For example, modify the registration for SavedEventCategoryAdapter as follows:</p><pre>Hive.registerAdapter&lt;SavedEventCategory&gt;(SavedEventCategoryAdapter());<br>Hive.registerAdapter&lt;SavedVendor&gt;(SavedVendorAdapter());<br>Hive.registerAdapter&lt;SavedEvent&gt;(SavedEventAdapter());</pre><p>This explicit type declaration informs Hive exactly which type to associate with each adapter, avoiding any potential mismatches.</p><h4><strong>Updated Initialization Code</strong></h4><p>Here’s an updated example of the initialization code:</p><pre>static Future&lt;void&gt; initDb() async {<br>  await Hive.initFlutter();<br><br>  // Register adapters with explicit generic types.<br>  if (!Hive.isAdapterRegistered(SavedEventCategoryAdapter().typeId)) {<br>    Hive.registerAdapter&lt;SavedEventCategory&gt;(SavedEventCategoryAdapter());<br>  }<br>  if (!Hive.isAdapterRegistered(SavedVendorAdapter().typeId)) {<br>    Hive.registerAdapter&lt;SavedVendor&gt;(SavedVendorAdapter());<br>  }<br>  if (!Hive.isAdapterRegistered(SavedEventAdapter().typeId)) {<br>    Hive.registerAdapter&lt;SavedEvent&gt;(SavedEventAdapter());<br>  }<br>}</pre><p>And in your main class:</p><pre>await DbHelper.initDb();</pre><p>This approach is clearer and eliminates the ambiguity that can lead to type errors.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o6Mbj2w67HnPQKgcE%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExazZvczJ3MjdqMXN3c3prcjU0NjAxY2pmd2UyYWQ3emc2MnQzamswOSZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F3o6Mbj2w67HnPQKgcE%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExeGZzdnh6ZWh3OXVidWg4cXlpdGV2YzlqZTdrZjNrNjNjY3RjNWs2aiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3o6Mbj2w67HnPQKgcE%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="331" frameborder="0" scrolling="no"><a href="https://medium.com/media/406c1507c9ed5cdbeb26bc77cfb7bb9f/href">https://medium.com/media/406c1507c9ed5cdbeb26bc77cfb7bb9f/href</a></iframe><p>Or, you can create a “Wrapper class” to keep using the loop initialization &amp; registered status checker.</p><pre>abstract interface class AdapterWrapper {<br>  void register();<br>}<br><br>class HiveAdapterWrapper&lt;T&gt; implements AdapterWrapper {<br>  final TypeAdapter&lt;T&gt; adapter;<br>  HiveAdapterWrapper(this.adapter);<br><br>  @override<br>  void register() {<br>    if (!Hive.isAdapterRegistered(adapter.typeId)) {<br>      Hive.registerAdapter&lt;T&gt;(adapter);<br>    }<br>  }<br>}<br></pre><p>The init function become like this :</p><pre>static Future&lt;void&gt; initDb({<br>  List&lt;AdapterWrapper&gt; adapters = const [],<br>}) async {<br>  await Hive.initFlutter();<br>  for (final wrapper in adapters) {<br>      wrapper.register();<br>  }<br>}</pre><p>In your main class (put specific object type in the generic type) :</p><pre>await DbHelper.initDb(<br>  adapters: [<br>    HiveAdapterWrapper&lt;SavedEventCategory&gt;(SavedEventCategoryAdapter()),<br>    HiveAdapterWrapper&lt;SavedVendor&gt;(SavedVendorAdapter()),<br>    HiveAdapterWrapper&lt;SavedEvent&gt;(SavedEventAdapter()),<br>  ],<br>);</pre><h4><strong>Key Takeaways</strong></h4><ul><li><strong>Explicit Typing Matters:</strong> When dealing with nested objects, always specify the generic type when registering Hive adapters.</li><li><strong>Avoid Ambiguity:</strong> Implicit adapter registration can cause type mismatches if the nested type isn’t recognized correctly.</li><li><strong>Readability and Maintenance:</strong> Writing clear and explicit registration code can save time during debugging and maintenance.</li></ul><p>For more details and additional best practices, you might find the <a href="https://pub.dev/documentation/hive/latest/">Hive documentation</a> useful.</p><h4><strong>Conclusion</strong></h4><p>By explicitly specifying the type parameter during adapter registration, you can avoid runtime type errors when working with nested Hive objects in Flutter. This small change ensures that each adapter is correctly associated with its object type, leading to cleaner, more reliable code.</p><p>Happy coding, and may your Hive databases run smoothly!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d26a371a5c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Push Notifications with Laravel 11 Backend using Firebase & RabbitMQ]]></title>
            <link>https://blog.devops.dev/push-notifications-with-laravel-11-backend-using-firebase-rabbitmq-34cc01f4208b?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/34cc01f4208b</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[laravel-11]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[rabbitmq]]></category>
            <category><![CDATA[firebasecloudmessaging]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Sun, 09 Mar 2025 17:20:50 GMT</pubDate>
            <atom:updated>2025-05-06T09:31:09.935Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we’ll explore how to send push notifications in Laravel 11 with FCM (Firebase Cloud Messaging) and offload the heavy lifting to RabbitMQ. Using a custom notification channel for Firebase and leveraging RabbitMQ for asynchronous processing will help you build a scalable and robust notification system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PPCl8q3V-rSXLmsE" /><figcaption>Photo by <a href="https://unsplash.com/@huntleytography?utm_source=medium&amp;utm_medium=referral">Devon Janse van Rensburg</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Overview</h4><p>Laravel’s notification system is flexible and easily extendable. By creating a custom Firebase channel, we can send push notifications to devices via FCM. Offloading notifications to RabbitMQ (using Laravel’s queue system) ensures that heavy tasks don’t block your main application thread. This article will walk through a complete example, including code samples and configuration details.</p><h4>Prerequisites</h4><ul><li><strong>Laravel 11:</strong> Ensure you have a Laravel 11 project.</li><li><strong>Firebase Service Account:</strong> Create a Firebase project and download the <em>firebase.json</em> (service account key) file.</li><li><strong>RabbitMQ Server:</strong> You need access to a RabbitMQ server (installation steps provided below).</li><li><strong>Composer Dependencies:</strong> We’ll be using the <a href="https://github.com/kreait/firebase-php">kreait/firebase-php</a> package for interacting with Firebase. For RabbitMQ integration, consider using <a href="https://github.com/vyuldashev/laravel-queue-rabbitmq">vyuldashev/laravel-queue-rabbitmq</a>.</li></ul><h4>Setting Up Firebase for FCM</h4><ol><li><strong>Create a Firebase Project:<br></strong>Go to the <a href="https://console.firebase.google.com/">Firebase Console</a> and create a new project. Enable Cloud Messaging in your project settings.</li><li><strong>Generate a Service Account Key:<br></strong>Navigate to <strong>Project Settings &gt; Service Accounts</strong>. Click “Generate new private key” to download the firebase.json file. Place the json file in your Laravel project at “storage/app/firebase/your-service-account.json”</li><li><strong>Install Firebase PHP SDK:<br></strong>Run the following command in your Laravel project:</li></ol><pre>composer require kreait/firebase-php</pre><p>For detailed documentation, refer to <a href="https://firebase-php.readthedocs.io/en/stable/"><em>Kreait’s Firebase PHP documentation</em></a>.</p><p><strong>Creating a Custom Firebase Notification Channel</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ce58668a503617dcaffe7fe7efc7f2a/href">https://medium.com/media/6ce58668a503617dcaffe7fe7efc7f2a/href</a></iframe><p><strong>Explanation:</strong></p><ul><li>The channel reads the service account credentials from your Firebase JSON file.</li><li>It constructs an FCM notification with a title, body, and optional data.</li><li>Any errors during the sending process are logged for debugging.</li></ul><h4>Building the Notification Class</h4><p>Next, create a notification class that utilizes your custom channel. Save this as <em>GenericFirebaseNotification.php</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ea21907f45fe19e925183f4039bd8ba/href">https://medium.com/media/5ea21907f45fe19e925183f4039bd8ba/href</a></iframe><p><strong>Key Points:</strong></p><ul><li>The notification implements ShouldQueue to ensure it is processed asynchronously.</li><li>The <a href="https://gist.github.com/herisulistiyanto/81b63e308fb5956ccf0ed381ee85c8d8#file-genericfirebasenotification-php-L52"><strong><em>toFirebase</em></strong></a> method returns an array with all the details needed by your custom channel.</li></ul><h4><strong>Integrating RabbitMQ with Laravel</strong></h4><ol><li><strong>Installing the RabbitMQ Package<br></strong>To integrate RabbitMQ as a queue driver, use the <a href="https://github.com/vyuldashev/laravel-queue-rabbitmq"><em>vyuldashev/laravel-queue-rabbitmq</em></a> package. Install it via Composer:</li></ol><pre>composer require vyuldashev/laravel-queue-rabbitmq</pre><p>2. <strong>Configuration</strong></p><p>Update your <strong><em>config/queue.php</em></strong> to add the RabbitMQ connection. For example:</p><pre>&#39;rabbitmq&#39; =&gt; [<br>    &#39;driver&#39;    =&gt; env(&#39;QUEUE_CONNECTION&#39;, &#39;rabbitmq&#39;),<br>    &#39;host&#39;      =&gt; env(&#39;RABBITMQ_HOST&#39;, &#39;127.0.0.1&#39;),<br>    &#39;port&#39;      =&gt; env(&#39;RABBITMQ_PORT&#39;, 5672),<br>    &#39;vhost&#39;     =&gt; env(&#39;RABBITMQ_VHOST&#39;, &#39;/&#39;),<br>    &#39;login&#39;     =&gt; env(&#39;RABBITMQ_LOGIN&#39;, &#39;guest&#39;),<br>    &#39;password&#39;  =&gt; env(&#39;RABBITMQ_PASSWORD&#39;, &#39;guest&#39;),<br>    &#39;queue&#39;     =&gt; env(&#39;RABBITMQ_QUEUE&#39;, &#39;default&#39;),<br>    &#39;options&#39;   =&gt; [<br>        &#39;exchange&#39; =&gt; [<br>            &#39;name&#39;      =&gt; env(&#39;RABBITMQ_EXCHANGE_NAME&#39;),<br>            &#39;type&#39;      =&gt; env(&#39;RABBITMQ_EXCHANGE_TYPE&#39;, &#39;direct&#39;),<br>            &#39;declare&#39;   =&gt; env(&#39;RABBITMQ_EXCHANGE_DECLARE&#39;, true),<br>        ],<br>    ],<br>],</pre><p>Set the corresponding environment variables in your <strong>.env</strong> file:</p><pre>QUEUE_CONNECTION=rabbitmq<br>RABBITMQ_HOST=127.0.0.1<br>RABBITMQ_PORT=5672<br>RABBITMQ_VHOST=/<br>RABBITMQ_LOGIN=guest<br>RABBITMQ_PASSWORD=guest<br>RABBITMQ_QUEUE=default<br>RABBITMQ_EXCHANGE_NAME=your_exchange_name<br>RABBITMQ_EXCHANGE_TYPE=direct<br>RABBITMQ_EXCHANGE_DECLARE=true</pre><p><strong>Documentation References:</strong></p><ul><li><a href="https://laravel.com/docs/11.x/queues">Laravel Queue Documentation</a></li><li><a href="https://github.com/vyuldashev/laravel-queue-rabbitmq">vyuldashev/laravel-queue-rabbitmq</a></li></ul><h4><strong>Installing RabbitMQ on Your Server</strong></h4><p>Here’s how to install RabbitMQ on an Ubuntu server. (Steps may vary slightly for other distributions.)</p><ol><li><strong>Update System Packages:</strong></li></ol><pre>sudo apt-get update<br>sudo apt-get upgrade -y</pre><p>2. <strong>Install Erlang:</strong></p><p>RabbitMQ is built on Erlang, so you must install it first.</p><pre>sudo apt-get install -y erlang</pre><p>For the latest version, you might add the Erlang Solutions repository:</p><pre>wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb<br>sudo dpkg -i erlang-solutions_2.0_all.deb<br>sudo apt-get update<br>sudo apt-get install -y erlang</pre><p>3. <strong>Install RabbitMQ:</strong></p><pre>sudo apt-get install -y rabbitmq-server</pre><p>4. <strong>Enable and Start RabbitMQ:</strong></p><pre>sudo systemctl enable rabbitmq-server<br>sudo systemctl start rabbitmq-server</pre><p><strong>5. Enable Management Plugin (<em>Optional but recommended</em>):</strong></p><pre>sudo rabbitmq-plugins enable rabbitmq_management</pre><p>You can now access the management dashboard at <a href="http://localhost:15672/">http://localhost:15672</a> or <a href="http://your.server.ip.address:15672/">http://your.server.ip.address:15672</a> using the default credentials username/password (guest/guest).</p><p>For more detailed installation instructions, refer to the <a href="https://www.rabbitmq.com/download.html">RabbitMQ Official Documentation</a>.</p><h4><strong>Dispatching Notifications</strong></h4><p>Here’s how you can dispatch a notification, assume the client fcm_token already stored in your database :</p><pre>// Example usage in your controller or service:<br>if ($user-&gt;fcm_token != null) {<br> $user-&gt;notify(new \App\Notifications\GenericFirebaseNotification(<br> $user-&gt;fcm_token,<br> &quot;This is Notification Title&quot;,<br> &quot;This is Notification Body&quot;,<br> [&quot;data_key_1&quot; =&gt; &quot;abc&quot;, &quot;data_key_2&quot; =&gt; &quot;data 2&quot;]<br> ));<br>}</pre><h4><strong>Running the Queue Worker with RabbitMQ</strong></h4><p>To process the queued notifications asynchronously, you need to run a queue worker that listens to the RabbitMQ queue. You can do this by running the following Artisan command:</p><pre>php artisan queue:work rabbitmq -d</pre><p><strong>Explanation:</strong></p><ul><li><strong>rabbitmq</strong>: Specifies the connection name as defined in your <em>config/queue.php</em>.</li><li><strong>-d</strong>: Runs the worker in daemon mode, which keeps the process running in the background. This mode is ideal for production environments as it reduces the overhead of bootstrapping the application on each job execution.</li></ul><p>Make sure to monitor your daemon process and restart it as needed, especially when you deploy updates to your application.</p><p><strong>How It Works:</strong></p><ul><li>The notification is queued and processed by Laravel’s queue worker.</li><li>RabbitMQ picks up the job from the queue, ensuring that the notification process doesn’t delay the main application flow.</li><li>The custom Firebase channel sends the push notification via FCM.</li></ul><h4><strong>Conclusion</strong></h4><p>By combining Laravel’s robust notification system with FCM and RabbitMQ, you can efficiently send push notifications in a scalable, non-blocking way. This setup ensures that the notification process is handled asynchronously, which improves performance and user experience. Remember to review the official documentation for each component:</p><ul><li><a href="https://laravel.com/docs/11.x/notifications">Laravel Notifications</a></li><li><a href="https://firebase-php.readthedocs.io/en/stable/">Kreait Firebase PHP</a></li><li><a href="https://www.rabbitmq.com/documentation.html">RabbitMQ Official Docs</a></li></ul><p>With these steps, you have a solid foundation for implementing push notifications in Laravel 11 using FCM &amp; RabbitMQ.</p><p>Happy coding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MUGDtl1oj0oJBTxI" /><figcaption>Photo by <a href="https://unsplash.com/@joshuaryanphoto?utm_source=medium&amp;utm_medium=referral">Joshua Reddekopp</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34cc01f4208b" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/push-notifications-with-laravel-11-backend-using-firebase-rabbitmq-34cc01f4208b">Push Notifications with Laravel 11 Backend using Firebase &amp; RabbitMQ</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving the “Families Policy Requirement” Rejection in Android PlayStore]]></title>
            <link>https://herisulis.medium.com/solving-the-families-policy-requirement-rejection-in-android-playstore-5bba0a953c7d?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bba0a953c7d</guid>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[play-store]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Wed, 16 Aug 2023 03:50:53 GMT</pubDate>
            <atom:updated>2023-08-16T03:50:53.837Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ldFlfvdJ22GS4guc" /><figcaption>Photo by <a href="https://unsplash.com/@redaquamedia?utm_source=medium&amp;utm_medium=referral">Denny Müller</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A recent challenge many Android developers have faced is the consistent rejection of apps from the PlayStore, particularly concerning the “Families Policy Requirement.” This policy insists that apps targeting children must not transmit specific identifiers, including Android advertising identifier (AAID), SIM Serial, Build Serial, and more.</p><p>The problem faced by many developers, including us, was that the solutions available were often not sufficient to meet Google’s requirements, leading to back-and-forth communications and repeated rejections. In our case, we stumbled upon an unexpected connection between this requirement and the Facebook SDK.</p><h3>The Challenge</h3><p>One of the dependencies which automatically includes the ads permission is from Firebase refer to this release notes: <a href="https://firebase.google.com/support/release-notes/android#analytics_v20-1-1">https://firebase.google.com/support/release-notes/android#analytics_v20-1-1</a></p><p>Unfortunately, it will cause an issue that we facing according to this policy guideline : <br><a href="https://support.google.com/googleplay/android-developer/answer/6048248">https://support.google.com/googleplay/android-developer/answer/6048248</a></p><p>So we remove the permission from our AndroidManifest by adding these lines:</p><pre>&lt;uses-permission<br>        android:name=&quot;com.google.android.gms.permission.AD_ID&quot;<br>        tools:node=&quot;remove&quot; /&gt;</pre><p>Despite removing the permissions for AD_ID, our app was still being rejected. Even after double-checking the Gradle dependency trees for any suspicious ad-related dependencies, we couldn’t find the culprit.</p><h3>A Surprising Discovery</h3><p>Google explicitly mentioned that the transmission was related to Facebook. Upon investigating our dependencies, including the Facebook SDK, we found that no suspicious connections seemed related to ads.</p><p>However, a deeper look at the code inside the Facebook SDK revealed the use of Reflection to collect AdvertisingIdClient. This was causing the app to transmit data related to advertising, thus violating the Families Policy Requirement.</p><p>Here’s the specific part of the code:</p><p><a href="https://github.com/facebook/facebook-android-sdk/blob/1ad4bd9c71ab4b243d3fca04910d6d7de42ae3de/facebook-core/src/main/java/com/facebook/internal/AttributionIdentifiers.kt#L95">facebook-android-sdk/facebook-core/src/main/java/com/facebook/internal/AttributionIdentifiers.kt at 1ad4bd9c71ab4b243d3fca04910d6d7de42ae3de · facebook/facebook-android-sdk</a></p><h3>The Solution</h3><p>After reading the source code thoroughly, we found the way to opt-out of the ads ID collection:</p><pre>&lt;meta-data<br>    android:name=&quot;com.facebook.sdk.AdvertiserIDCollectionEnabled&quot;<br>    android:value=&quot;false&quot; /&gt;</pre><p>Adding the above line to our AndroidManifest file finally made our app comply with the family policies 👏.</p><h3>Conclusion</h3><p>The lack of transparency and clear guidance from Google can make resolving such issues time-consuming and challenging. In our case, understanding the Facebook SDK’s internal workings and employing a small yet crucial change to our manifest was the key to success.</p><p>For developers facing similar challenges, it is essential to consider not only the explicit dependencies but also potential hidden connections that might violate the policy requirements.</p><p>Our journey teaches us that sometimes, the answers lie in the deeper layers of code, waiting to be discovered. With perseverance and attention to detail, the solutions are there to be found.</p><p>If you find this article helpful, please give your warmest clap 👏.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bba0a953c7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Check AndroidManifest.xml for Android target API 31 ready.]]></title>
            <link>https://herisulis.medium.com/check-androidmanifest-xml-for-android-target-api-31-ready-f5ff1f36fbe7?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5ff1f36fbe7</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Mon, 12 Sep 2022 08:17:19 GMT</pubDate>
            <atom:updated>2022-09-12T08:17:19.668Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MZ0derxjbDA3z_CA" /><figcaption>Photo by <a href="https://unsplash.com/@olloweb?utm_source=medium&amp;utm_medium=referral">Agence Olloweb</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As we already know, Android with target API 31 requires some adjustments within its Manifest, in this case, we need to explicitly declare the android:exported attribute for activities, services, and broadcast receivers that use intent filters. You can read the detailed information about this topic from the <a href="https://developer.android.com/about/versions/12/behavior-changes-12#exported">official docs</a>.</p><p>The problem is when we <em>roughly</em> upgrade the target SDK in a large project (a lot of dependencies &amp; modular projects) without adjustment, we might face issues like :</p><pre>Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest</pre><p>Unfortunately, the error log doesn’t mention which manifest node we have to make adjustments 🤔.</p><p>It will be much easier if we know which one is the root cause of the error, so in this article, we want to share how we find the <em>“unsupported” </em>nodes using a custom Gradle task.</p><p>The rough steps are :</p><ol><li>Build/generate merged manifest using target API <strong>below 31</strong> (target API which doesn’t have error).<br>If successful, the merged manifest will be in: <em>your_app_build_dir/intermediates/merged_manifests/variant_dir/Androidmanifest.xml</em></li><li>Search activities, services, and broadcast receivers nodes that have intent-filter but doesn’t have android:exported property.</li><li>Print the result.</li></ol><p>Point number 2 seems <em>“no problem at all” </em>when the project isn’t large, but it is quite troublesome when it&#39;s a huge project if we have to check the node one by one.</p><p>So we write a custom Gradle task to do the search job :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/337d86bafaef083130f38000cd9ea8d6/href">https://medium.com/media/337d86bafaef083130f38000cd9ea8d6/href</a></iframe><p>Once the Gradle script is applied, We can check our merged manifest generated previously by running the task :</p><pre>./gradlew checkMissingExport</pre><p>If any <em>activity</em>, <em>service</em>, or <em>receiver</em> doesn’t have android:exported property, it will show the list something like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*0PscrlmfRXSwOrcQdkJuCQ.png" /><figcaption>log result</figcaption></figure><p>With the list result, now we can fix the issue by adding the required property (<em>android:exported</em>) in the specific node. Please check the official docs about <a href="https://developer.android.com/studio/build/manage-manifests">managing manifest files</a> to fix the issue.</p><p>Once the required nodes have android:exported , we can upgrade the target SDK to 31 (<em>assuming we already make adjustments in the code also</em>).</p><p>OK, that’s all folks. Hope it is useful for your migration to android target SDK 31.</p><p>Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5ff1f36fbe7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Android Multi dimension Flavors Signing Config]]></title>
            <link>https://herisulis.medium.com/dynamic-android-multi-dimension-flavors-signing-config-9866f1f5cb63?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9866f1f5cb63</guid>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Thu, 03 Jun 2021 09:37:59 GMT</pubDate>
            <atom:updated>2021-06-03T10:11:09.724Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q8xeQxMLBhMbQlu2" /><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>Maybe this article won’t be popular as Jetpack Compose or another Jetpack article. Signing config . . yes, it’s been several days become the root of headache in our project. For notes, our project have multi dimension <em>flavors </em>to handle multiple Apps in a single Android project. So we have dimension <em>API (environment), LANG (app region language, app), </em>then we have build type <em>Debug &amp; Release</em>.</p><p>In API dimension, we got <em>Production</em> &amp; <em>Staging,</em> and then in LANG dimension we have <em>IDN, VNM, THA. </em>So the combination of the <em>flavors</em> &amp; build type we’ll get the <a href="https://developer.android.com/studio/build/build-variants"><em>build variant</em>s</a><em> </em>and we need to sign those variant using corresponded <em>keystore.</em></p><pre>The build variants will be : <br>[<em>production, staging</em>][<em>idn, vnm, tha</em>][<em>debug, release</em>]</pre><p>By the time if we want to get the build variant, traverse the application variants is the easiest way (<em>well, i thought so at first . .</em>).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0d02102ceb7ed695b18b69b2fb12539/href">https://medium.com/media/d0d02102ceb7ed695b18b69b2fb12539/href</a></iframe><p>Above snippet code, i’m assuming all merged <em>flavors</em> will be signed using corresponded <em>keystore</em> and if we check on gradle <em>signingReport</em> task, it will show correct mapping of the signing configs. And yes, it seems work properly, APK / AAB can be signed &amp; can be upload into <em>Playstore</em>. All cool . . 😙</p><p>Until the day suddenly we <strong><em>can’t </em></strong>upload AAB into store, it says the AAB is signed using different <em>key. </em>We check the <em>SHA1</em>, the <em>SHA1</em> is wrong, it signed using <em>debug keystore</em> not the <em>release</em> <em>keystore </em>😮 . . . check on the <em>SigningReport</em> task, nothing changed, still the same as before 😱, i thought it is cache problem since we use gradle <em>remote build cache.</em> Flush the cache, rebuild, still wrong signature applied.</p><p>Then I try build locally and check the signature, i assume there’s problem with CI env. And just to make sure i’m not facing “strange issue”, i’m doing <em>Invalidate Cache &amp; Restart</em> first before build . .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*Nso1pbGgXmR5-aQ6f9dFPQ.jpeg" /><figcaption>ultimate solution</figcaption></figure><p>Unfortunately, local build also give wrong signature result when i check using keytool :</p><pre><em>keytool -printcert -jarfile my/awesome/project/app-xyz.aab</em></pre><p>This issue become blocker our release process, and somehow it takes long time to solve it. For the release purpose we hardcode signature temporary, and parallel try looking for the solution.</p><p>It seem, it doesn’t as easy as it look, then i think better to change how the app signed by creating the <em>SigningConfig </em>object based on the <em>gradle</em> task request (<em>dynamic</em>).</p><p>For the signature configuration info, i’m using Json file then later can be parsed into object using <em>JsonSlurper</em> as shown below :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f308950c20de370419844f011464d54/href">https://medium.com/media/1f308950c20de370419844f011464d54/href</a></iframe><p>The Json file parsed into object then put on HashMap with “<em>configName</em>” field as <strong>key</strong> and the current object as the <strong>value</strong>.</p><pre><em>&quot;tha&quot; : {          <br>    &quot;configName&quot;: &quot;tha&quot;,<br>    &quot;storeFile&quot;:&quot;src/tha/release.keystore&quot;,<br>    &quot;storePassword&quot;:&quot;xxxx&quot;,<br>    &quot;keyAlias&quot;:&quot;xxxx&quot;,<br>    &quot;keyPassword&quot;:&quot;xxxx&quot;        <br>}</em></pre><p>And here’s the helper script to parse <em>gradle</em> task request :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e08d588860a0f7c93b1d1b8b8979968/href">https://medium.com/media/5e08d588860a0f7c93b1d1b8b8979968/href</a></iframe><p>In the simple way, those script will extract our <em>gradle</em> command using <em>Regex</em> and using simple logic <em>if contains-then</em>.</p><pre><em>./gradlew assembleProdIdnRelease<br></em><br>* contains &quot;Release&quot; :<br>  - isRelease = true, so it should use release.keystore<br>* contains &quot;assemble&quot; :<br>  - apply pattern &quot;assemble(\\w+)(Release|Debug)&quot;<br>  - is pattern match with gradle request? -&gt; yes<br>  - matcher.group(1) will return &quot;ProdIdn&quot; (convert lowercase)<br>  - &quot;prodidn&quot; get 3 last chars -&gt; &quot;idn&quot;<br>  - use our last 3 chars as KEY to get the VALUE from config hashmap</pre><p>And below is the snippet app <em>build.gradle</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f61d1331690502e904695177555eb7a/href">https://medium.com/media/2f61d1331690502e904695177555eb7a/href</a></iframe><p>It’s not fancy solution for sure, but for now it solve our problems on multi dimension <em>flavors</em> signing config. And somehow a lot of people facing this issue but few articles discuss about it. Anyway, if you find this article helpful, please give your warmest clap 👏 .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9866f1f5cb63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Coroutine LiveData in ViewModel]]></title>
            <link>https://medium.com/ruangguru-engineering/how-to-coroutine-livedata-in-viewmodel-6def66f932a7?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6def66f932a7</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[coroutine]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Fri, 08 Nov 2019 06:39:36 GMT</pubDate>
            <atom:updated>2019-11-11T03:15:08.315Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jfvBXuaE0jJ5hXFqmR9mFQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@rami_alzayat?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Rami Al-zayat</a> on <a href="https://unsplash.com/s/photos/android?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>As we know lately . . Kotlin Coroutine become <em>hot topic</em> in Android development. Usually i’m using RxJava in my Android project, and i decide to take a look on Coroutine for a simple project and share my “<em>experience”</em> in this story.</p><p>I’m using Retrofit (2.6.1) in my demo project, which already support for suspend function. Let’s take a look in my MovieApiService below :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1523e4572b99926814100a2bd4e895ce/href">https://medium.com/media/1523e4572b99926814100a2bd4e895ce/href</a></iframe><p>From the snippet above, we see that all of the function return object Retrofit Response not Deferred.</p><p>And then, i have a BaseDataSource which is the base abstract class for the DataSource, and here’s the snippet code :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a51d100fed169fd6d7234ce50ae85f97/href">https://medium.com/media/a51d100fed169fd6d7234ce50ae85f97/href</a></iframe><p>This BaseDataSource, we wrap the Retrofit Response into 2 type in the getResult function, ResponseResult.Success and ResponseResult.Error.</p><p>In resultLiveData function, we gonna wrap the suspend function result as LiveData by emitting the object.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6d55a14c1f0d28e1bb709c82d75ca6d/href">https://medium.com/media/d6d55a14c1f0d28e1bb709c82d75ca6d/href</a></iframe><p>Take a look on snippet above. Both of function will return LiveData using the function from the BaseDataSource. So when those function invoked, it should give LiveData immediately right? <em>ummmm</em> . . . not quite right though.</p><p>So here’s my experience i mentioned earlier.</p><p>Usually, when we work using ViewModel &amp; LiveData, we put like . . . let say 2 variable which will store value to be observe :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9783077c45e150ea8666635695919877/href">https://medium.com/media/9783077c45e150ea8666635695919877/href</a></iframe><p>On the snippet above will give null result when we observe movieResult . . but why?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*gVUNtBlqasnWBPQM1XlzJg.jpeg" /><figcaption>But why??</figcaption></figure><p>So it seem our DataSource won’t emitting data because the LiveData (<em>from our remote data source</em>) mark as no active observer. And then i change the approach, for the function in our <em>viewmodel</em> become not return Unit but return LiveData instead.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80c9ccba95aaab3d3aa806eb322f6726/href">https://medium.com/media/80c9ccba95aaab3d3aa806eb322f6726/href</a></iframe><p>When we observe the LiveData by observing discoverAllMovies() in our Activity, it will give correct result.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7035d5fbdc9a9f49a235801ee0ad442f/href">https://medium.com/media/7035d5fbdc9a9f49a235801ee0ad442f/href</a></iframe><p>Please take a look at :</p><pre>dashboardViewModel.discoverAllMovies().<em>onResult </em><strong>{<br>    </strong>vfDashboardContent.<em>displayedChild </em>= when(<strong>it</strong>) {<br>        is ResponseResult.Success -&gt; {<br>            val data = it.result.data?.mapToMovieItemList()<br>            movieAdapter.setListMovieData(data)<br>            DashboardStateView.STATE_CONTENT<br>        }<br>        is ResponseResult.Loading -&gt; {<br>            DashboardStateView.STATE_LOADING<br>        }<br>        is ResponseResult.Error -&gt; {<br>            tvCommonError.<em>text </em>= <strong>it</strong>.msg.errorMsg.<em>orEmpty</em>()<br>            DashboardStateView.STATE_ERROR<br>        }<br>    }<br><strong>}</strong></pre><p>On above block, the live data can be observed (not null) and result will be handled by the state, then update current UI.</p><p>After this demo project, i realise that the livedata{} on coroutine need to be observe directly, so it can emitting data.</p><p>You can find the full source code in my <a href="https://github.com/herisulistiyanto/Simple-Retrofit-Coroutine">github</a>.</p><p><a href="https://github.com/herisulistiyanto/Simple-Retrofit-Coroutine">herisulistiyanto/Simple-Retrofit-Coroutine</a></p><p>If you find this article helpful, please give your warmest clap :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jUW_wXKWPOaYudPM3RSFgQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@peet818?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Pete Pedroza</a> on <a href="https://unsplash.com/s/photos/thank-you?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6def66f932a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ruangguru-engineering/how-to-coroutine-livedata-in-viewmodel-6def66f932a7">How to Coroutine LiveData in ViewModel</a> was originally published in <a href="https://medium.com/ruangguru-engineering">Ruangguru Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Kotlin Code Quality Check using Detekt and Git Hooks Pre-push (Mac and Linux)]]></title>
            <link>https://medium.com/binar-academy/android-kotlin-code-quality-check-using-detekt-and-git-hooks-pre-push-mac-and-linux-556c111bc71b?source=rss-218d8f355bf3------2</link>
            <guid isPermaLink="false">https://medium.com/p/556c111bc71b</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[heri sulistiyanto]]></dc:creator>
            <pubDate>Tue, 30 Oct 2018 04:42:11 GMT</pubDate>
            <atom:updated>2018-12-05T19:47:52.339Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rh65j8Nne4gKJ7OGQJUdfw.jpeg" /><figcaption>quality check</figcaption></figure><p>Lately on Android apps development in my team sometimes forget to check their code before push or raise merge request into protected branch. So I decide to put <em>filter</em> before they push their code into their feature branch using Git hooks.</p><p>As i mentioned before on my story, we use <a href="https://github.com/arturbosch/detekt"><strong><em>Kotlin Detekt</em></strong></a> as static code analyser (<a href="https://medium.com/@heri.sulis/integrating-kotlin-detekt-cli-on-android-gradle-task-a02ca0378dcc"><strong><em>here</em></strong></a>) on gradle task. Sometimes member of the team forget to run it, and as a result I have to put several comment on their merge request which can be prevented before it raised.</p><blockquote>Ok, so let’s begin. . .</blockquote><p>So when we work with Git repo, in our project will have a directory named <strong><em>.git </em></strong>(it will showed up when you run <strong><em>ls -al</em></strong><em> </em>on your root project directory). And inside of this folder will contain several Git properties and one of it is a directory named <strong><em>hooks</em></strong> (.git/hooks). If we proceed to look inside of it, it will contain several of Git lifecycle which ended with <strong><em>.sample</em></strong>, for example :</p><pre>applypatch-msg.sample     post-update.sample        <br>pre-commit.sample         pre-push.sample           <br>pre-receive.sample        update.sample<br>commit-msg.sample         pre-applypatch.sample                      pre-rebase.sample         prepare-commit-msg.sample</pre><p>The <em>.sample </em>extension is work as a template and it can be override. So if we want to do something (<em>as my plan is to intercept before push, so we will focus on pre-push</em>).</p><p>The first step I did, I write a script named pre-push (without <em>.sample</em> at the end) and I save this script in path <em>${rootDir}/binar-common-config-android/hooks/</em></p><pre><strong>#!/bin/sh<br><br></strong><em>echo </em>&quot;Running static analysis...&quot;<br><br># Validate Kotlin code with detekt<br><em>./gradlew </em>app:detekt --stacktrace --no-daemon<br><br>status=$?<br><br><strong>if [ </strong>&quot;$status&quot; <strong>= </strong>0<strong> ] </strong>; <strong>then<br>    </strong><em>echo </em>&quot;Static analysis found no issues. Proceeding with push.&quot;<br>    <em>exit </em>0<br><strong>else<br>    </strong><em>echo 1&gt;&amp;2 </em>&quot;Static analysis found issues you need to fix before pushing.&quot;<br>    <em>exit </em>1<br><strong>fi</strong></pre><p>As you can see on the script above, it just a simple script to run task named <strong>detekt</strong> and it will check the status result. If there is <strong>0</strong> then no issue found and vice versa.</p><blockquote>So how we can run this script and add this script to all of my team member?</blockquote><p>The second step is, I write a gradle file named <strong><em>git-hooks.gradle </em></strong>which it looks like this :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d312c35308312e864c9b5cd1dab2478f/href">https://medium.com/media/d312c35308312e864c9b5cd1dab2478f/href</a></iframe><p>As you can see on <em>git-hooks.gradle</em> above, I write 2 tasks:</p><p><strong>copyGitHooks</strong> :</p><p>this task will copy our <strong><em>pre-push</em></strong> script into ${rootDir}/.git/hooks</p><p><strong>installGitHooks</strong> :</p><p>This task will do something as the same as we run <em>chmod +x</em> to our pre-push script file</p><p>On after evaluate block, we can see that clean &amp; assemble depending on installGitHooks, that mean if we run one of the task (<em>./gradlew clean</em> or <em>./gradlew assemble</em>) it will install our pre-push script.</p><p>When the pre-push script already installed, every time we want to push our code into remote repo, it will check our code first by running <strong><em>detekt</em></strong> task before it can proceed to push step.</p><p>Ok, that’s it . . quite simple right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*Sr9W1z8KUc81MyChExEPKg.gif" /><figcaption>bravo</figcaption></figure><p>If you find this article is helpful please give your warmest clap :)</p><p>Thanks</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=556c111bc71b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/binar-academy/android-kotlin-code-quality-check-using-detekt-and-git-hooks-pre-push-mac-and-linux-556c111bc71b">Android Kotlin Code Quality Check using Detekt and Git Hooks Pre-push (Mac and Linux)</a> was originally published in <a href="https://medium.com/binar-academy">Binar Academy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>