Android Terminology Topics

Android SDK(Software Development Kit)

  • Like JDK of Java, The Android SDK (Software Development Kit) is a set of development tools and libraries provided by Google for creating applications for the Android operating system.
  • It includes a variety of components that enable developers to build, test, and debug Android apps.
  • Developers use the Android SDK to create a wide range of applications, including games, productivity apps, social media apps, and much more.
  • The SDK supports various programming languages, but Java and Kotlin are the most commonly used languages for Android app development.
  • Before starting Android app development, we need to download and install Android Studio, which comes bundled with the Android SDK and all the necessary tools to get started.
  • Some key components of the Android SDK are as follows:-
    • Android Emulator/Android Virtual Device(AVD):
      • The Android Emulator is a virtual device that allows us to run and test Android applications on our computer without needing a physical device.
      • The Android Emulator allows developers to run and test their apps on a virtual Android device without the need for a physical device.
      • The Android Emulator emulates the hardware and software of an Android device, making it an essential tool for Android development.
      • It comes with various pre-configured device profiles and allows for the simulation of different Android versions, API levels, and screen sizes.
      • it tests apps on different Android versions and device configurations without needing multiple physical devices.
      • It’s an essential tool for app testing across different Android versions and device configurations i.e. it simulates real-world conditions like incoming calls, text messages, location, network conditions, and more.
      • It emulates different device configurations, including various screen sizes, resolutions, and hardware specifications.
      • It supports hardware acceleration for faster performance.
      • It allows snapshot saving and quick boot for faster startup times.
      • It seamlessly integrates with Android Studio for easy deployment and testing of the applications.
      • It provides access to the Google Play Store (in some configurations) for testing app compatibility with Google services.
      • To Activate/Optimize Emulator Performance
        • Enable Hardware Acceleration by ensuring that Intel HAXM (Hardware Accelerated Execution Manager) is installed on Intel-based CPUs/systems.
        • Enable Hardware Acceleration for AMD processors, by enabling Hyper-V or WHPX (Windows Hypervisor Platform) options.
        • Increase the amount of RAM as possible and CPU cores allocated to the emulator for better performance.
        • Regularly check for updates to the emulator and system images to benefit from performance improvements and new features.
      • To Configure or Set up the Android Emulator
        • Download and install Android Studio from the official website.
        • Open/Launch Android Studio.
        • Go to Tools menu > click AVD Manager, or click the AVD Manager icon in the toolbar.
        • Click “Create Virtual Device” and choose a device definition that matches the type of device we want to emulate (e.g., Pixel 4, Nexus 5X).
        • Select the system image by choosing an Android version (API level) from the lists for the virtual device. Download it if it’s not already installed.
        • Configure AVD Settings by customizing advanced settings like RAM, internal storage, and more if needed.
        • Review the configuration and click “Finish” to create the AVD (Android Virtual Device).
      • To Launch/Execute the Emulator
        • Start/Open the Emulator in the AVD Manager, by clicking the play button next to the virtual device to start the emulator.
        • Deploy the created App by running the app from Android Studio, and choosing the emulator as the target device.
    • Android Debug Bridge (ADB):
        • ADB is a key part of the Android SDK.
        • Android Debug Bridge (ADB) is a versatile command-line tool that lets us communicate between a developer’s computer and a connected Android device or emulator.
        • It is used to perform various tasks/actions, such as installing and debugging apps, copying files back and forth, transferring files, and accessing the device’s shell.
        • It provides a command-line interface to the Android device.
        • It executes commands directly on the device.
        • It is used to Install, uninstall, and update apps.
        • It is helpful to clear app data and cache.
        • It starts and stops services, view system information, and more.
    • SDK Manager:
      • The SDK Manager is a tool within Android Studio that enables developers to download and manage the various components or versions of the Android Software Development Kit (SDK), which is necessary for developing Android applications., as well as additional development tools, platforms, and system images for testing on various Android devices.
      • The SDK Manager can be accessed through either Android Studio(common method) or as a Standalone tool using command line tools/DOS.

