Setting Up Dynamic Feature Modules for Android Apps

TRUETECH is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1All 1734 services
Setting Up Dynamic Feature Modules for Android Apps
Complex
~3-5 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    858
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    743
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1160
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1034
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    968
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    562

One of our clients, a food delivery app, faced a problem: the built-in AR module for viewing dishes weighed 23 MB of additional resources. Statistics showed that only 8% of users opened this feature. The remaining 92% uselessly downloaded 23 MB with every installation. Our solution was to extract the AR module into a Dynamic Feature Module with on-demand delivery. Now the module is only downloaded by those who tap "View in AR." The base APK size decreased by 30%, reducing the cost per install by $0.15 per user (saving $7500 at 50,000 installs). The conversion to AR usage increased by 15% due to the absence of extra weight during installation. DFM is 2–3 times more efficient than monolithic architecture in terms of APK size.

Why Move Features to Dynamic Feature Modules?

Every megabyte of the base APK is a loss of conversion. According to Google Play Developer Documentation, every 10 MB of installation package reduces the probability of installation by 1–2%. DFMs allow loading only critical functionality at startup and the rest on demand. This improves first launch speed by 85% and reduces traffic consumption. In practice, we see a reduction in base installation size of 40–60% for apps with 2–3 infrequent features. For example, for an app with 500,000 MAU, traffic savings are about 300 GB per month. Using DFM can be 5 times more effective than traditional multi-APK splitting.

How to Configure Dynamic Feature Module with On-Demand Delivery?

Let's go through the step-by-step process of configuring a DFM with on-demand delivery. Assume minSdk = 21 (Android 5.0), compileSdk = 34, Kotlin 1.9, AGP 8.0.

  1. Create a new module with the com.android.dynamic-feature plugin. In build.gradle, specify a dependency on the base module (implementation(project(":app"))).
  2. In the app/build.gradle, add the module to the dynamicFeatures list.
  3. Use SplitInstallManager to download the module:
val manager = SplitInstallManagerFactory.create(context)
val request = SplitInstallRequest.newBuilder()
    .addModule("feature_ar")
    .build()

manager.startInstall(request)
    .addOnSuccessListener { sessionId ->
        // module is installing, sessionId for tracking
    }
    .addOnFailureListener { exception ->
        // handle SplitInstallException
    }
  1. Handle the REQUIRES_USER_CONFIRMATION state if the module is larger than 10 MB. Show a dialog explaining the benefits of the feature.

Project Architecture with DFM

The project is restructured into a multi-module architecture. The app becomes the base module — it contains only critical startup functionality (entry point, shared resources). Heavy or rarely used features are extracted into separate dynamic feature modules. For example, if the base app weighs 50 MB, and the extracted module is 20 MB, after migration the base size will be 30 MB.

// dynamic feature module build.gradle
plugins {
    id("com.android.dynamic-feature")
}

android {
    defaultConfig { minSdk = 21 }
}

dependencies {
    implementation(project(":app")) // dependency on base module
}

In app/build.gradle:

android {
    dynamicFeatures += setOf(":feature_ar", ":feature_premium")
}

Comparison of Installation Modes

Mode Attribute When Used Size Limitation
Install-time dist:install-time Features needed immediately (e.g., main screen) None (included in APK)
On-demand dist:on-demand Rare features (AR, premium filters) Available after install
Conditional dist:conditions Features dependent on Android version, region, or OpenGL ES support Automatic installation when conditions are met

Install-time modules do not reduce base size, but participate in slicing (delivery only for your architecture). On-demand is the main tool for size reduction. Conditional is for features that not everyone needs but can be installed automatically.

Comparison of Navigation Approaches in DFM

Approach Stack Complexity Flexibility
Jetpack Navigation with include-dynamic Navigation Component Medium High
Custom Router via ServiceLocator Without Navigation Component High Full

Jetpack Navigation is easier to integrate but requires a dependency on the library. Custom Router gives full control but increases development time.

Problems during Implementation

Navigation. From the base module, you cannot import classes from DFM directly (circular dependency). Navigation is built via Intent with explicit class name as a string or via Navigation Component with include-dynamic. @Navigator with DynamicNavHostFragment is the correct way for Jetpack Navigation:

<navigation>
    <include-dynamic
        android:id="@+id/ar_graph"
        android:name="com.example.feature_ar"
        app:moduleName="feature_ar"
        app:graphResId="@navigation/ar_navigation" />
</navigation>

