Android Developer Reference

repository·main·Indexed 43 days ago

https://github.com/imangazalievm/android-developer-reference

A curated reference for Android developers covering the full development lifecycle. Topics include Java and Kotlin languages, Android system internals (Zygote, Dalvik/ART), SDK components, Jetpack libraries (Compose, Room, WorkManager), app architecture (MVVM, MVI, Clean Architecture), Android NDK with JNI and FFmpeg, and DevOps practices. Includes a curated 'Android Developer Arsenal' of industry-standard libraries for dependency injection, data management, UI, and testing.

Tokens
10.2K
Snippets
15
Records
80
Agent score
57%

What's inside Android Developer Reference

  1. Explore the Android Developer Reference topics

    main

    The android-developer-reference repository is a comprehensive collection of documentation and guides for Android development. It covers everything from core languages (Java, Kotlin) and Android internals to modern Jetpack libraries, app architecture patterns, and DevOps practices.

    Key knowledge areas include:

    • Languages: Deep dives into Java (Collections, Reflection, Concurrency, JVM) and Kotlin (Basics, Extensions, Coroutines, Channels & Flows).
    • Android Fundamentals: System internals (Zygote, Dalvik/ART), SDK components (Activities, Fragments, Services, Permissions), and UI development (Views, Animations, RecyclerView).
    • Modern Android Development: Jetpack libraries (Compose, Room, WorkManager, ViewModel), App Architecture (MVVM, MVI, Clean Architecture), and Dependency Injection (Dagger & Hilt).
    • Infrastructure & Tools: Testing & Debugging, Gradle, ProGuard, Mobile DevOps (CI/CD, Docker), and Android NDK (C++, JNI, CMake).
    • External Services: Firebase integration (Crashlytics, Realtime Database, Messaging).
  2. Explore Jetpack components and guides

    main

    This document serves as a central index for Android Jetpack libraries. It provides curated links to official documentation, deep-dive technical articles (Medium), and practical tutorials for the following core components:

    • App Startup: Optimizing application initialization.
    • Compose: Declarative UI development.
    • DataStore: Modern data storage solution.
    • LiveData: Observable data holder classes.
    • ViewModel: UI-related data holder and lifecycle management.
    • Paging library: Loading large datasets in chunks.
    • Navigation: Managing app flow and fragment/composable transitions.
    • WorkManager: Deferrable, guaranteed background execution.
    • Room: SQLite abstraction layer for local persistence.
  3. Understand the Java Memory Model (JMM)

    main

    The Java Memory Model defines how the JVM interacts with computer memory to ensure predictable behavior in multi-threaded applications. Key concepts include:

    • Shared Memory: How threads view memory.
    • Program Order & Synchronization Order: Rules governing the order of operations.
    • Happens-before: A formal relationship that guarantees memory visibility between threads.
    • volatile keyword: Ensures that changes to a variable are immediately visible to all threads and prevents instruction reordering.
    • Atomic Variables: Using classes like AtomicInteger to perform thread-safe operations without explicit synchronization.
  4. Manage Gradle Dependencies and Build Logic

    main

    When working with Gradle in Android development, consider the following:

    • Dependency Scopes: Understand the difference between implementation and api to control how dependencies are exposed to consumer modules.
    • Kotlin DSL: Use Kotlin DSL for writing build scripts. For sharing build logic, prefer composite builds over the older buildSrc approach.
    • Plugin Discovery: You can search for available Gradle plugins at plugins.gradle.org.
  5. Manage Fragments and the Back Stack

    main

    Effective Fragment management involves understanding the FragmentManager and how to handle the back stack. Key concepts include:

    • Back Stack Management: Controlling how users navigate back through fragment transactions.
    • Fragment Transactions: Using commit(), commitNow(), or custom backstack implementations for navigation.
    • FragmentFactory: Using custom factories to instantiate fragments with dependency injection.
    • Multiple Back Stacks: Managing separate navigation histories for different parts of the UI.
    <!-- Refer to: https://medium.com/@bherbst/managing-the-fragment-back-stack-373e87e4ff62 -->
  6. Master ConstraintLayout and MotionLayout

    main

    ConstraintLayout

    ConstraintLayout allows for building complex, flat view hierarchies by defining constraints between views.

    • Chains: Group related views together to control their distribution within a space.
    • Flow: A virtual layout helper that allows you to arrange views in a grid or flow pattern without nesting multiple layouts, improving performance.

    MotionLayout

    MotionLayout is a subclass of ConstraintLayout designed specifically for animating transitions between different constraint states.

    • Motion Editor: A visual tool for defining transitions.
    • Motion Paths: Allows you to define custom paths (e.g., curved paths) for views to follow during an animation.
    • States: You define ConstraintSets representing different UI states, and MotionLayout interpolates between them.
  7. Understand JVM Internals and Garbage Collection

    main

    The Java Virtual Machine (JVM) is the engine that runs Java code. Key components include:

    • ClassLoader Sub-System: Responsible for loading, linking, and initializing class files.
    • JIT Compiler: Just-In-Time compiler that improves performance by compiling bytecode into native machine code at runtime.
    • Garbage Collector (GC): Automatically manages memory by reclaiming heap space occupied by objects that are no longer reachable.
    • Class File Format: The structure of the .class files processed by the JVM.
  8. Use JNI for Kotlin/Java and C++ interoperability

    main

    JNI (Java Native Interface) is the mechanism used to allow code running in a virtual machine (like the ART) to call in native applications and vice versa.

    Key learning paths for JNI include:

    • JNI Primer: Use a JNI Primer and Cheat Sheet to understand function signatures and data type mapping.
    • Callbacks: Learn how to handle callbacks from C++ back to Kotlin/Java to create reactive native components.
    • Security: You can use the NDK to help secure sensitive data, such as storing API keys in native code to make them harder to extract via simple reverse engineering.
  9. Create Custom Views and use Android Canvas

    main

    When standard widgets are insufficient, you can create custom views by extending existing View classes or building from scratch using the Canvas API.

    Custom View Lifecycle:

    1. Constructor: Initialize attributes using AttributeSet.
    2. onMeasure: Define the size of the view.
    3. onLayout: Position the view and its children.
    4. onDraw: Use the Canvas object to render graphics.

    Drawing with Canvas:

    • Use Canvas methods to draw shapes, paths, bitmaps, and text.
    • Use Paint objects to define color, style (fill/stroke), anti-aliasing, and shaders (like gradients).
    • Clipping: Restrict drawing to a specific area using canvas.clipPath() or canvas.clipRect().
    • PorterDuff Modes: Use PorterDuff.Mode to define how a new drawing operation blends with the existing content on the canvas (e.g., SRC_OVER, DST_IN, MULTIPLY).