Skip to content

Instantly share code, notes, and snippets.

View mochadwi's full-sized avatar
I may be slow to respond.

Mochamad Iqbal Dwi Cahyo mochadwi

I may be slow to respond.
View GitHub Profile
mochadwi /
Last active September 3, 2021 10:26
How to check for transitive dependencies
$: ./gradlew :<your base module>:dependencies > dependencies.txt
$: # vim or nano `dependencies.txt`
$: vim dependencies.txt
$: # try to search the dependencies version used, to detect which transitive dependency making our build fails

If there's a problem with a specific version of your dependencies, try to search the version was pulled from which dependencies, e.g:

our current project dependencies has different version of androidx.test:monitor, see images

mochadwi /
Last active March 20, 2020 18:56
Passing extras with intent while using intent with action ACTION_GET_CONTENT
mochadwi / SafeActivity.kt
Last active February 16, 2020 15:46
Wrapper to handle nullable activity and returns non-null activity
fun Activity?.safeActivity(action: Activity.() -> Unit) {
val isActivityStillRuns = this != null && (!this?.isDestroyed() || !this?.isFinishing())
if (isActivityStillRuns) {
// usage:
fun initSomething() = this@YourActivity.safeActivity {
val adapter = YourAdapter(this, listOf())
mochadwi /
Last active April 5, 2020 04:58
Release script to automate versioning and git tagging


  • Add Triple-T dependencies
  • Setup the service account on GCP & link to Play Store (explained in the of Triple-T)
  • Create custom gradle task (to bump version) or see here
  • Use git-flow as branching model


  • Change $VERSION_NAME, $VERSION_CODE, $BUILD_GRADLE_FILE & $MODULE_NAME accordingly to your needs
mochadwi /
Last active October 8, 2020 06:33
(DEPRECATED) Extracting or Installing an AAB to APK.

DISCLAIMER, in Google Play Console you can download Universal APK directly. No need to use this extracting from AAB to APK method

Download Universal APK from AAB

Please make sure to run this script with your .aab file in the same folder.

The script has the following placeholders, which should be replaced for your specific environment/application:

  • $PASSWORD, $KEYSTORE_FILE, $ALIAS are the details used to sign the .aab in Android Studio
  • $PATH_TO_BUNDLE_TOOL is the path of the bundletool e.g. ~/Downloads/bundletool-all-0.8.0.jar
mochadwi /
Created November 21, 2019 11:14
Setup and Install JDK 8, 9, 10 in macOS with Homebrew

Oracle now force user to signup and accept the license agreement in the oracle website.

JDK 8 is still mostly used among java developer especially Android Developer.

Unfortunately, if we're on macOS there's a bad news that the homebrew community delete the entire JAVA/JDk cask and give replacement support to use AdoptOpenJDK.

brew tap adoptopenjdk/openjdk

brew cask install adoptopenjdk8
mochadwi / clean_architecture.txt
Created November 15, 2019 18:38 — forked from gpetuhov/clean_architecture.txt
Clean architecture tutorials (MVC, MVP, MVVM)
Detailed intro
Demo project
mochadwi /
Last active September 11, 2020 05:25
AndroidX manual Migration script: Class, Artifact & Themes

Inpsired by:

Why this?

  • Use the same script, with additional "artifact" mapping (
  • Skip any "build" directory, regardless of module name: app (app/build), abc (abc/build)
  • Support view binding please comment if the class mapping is not updated (official from google also still not updated)
mochadwi / adapter.kt
Last active July 14, 2019 12:46
ObservableField vs. LiveData
class Adapter(list: ArrayList<String>) : RecyclerView.ViewHolder(binding.root) {
// 02. using observablefield
// variable binding is your item.xml, generated into -> ItemBinding
lateinit val binding: ItemBinding // this should be defined on your project.
fun changeVariableA(msg: String) {
binding.apply {
message = msg
executePendingBindings() // directly tells the binding to be updated, without delay