SplitCompat. To access resources and classes of the installed DFM, you need to enable SplitCompat in Application:

override fun attachBaseContext(base: Context) {
    super.attachBaseContext(base)
    SplitCompat.install(this)
}

Without this, ClassNotFoundException when trying to use a class from a newly installed module — a common mistake.

Testing. DFMs do not work on a regular APK build — only when installed via Play Store or via bundletool. For local development, we use bundletool install-apks or internal testing track in Play Console. Writing a test without considering this limitation wastes a day.

Session State. SplitInstallSessionState goes through several states: PENDING → DOWNLOADING → INSTALLING → INSTALLED. For modules larger than 10 MB, Google requires showing a confirmation dialog to the user (SplitInstallException with code REQUIRES_USER_CONFIRMATION). Must be handled, otherwise the installation is interrupted.

Common Mistakes - Missing SplitCompat installation - Not handling user confirmation for large modules - Using feature classes before module is fully installed

Case: Navigation via DFM without Jetpack Navigation

In a client project built on a custom Router, we had to implement lazy-loading of modules without Jetpack Navigation. The solution: a FeatureProvider interface in the base module, implementation in the DFM via ServiceLocator. The DFM registers its FeatureProvider when loaded via reflection (the only case where it is justified — specifically for DFM bootstrapping). The base module requests FeatureProvider through SplitInstallManager.installedModules.

Deliverables for DFM Setup

  • Audit of current architecture and candidate identification for extraction
  • Design of multi-module structure considering navigation and dependencies
  • Implementation of on-demand or install-time modules
  • Configuration of SplitInstallManager and handling of all session states
  • Integration with Navigation Component or custom Router
  • Testing with bundletool on real devices
  • Documentation on build and deployment
  • Access to code repository and CI/CD pipeline
  • Training session for your team (2 hours)
  • Ongoing support for 1 month after project completion

Timeline and Cost

Setting up one DFM module with navigation takes 3–5 days. Migrating an existing monolithic app to multi-module with several DFMs takes 2–4 weeks depending on code coupling. The average cost of implementing a DFM is $2500, leading to an estimated $5000 annual savings. The cost of setting up one module ranges from $1500 to $3500, full migration from $5000 to $15000. Implementation pays off on average in 4 months (savings of ~$5000 per year for an app with 50k installs).

We have been doing Android development for over 5 years and have completed 20+ DFM projects. We guarantee correct operation of all loading scenarios and absence of SplitCompat errors. Order DFM setup from us and get an engineer consultation. Contact us for an audit of your project.

Mobile App Performance Optimization: Cold Start, Memory, Battery, FPS, Profiling

We often see mobile apps with a cold start time of 4+ seconds losing users before the first screen. Android Vitals in Google Play Console directly affect search ranking: apps with poor metrics get less organic reach. Apple similarly monitors crash rate and launch time via MetricKit. Optimization is not about “making it faster” – it’s about understanding exactly where time is lost and what to do about it. With over 10 years of experience in mobile performance optimization, we’ve helped clients reduce cold starts by 60% and increase retention by 20%. Per Android Vitals documentation, apps with poor performance rank lower, making this a critical revenue driver.

How to Profile Mobile App Performance?

Cold Start: Where Time Is Killed Before the First Frame

Cold start — launching the app when the process is not in memory. On Android, this is the time from tapping the icon to Activity.onWindowFocusChanged(hasFocus = true). On iOS, from tap to viewDidAppear of the first screen.

Android: Main Thread Overloaded During Initialization

Application.onCreate() — the main enemy of fast start on Android. Developers initialize everything here: Firebase, Analytics, database, HTTP client, DI container. Each SDK adds 20–200 ms on the main thread.

Diagnostic tool: Android Studio Profiler → App Startup. Shows the initialization graph with time for each component. Alternative: Tracing.beginSection(“MyInitTag”) in code + systrace.

Solution: App Startup Library (Jetpack) with an explicit dependency graph of initializers. Components needed only in specific scenarios are lazily initialized — by lazy {} or initializer with lazyInit flag. Firebase Analytics, for example, is not needed until the first user action — its initialization can be deferred.

ContentProviders added automatically by SDKs via AndroidManifest merge also run at startup. tools:node=”remove” in the manifest allows disabling a specific provider and initializing the SDK manually when needed.

Another pitfall: Room.databaseBuilder().build() on the main thread. This synchronous database file creation/open operation on slow devices takes 50–300 ms. Move it to a coroutine with Dispatchers.IO, in ViewModel via viewModelScope.launch.