Through Android Studio :- Open and launch Android Studio – Go to Tools menu > choose/click SDK Manager – SDK Manager Window appears – In the SDK Manager window, multiple tabs like SDK Platforms, SDK Tools, and SDK Update Sites with different options.

      • By managing various SDK components effectively, we can ensure a smooth and efficient Android development process.
      • It helps in keeping the Android development environment up to date by regularly checking for updates. Thus, it easily updates installed components to the latest versions.
      • It also receives notifications about new updates.
      • It allows us to select specific packages/customizing installations to download and install, tailored to our development needs thus saving disk space.
      • It also supports component management such as:-
        • Android SDK Platforms:
        • Android SDK Tools: 
        • SDK Add-ons: This is an additional components and libraries provided by Google or third-party vendors.
        • System Images: This component is required for emulating different Android devices.
    • Android Virtual Device (AVD)/Emulator Manager:
      • The AVD Manager allows developers to create and manage virtual Android devices (AVDs) for use with the Android Emulator.
      • Developers can configure various aspects of the virtual device, such as screen size, Android version, and hardware specifications.
    • Android SDK Tools:
      • The SDK Tools include various command-line utilities, build scripts, and other development-related resources required for app development.
      • it helps in downloading and updating essential tools like Android Emulator, build tools, and platform tools.
    • Android SDK Build Tools:
      • These are a collection of command-line tools that automate the build process for Android apps.
      • The Build-Tools include tools necessary for building and compiling Android app projects, i.e. They compile code, package resources, and create the APK (Android Package) file that can be installed on devices.
    • Android SDK Platform Tools:
      • These tools contain essential platform-specific utilities or components like ADB, Fastboot, and other utilities for communicating with Android devices and emulators at a lower level.
      • It helps in downloading and installing different versions of the Android platform (e.g., Android 10, Android 11).
    • Android Support Library (now replaced by AndroidX):
      • This library provided backward compatibility for older Android versions and various additional features to enhance app development.
    • Android API Documentation:
      • The SDK comes with comprehensive documentation that covers all aspects of Android development, including APIs, classes, and guides.
    • Samples and Code Templates:
      • The SDK also provides sample projects and code templates to help developers get started with different app features and functionalities.

