Skip to content

Android Tooling

arteghem edited this page Jun 19, 2021 · 7 revisions

In order to ensure smooth adoption of the RIB architecture, we have built tooling to (1) make RIBs easier to use (2) take advantage by the invariants created by adopting RIBs. Tools we have open sourced are:

RIBs Code Generation Plugin for Android Studio and IntelliJ

We have created an Android Studio / IntelliJ plugin to generate RIBs scaffolding, making RIB usage and adoption easier. The scaffolded classes have RIB structures in place. Test scaffolding for classes that should have business logic is also generated for use.

After installing the plugin, RIBs can be added with the New -> New RIB... command. This generates:

  • Scaffolding: [RIBName]Builder, [RIBName]Interactor, [RIBName]Router and [RIBName]View
  • Test classes for unit testing: [RIBName]InteractorTest, [RIBName]RouterTest

RIBs can be generated with or without Presenter and View classes.

The RIB IntelliJ Plugin

RIB Tree visualization

IJ RIB tree snapshot

Plugin Installation Instructions

In Android Studio or Intellij, open IntelliJ IDEA > Preferences > Plugins and select Install Plugins From Disk. Then install the RIBs plugin jar. After this, the plugin will appear in the New menu.

Adding a new RIB from IntelliJ, after having installed the plugin

Plugin Build Instructions

To install the plugin locally:

  • Run ./gradlew :tooling:rib-intellij-plugin:buildPlugin -Dorg.gradle.configureondemand=true -Dbuild.intellijplugin=true
  • Install the jar file generated within build
  • Make sure you've installed the correct jar. If you install the wrong jar, you could see runtime crashes.

NullAway: Fast Annotation-Based Null Checking for Java

NullAway is the tool we built to help eliminate NullPointerExceptions (NPEs) in Java code. We use this tool on top of our RIBs stack for static analysis.

The project is open sourced on its own. You can read more about it and download it on the NullAway Github page.

AutoDispose Error Prone Checker

You can configure the RIB AutoDispose checker similarly to usage of NullAway. Once applied to your project you can't build your app when you forget to apply AutoDispose to an rx subscription inside a RIB. If you do forget you'll see an error like the following

error: [RxJavaMissingAutodisposeErrorChecker] Always apply an Autodispose scope before subscribing
        .subscribe(new Consumer<String>() {
                  ^

RIBs Flipper Plugin For Android

Flipper RIB tree snapshot

Once you've read through the documentation, learn the core concepts of RIBs by running through the tutorials and use RIBs more efficiently with the platform-specific tooling we've built.

Tutorial 1

iOS, Android

Tutorial 2

iOS, Android

Tutorial 3

iOS, Android

Tutorial 4

iOS, Android

Tooling

iOS, Android

Clone this wiki locally