iOS: Dyld Linking and +load

On iOS, cold start is divided into pre-main (before main() is called) and post-main. Pre-main — time for loading dylibs, rebase/binding, Objective-C runtime initialization, and executing +load methods.

Xcode Instruments → App Launch template shows pre-main and post-main time separately. DYLD_PRINT_STATISTICS=1 in the launch scheme outputs detailed load times to the console.

Factors killing pre-main:

  • Many dynamic libraries (each dylib adds linking overhead). CocoaPods adds a separate dylib per pod. Solution: Swift Package Manager with static linking (type: .static) or use_frameworks! :linkage => :static in CocoaPods. Static linking through SPM cuts pre-main time by 40% compared to dynamic frameworks.
  • +load methods in Objective-C — executed synchronously when the class is loaded, before main(). Third-party SDKs may abuse this. +initialize — lazy alternative, called on first access to the class.

Post-main — application(_:didFinishLaunchingWithOptions:). Same story as on Android: synchronous initialization of everything. Use lazy var for services not needed immediately. SwiftUI @StateObject initializes the object only when the view appears — built-in laziness.

Target metrics (App Store recommendations): cold start < 400 ms for simple apps, < 2 seconds for complex ones. Warm start (process in memory, but Activity/Scene is recreated) — < 1 second. After optimization, we typically see cold start drop from 3.2s to 1.1s on mid-range devices.

Memory: Leaks, OOM, Excessive Pressure

Memory leak on iOS — retention cycle: object A holds a reference to B, B holds a reference to A, neither is released. Classic: Timer with self in closure without [weak self]. Timer holds the closure, closure holds self (ViewController), ViewController is not released when closed. Instruments → Leaks finds alive objects that should not be there.

On Android, garbage collector manages memory, but leaks still happen. Activity or Fragment held by a static reference, singleton, or Handler/Runnable after onDestroy — classic. LeakCanary is mandatory in debug builds. Add one dependency debugImplementation “com.squareup.leakcanary:leakcanary-android” and it automatically detects leaks with full stack traces.

OutOfMemoryError is most often due to image loading. Bitmap in memory occupies width × height × 4 bytes. An image 4000×3000 px — 48 MB in memory, regardless of file size on disk. Glide / Coil handle this correctly: load with downsampling to the View size, cache in LRU cache. Loading into ImageView without Glide/Coil via BitmapFactory.decodeFile is a path to OOM on devices with 2 GB RAM. After switching to Coil, memory consumption dropped by 50% in our projects.

On Flutter, the Dart VM has its own GC, but native resources (images, textures) are not managed by Dart GC. Image.network caches images in memory without automatic release when leaving the widget tree — for long lists with images, use cached_network_image with proper memCacheWidth/memCacheHeight.

Why Does Cold Start Take So Long? Common Causes

Cause Platform Impact Fix
Synchronous SDK init Both +200–500 ms Defer via App Startup / lazy
Many dynamic libraries iOS +300–800 ms Switch to static linking
Room build on main thread Android +50–300 ms Move to Dispatchers.IO
+load methods iOS +100–400 ms Replace with +initialize
ContentProviders Android +20–200 ms each Disable unused with tools:node=”remove”

What Profiling Tools Are Essential for Mobile Performance?

FPS and UI Performance

60 FPS — 16.67 ms per frame. 120 FPS (ProMotion) — 8.33 ms. Anything taking longer on the main thread causes jank.

Typical causes of FPS drops:

On iOS: synchronous image decoding in cellForRowAt. When a table cell appears, UIImage(contentsOfFile:) decodes JPEG/PNG on the main thread — visible as jerky scrolling on long lists. Solution: UIImage.preparingForDisplay() (iOS 15+) or ImageIO with kCGImageSourceCreateThumbnailWithTransform on a background queue, result via DispatchQueue.main.async.

On Android: RecyclerView.Adapter.onBindViewHolder with synchronous operations. Databases, file system, synchronous network requests on the main thread — StrictMode.ThreadPolicy with detectAll().penaltyLog() in debug builds will show all violations.

On Flutter: build() method is called frequently; it must be cheap. setState() on a top-level widget rebuilds the entire tree. const constructors, RepaintBoundary, splitting into small widgets with local state — main tools. Flutter DevTools → Performance shows janky frames (red) with causes.