APK File

  • An APK file (Android Package Kit) is the package file format used by the Android operating system for the distribution and installation purposes of mobile apps.
  • An APK file contains all the necessary programming elements, such as the app’s code (such as .dex files), resources, assets, certificates, and manifest files, required for installing and running an Android application on a device.
  • Essentially, it’s a zip archive that includes everything needed for an Android application to run.
  • The developers create an Android app and compile it into an APK file using Android Studio, which is essentially a compressed archive in ZIP format.
  • To install an APK file on a device(smartphone), we typically need to enable “Unknown Sources” in the device’s security settings, allowing the installation of apps from sources other than the Google Play Store. Installing APK files from unknown sources can pose a security risk, as malicious APK files can contain malware. It’s important to download APK files from trusted known or unknown sources.
  • Besides the Google Play Store, APK files can be also distributed or installed through other app stores or directly by developers via websites or other means.

    Android Tool Repository

    • There is no official & specific “Android Tool Repository” maintained by Google or Android itself. But, the Android Open Source Project (AOSP) is a single entity. However, there are several repositories and tools related to Android development and AOSP available on various platforms and websites which are rich with various tools and resources that developers and users can access to build, modify, and enhance Android applications and devices.
    • ‘Android Tool Repository’ tools are typically available through different sources, including official Google resources, open-source projects, and third-party platforms.
    • As we understand the Android ecosystem is continuously evolving, and new resources and repositories emerge regularly.
    • Some common Android development resources and repositories are:-
      • Android Developer Website:
        • The official Android Developer website, maintained by Google, is a comprehensive resource for Android developers.
        • It provides documentation, tutorials, code samples, best practices, and guidelines for building Android apps.
        • Website: https://developer.android.com/
      • Android Open Source Project (AOSP):
        • AOSP is the open-source codebase of the Android operating system.
        • It includes the core components of Android and serves as the foundation for custom ROMs and other Android-based projects.
        • Website: https://source.android.com/
      • Android Studio IDE:
        • Android Studio is the official integrated development environment (IDE) for Android app development.
        • It offers a suite of tools and features to streamline the app development process.
        • Website: https://developer.android.com/studio
      • GitHub:
        • GitHub is a popular platform for hosting and collaborating on software projects, including Android apps and libraries.
        • Many open-source Android projects and tools are available on GitHub.
        • Website: https://github.com/
      • Android Developer Samples:
        • Google offers a collection of sample apps with source code that demonstrate various Android development techniques.
        • These samples are available on GitHub: https://github.com/android/ and on the official Android Developer website.
      • Android Arsenal:
        • Android Arsenal is a website that curates a collection of Android libraries and tools.
        • It’s a useful resource for discovering new and popular Android projects.
        • Website: https://android-arsenal.com/
      • XDA Developers:
        • XDA Developers is a well-known community forum focused on Android development and customization.
        • It contains discussions, guides, and tools related to Android devices and software.
        • Website: https://www.xda-developers.com/
      • Android Developer Documentation:
        • The official Android developer documentation provides comprehensive guides, API references, tutorials, and other resources for Android app development.
        • Website: https://developer.android.com/docs
      • Android SDK Tools:
        • The Android SDK (Software Development Kit) provides various tools and libraries required for Android app development.
        • We can download it through Android Studio’s SDK Manager.
      • Android NDK (Native Development Kit):
        • This kit is used to develop Android apps using native code (C/C++), the Android NDK is essential. Y
        • We can find information and download it on the official NDK website: https://developer.android.com/ndk
      • Gradle:
        • Gradle is the build automation tool used in Android Studio to manage dependencies and build Android projects.
      • Android Jetpack:
        • Android Jetpack is a suite of libraries and tools that make Android app development more efficient by providing a set of high-level APIs.

    Dalvik Virtual Machine(DVM)

    Link for Difference between DVM and ART

    • Dalvik Virtual Machine (DVM), is a virtual machine used in older versions of the Android operating system to run Android applications. However, with the release of Android 5.0 (Lollipop), the Android Runtime (ART) replaced Dalvik as the default runtime environment. ART uses Ahead-of-Time (AOT) compilation, in which apps are compiled to machine code before they are installed on a device. This offers improved performance compared to the Just-In-Time (JIT) compilation used by Dalvik.
    • Unlike JVM of Java which is a Stack-based VM while DVM is a register-based fast and occupies less memory virtual machine.
    • DVM supports the Android operating system only. 
    • ART brought various improvements over DVM, such as faster app startup times, reduced memory usage, and improved battery life.
    • The name Dalvik comes from a town in Iceland, which is the hometown of Dalvik’s developer, Dan Bornstein.
    • The Dex(Dalvik eXchange) compiler converts one or multiple class files(generated by the Java compiler using Java source codes) into a single .dex file that runs on the Dalvik VM.  Thus, the .dex tool transforms Java bytecode or class files to Dalvik bytecode/.Dex file. This .dex file is finally handled and processed by the Android Assets Packaging Tool (AAPT) and converted into an APK file as a packaging process. Finally, the DVM translates the Dalvik bytecode to binary machine code.

    Manifest File

    • A “manifest file” generally refers to the “AndroidManifest.xml” file which is an XML file that every Android app must include in its root directory.
    • It’s a critical component in an Android app project, which is actually a configuration file that provides essential information about the app to the Android operating system. The main activity (entry point) of the app is declared in the manifest, allowing the system to launch the app when it’s opened by the user.
    • The AndroidManifest.xml file is a required file in every Android app project because It contains metadata about the app, such as its package name, version, permissions, components (activities, services, broadcast receivers, content providers), and required hardware features.
    • It provides crucial information to the Android system about the app’s components, capabilities, permissions, and how the app should interact with the system and other apps.
    • The manifest file contains the major part of the app’s components, including:
      • Activities: User interface screens.
      • Services: Background processes.
      • Broadcast Receivers: Respond to system-wide events.
      • Content Providers: Manage shared app data.

    Thus, the AndroidManifest.xml file contains these mandatory elements/components and configurations, under the <application> XML  encapsulation.

    <manifest      xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.myapp">
    <application
        android:icon="@drawable/app_icon"
        android:label="@string/app_name">
        <activity
                   android:name=".MainActivity"
                    android:label="@string/app_name">
           <intent-filter>
                           <action android:name="android.intent.action.MAIN" />
                            <category android:name="android.intent.category.LAUNCHER" />
                      </intent-filter>
              </activity>
     </application>
         <uses-permission android:name="android.permission.INTERNET" />
    </manifest>
    • The manifest file lists the permissions the app requires to access certain features or resources on the device, such as accessing the internet, using the camera, reading contacts, etc. When users install the app, they’re informed about the permissions it needs.
    • The manifest XML file contains Intent filters that define how the app responds to various actions or intents. For example, which activities to launch when certain actions occur, like opening a URL or viewing a specific type of file.
    • The manifest file also stores App configuration which includes information like the app’s package name, version code, version name, minimum, and target SDK versions, and more. This helps the system identify and manage the app.
    • Various settings related to additional metadata that provides information to the app, such as the app’s labels, icons, theme styles, minimum required SDK version, target SDK version, etc., are defined in this manifest file. 
    • We can modify the AndroidManifest.xml file using a text editor or the built-in Manifest Editor in Android Studio. Any changes or additions to this file should be made with careful consideration, as incorrect configurations can affect the app’s behavior or prevent it from running as expected. But, it’s important to keep the manifest file accurate and up to date, especially when adding new components, permissions, or making changes to app configuration.

    Logcat 

    • Logcat is a powerful debugging tool provided by the Android operating system that allows developers to view and analyze log messages generated by their applications and the Android system itself from time to time.
    • It helps developers to track and understand the behavior of their apps, identify issues, and monitor the flow of information during app development and testing.
    • It’s a crucial tool for understanding our app’s behavior, tracking down issues, and ensuring a smooth app development and user experience.
    • In Android Studio, we can access Logcat by clicking on the “Logcat” tab at the bottom of the screen. We can choose different filters, highlight specific log levels, and search for specific text within log messages.
    • There are different types of Logcat information/checkpoints generated which have different meanings to track the issues of Android apps. These are –
      • Logging Messages:
        • In Android app development, we can use the Log class to output log messages at various levels of severity. The available log levels are:
          • Log.v(): Verbose
          • Log.d(): Debug
          • Log.i(): Info
          • Log.w(): Warning
          • Log.e(): Error
      • Viewing Logcat Output:
        • We can view log messages using Android Studio’s built-in Logcat viewer or through command-line tools like ADB Logcat.
        • Log messages are displayed in real-time, showing the log level, tag (a string identifier for the message source), and the message itself.
      • Filtering Logcat Output:
        • Logcat can display a lot of information, so filtering is essential.
        • We can filter by log level, application package name, or specific tags.
        • This helps us to focus on relevant information while ignoring unrelated messages.
      • Custom Tags:
        • Assigning custom tags to our log messages helps us to categorize and identify messages related to specific components or functionality within our app.
      • Debugging and Troubleshooting:
        • Logcat is an essential tool for diagnosing issues and debugging apps.
        • By analyzing log messages, we can trace the execution flow, understand the sequence of events, and identify potential errors or unexpected behavior.
      • Runtime Information:
        • Logcat is not only useful during development but also for monitoring apps in production.
        • It can provide valuable runtime information about the behavior of our app in real-world scenarios.
      • Security and Privacy Considerations:
        • While log messages are helpful for debugging, it’s important to avoid logging sensitive information, such as passwords or personal data. Log messages can be accessible to others if not properly secured.

    Gradle

    • Gradle is a powerful build system that provides flexibility and efficiency in building Android applications.
    • Gradle is an advanced build automation tool that is used for building, testing, and deploying Android applications.
    • It integrates with Android Studio, the official IDE for Android development, to manage dependencies, define build configurations, and automate various related tasks.
    • By understanding how to configure and use Gradle, we can effectively manage dependencies, build configurations, and automate tasks to streamline your development process.
    • Gradle tasks can be run from the command line or within Android Studio.
    • We can view and run tasks from the “Gradle” tool window. For this, expand the tasks under our project and double-click to run it.
    • To run a specific task, navigate to the project directory and run that task using ./gradlew <task-name> at the command line prompt.
    • Components of Gradle in Android Studio
    The major components of Gradle are –
      1. Build Scripts: Gradle uses two main build scripts in Android projects:
        • build.gradle (Project Level): It configures the build for the entire project, including repositories and dependencies. This file is located at the root of your project directory and is used to configure the build for all sub-projects/modules.
        • build.gradle (Module Level): It configures the build for a specific module, such as an app module, including dependencies, build types, and product flavors. This file is located in each module directory (e.g., app/build.gradle) and is used to configure the build for that specific module.
      2. Gradle Wrapper: It ensures that the correct version of Gradle is used to build the project. It consists of files like gradlew, gradlew.bat, and the gradle directory.
      3. Dependencies:
        • It includes libraries or modules that the project relies on.
        • Dependencies can be managed and declared in the build.gradle files.
        • Dependencies are libraries or frameworks that your project depends on.
        • They are declared in the dependencies block at the module-level build.gradle file.
        • Types of Dependencies
          • implementation: This dependency is used in the compilation and runtime but not exposed to other modules.
          • api: This dependency is exposed to other modules that depend on this module.
          • test implementation: This dependency is only available in the test source set.
          • android Test Implementation: This dependency is only available in the Android test source set.
    • Gradle allows us to create different build variants and product flavors to manage multiple versions of our app. It includes –

    Build Types

      • This defines different build configurations such as debug and release.

    Product Flavors

      • This part creates different versions of our app, such as free and paid versions.

    Toast

    • Toast is a form of short alert message shown on the Android screen for a short interval of time.
    • Android Toast is actually a short popup notification that is used to display information when we perform any operation/event in our app.
    • A Toast message disappears automatically after a short time. If a user wants to appear a permanently visible message, then a notification can be used.
    • A Toast in Android is a simple way to provide feedback to the user about an operation.
    • A Toast message appears on the screen for a short period of time and then disappears automatically.
    • It’s used primarily for quick messages that don’t require user interaction.
    • By using Toast, we can provide quick feedback to users in our Android app.
    • For more advanced or persistent messages, now Snackbar from the Material Design components are used, which offers more functionality and customization.
    • For example – 

    Toast.makeText(context, “Your message here”, Toast.LENGTH_SHORT).show();

    where context denotes the current activity, e.g., this or getApplicationContext().

    Your message here: The text to be displayed in the toast.

    Toast.LENGTH_SHORT: Duration for which the toast message is shown. It can also be Toast.LENGTH_SHORT (short duration) or Toast.LENGTH_LONG (long duration).

    • A complete program example regarding normal toast message is –

    package com.example.myapp;

    import android.os.Bundle;
    import android.widget.Toast;
    import androidx.appcompat.app.AppCompatActivity;

    public class MainActivity extends AppCompatActivity

    {
    @Override
    protected void onCreate(Bundle savedInstanceState)

    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Displaying a simple toast
    Toast.makeText(this, "Welcome to my app!", Toast.LENGTH_SHORT).show();
    }
    }

    • We can also customize the appearance of a toast by inflating a custom view and setting it on the toast.
    • We can change the position of a toast on the screen using the setGravity() method. eg.-

    Toast toast = Toast.makeText(this, "Positioned Toast", Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 0);
    toast.show();

    where

    Gravity.TOP|Gravity.CENTER_HORIZONTALis the position of the toast at the top center of the screen and

    0, 0 represents the offset for the X and Y coordinates.

    Categories: Android

    0 Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.