Usage within Dynamic Feature Modules

Google Play Dynamic Feature Delivery

Google Play Dynamic Feature Delivery allows certain features of your app to be delivered conditionally or downloaded on demand. To do that, first you need to separate these features from your base app into feature modules.

This allows to partition your Android app into a part that includes the Anyline SDK (on-demand module) and a part that doesn’t (base App). This means, that the size of the Anyline SDK (100-120MB) needs will only be downloaded by a user who specifically requests the Anyline Scanning functionality.

Explanation of the limitation

Because of a known limitation of Dynamic Feature Modules, some special precautions have to be taken to make it possible to use Anyline SDK within a Dynamic Feature Module.

Dynamic Feature Delivery has a known limitation: It isn’t possible to use Android WebView in an activity that accesses resources or assets from an optional module.

By default, the Anyline SDK uses WebView with local resources in the ScanView: The Visual Feedback Implementation, the WaterMarkImage.

Therefor separating the Anyline SDK out into an on-demand module works, but upon actually running the functionality a problem occurs because the aforementioned two factors collide:


A workaround for the aforementioned limitation consists of a combination of three measures:

  • You need to be using a license without watermark.

  • You don’t use “Live Preview” (i.e. the Blue overlayed Rectangles drawn over recognized characters). In this case you need to switch your viewConfig.json element viewPlugin→cutoutConfig→style from rect to animated_rect. Additional changes to the viewConfig.json might be necessary, such as adapting viewPlugin→cutoutConfig→maxWidthPercent: “90%” and viewPlugin→cutoutConfig→maxHeightPercent: “90%”.

  • In case a crash appears in relationship with MLKit, this StackOverflow answer provides the solution.

With this guide you should be able to use the Anyline Mobile SDK for Android from within a Dynamic Feature Module.