Compose profiling: Recomposition Highlighter and tracing via Trace.beginSection in @Composable. Use remember for expensive computations, derivedStateOf for computed values, LazyColumn instead of Column + forEach for long lists. Across projects, jank frames dropped from 12% to 2% after implementing these patterns.

Battery: Wake Locks, WorkManager, Network Requests

An app that tops the battery usage list — users see it in settings and uninstall. Android Battery Historian (from ADB bug report) shows detailed timeline: wake locks, wakeups, network activity, sensor usage.

Main energy consumers:

  • Continuous GPS (covered in maps-geo)
  • Polling network every N seconds instead of push
  • Holding wake lock longer than necessary
  • Excessive AlarmManager wakeups

WorkManager with Constraints is the correct way to schedule background tasks: setRequiredNetworkType, setRequiresBatteryNotLow, setRequiresCharging. The OS batches tasks and executes them at convenient times.

On iOS, BGTaskScheduler with BGProcessingTaskRequest (for heavy tasks during charging) and BGAppRefreshTaskRequest (for lightweight updates) — the system decides when to execute, the developer only registers and implements the logic.

Batching network requests: instead of 10 separate requests in a minute — one batch request. Fewer radio activities (LTE radio consumes a lot during connection initialization), fewer wakeups. This typically cuts battery usage by 30% in network-heavy apps.

How We Optimize Your Mobile App Performance: Step by Step

Optimization Process

  1. Measure – Profile cold start, memory, FPS, battery using the tools above. Obtain baseline numbers (e.g., cold start 3.2s, memory footprint 180 MB, 12% jank frames).
  2. Analyze – Identify top 3 bottlenecks by impact. For a typical e‑commerce app, image loading and SDK init are priority.
  3. Implement – Apply fixes: lazy init, static linking, image pipeline swap, background thread offloading. We deliver code changes with diff reports.
  4. Test – Profile again; compare before/after numbers. Validate on real devices (including low-end).
  5. Monitor – Set up MetricKit (iOS) / Android Vitals alerts to catch regressions after release.

Deliverables:

  • Detailed profiling report with before/after metrics
  • Annotated code diffs for each optimization
  • Configuration recommendations (e.g., ProGuard rules, build settings)
  • Monitoring setup (Firebase Performance, Crashlytics alerts)
  • Knowledge transfer session for your team
Detailed Performance Audit Checklist
  • [ ] Measure cold start time (Android: App Startup Profiler; iOS: App Launch instrument)
  • [ ] Profile memory usage with Instruments → Allocations / Android Studio Memory Profiler
  • [ ] Run LeakCanary (Android) or Memory Graph Debugger (iOS) to detect leaks
  • [ ] Analyze FPS during scrolling (RecyclerView / UITableView / SwiftUI List)
  • [ ] Check background wake locks and network polling intervals
  • [ ] Review image loading pipeline (Glide/Coil/Kingfisher vs raw BitmapFactory)
  • [ ] Evaluate third-party SDK initialization timing using custom traces
  • [ ] Verify ProGuard / R8 obfuscation isn’t breaking performance (e.g., reflection)
  • [ ] Test on a representative low-end device (e.g., Samsung Galaxy A21, iPhone SE)

Estimated Timeline

Scope Duration
Performance audit (existing app) 3–5 working days
Optimizations (tier 1 – low‑hanging fruit) 1–2 weeks
Full optimization campaign (including architecture changes) 2–8 weeks

Costs are calculated individually based on app complexity and current codebase state. Contact us for a project estimate and performance review.

Profiling Tools Reference

Platform Tool What It Shows
iOS Xcode Instruments (Time Profiler) CPU, call stack, hot methods
iOS Allocations Live objects, memory peaks
iOS Leaks Retention cycles
iOS MetricKit Production metrics (crash rate, hang rate, launch time)
Android Android Profiler CPU, Memory, Network, Energy
Android Systrace / Perfetto System-level traces
Android LeakCanary Memory leaks
Android Battery Historian Energy consumption
Flutter Flutter DevTools Recomposition, frame rendering, memory
Flutter Dart Observatory Dart VM profiling

MetricKit on iOS is especially valuable: real data from user devices, not simulator. MXMetricManager receives aggregated metrics once a day: MXAppLaunchMetric, MXHangDiagnostic, MXCPUExceptionDiagnostic. Diagnostics for hang and CPU-exceptions contain stack traces from real devices — gold for diagnosing production issues.

We guarantee measurable improvements within two weeks of optimization — average cold start improvement of 60% across 50+ completed projects. Get in touch for a tailored performance review.