Introduction
AndroidUtilCode is a comprehensive utility library that bundles dozens of helper classes frequently needed in Android development. Rather than writing boilerplate for file I/O, permission checks, device info, or encryption from scratch, developers can rely on its well-tested, API-stable utility methods across projects.
What AndroidUtilCode Does
- Provides utility classes for activities, fragments, services, and broadcast receivers lifecycle management
- Offers file, asset, and shared-preferences read/write helpers with minimal boilerplate
- Includes device info, screen metrics, keyboard, and status-bar utilities
- Bundles encryption helpers for AES, DES, RSA, MD5, SHA, and Base64
- Supplies network, Wi-Fi, phone state, and connectivity check methods
Architecture Overview
The library is organized into two modules: utilcode (core utilities with no UI dependency) and utilcodex (AndroidX-compatible superset). Each utility is a standalone static-method class that initializes lazily from the Application context provided at startup. The modular design means unused classes are stripped by ProGuard or R8 during release builds.
Setup & Configuration
- Add the JitPack repository and the utilcodex dependency to your Gradle file
- Call Utils.init(application) in your Application.onCreate method
- Access any utility through its static class, e.g., FileUtils.copy(), ScreenUtils.getScreenWidth()
- ProGuard rules are bundled automatically via consumerProguardFiles
- Use the sub-library utilcode instead of utilcodex if you target the legacy support library
Key Features
- Over 30 utility categories covering nearly every common Android boilerplate task
- Consistent API surface with Javadoc for every public method
- Lightweight per-class footprint thanks to static utility design and tree-shaking support
- Built-in bus module for simple cross-component messaging without third-party event libraries
- Actively maintained with regular updates for new Android API levels
Comparison with Similar Tools
- Guava (Android subset) — broader scope but heavier; AndroidUtilCode is Android-specific and lighter
- Apache Commons Lang — Java-only utilities without Android-specific helpers like toast, permission, or screen utils
- Anko — Kotlin DSL extensions for Android, now deprecated; AndroidUtilCode is Java-first and still maintained
- AndroidX Core KTX — Kotlin extensions for Jetpack; AndroidUtilCode provides a wider utility surface for Java projects
- TinyPinyin / OkHttp — single-purpose libraries; AndroidUtilCode consolidates many small concerns into one dependency
FAQ
Q: Does it support Kotlin projects? A: Yes. All utilities are callable from Kotlin, and the library is compatible with Kotlin-based Android projects.
Q: Will it increase my APK size significantly? A: Unused utility classes are removed by R8/ProGuard, so the final impact is limited to the classes you actually reference.
Q: Is it compatible with Jetpack Compose? A: Non-UI utilities like FileUtils, EncryptUtils, and NetworkUtils work in any Android project. View-specific helpers are designed for the traditional View system.
Q: What is the minimum Android API level? A: The library supports API 14 and above, covering the vast majority of active Android devices.