Android Studio

Android Studio is the official IDE for Android application development, based on IntelliJ IDEA. On top of the capabilities you expect from IntelliJ, Android Studio offers the following among many others:

  • Flexible Gradle-based build system
  • Build variants and multiple .apk file generation
  • Code templates to help you build common app features
  • Rich layout editor with support for drag and drop theme editing
  • lint tools to catch performance, usability, version compatibility, and other problems
  • ProGuard and app-signing capabilities
  • Built-in support for the Google Cloud platform, making it easy to integrate Google Cloud messaging and App Engine

If you're new to Android Studio or the IntelliJ IDEA interface, this section provides an introduction to some key Android Studio features.

Android project view

By default, Android Studio displays your project files in the Android project view. This view shows a flattened version of your project's structure, which provides quick access to the key source files of Android projects, and helps you work with the Gradle-based build system. The Android project view:

  • Shows the most important source directories at the top level of the module hierarchy
  • Groups the build files for all modules in a common folder
  • Groups all the manifest files for each module in a common folder
  • Shows resource files from all Gradle source sets
  • Groups resource files for different locales, orientations, and screen types in a single group per resource type

The Android project view shows all the build files at the top level of the project hierarchy under Gradle Scripts. Each project module appears as a folder at the top level of the project hierarchy, and contains these four elements at the top level:

  • java/: Source files for the module
  • manifests/: Manifest files for the module
  • res/: Resource files for the module
  • Gradle Scripts/: Gradle build and property files

Note

For example, the Android project view groups all the instances of the ic_launcher.png resource for different screen densities under the same element.

The project structure on disk differs from this flattened representation. To switch back to the segregated project view, select your project from the Project drop-down menu.

Memory and CPU monitor

Android Studio provides a memory and CPU monitor view so that you can easily monitor your app's performance and memory usage to track CPU usage, find deallocated objects, locate memory leaks, and track the amount of memory the connected device is using. With your app running on a device or emulator, click on the Android tab in the lower-left corner of the runtime window to launch the Android runtime window. Click on the Memory | CPU tab.

When you're monitoring memory usage in Android Studio, you can initiate garbage collection, and dump the Java heap to a heap snapshot in an Android-specific HPROF binary format file at the same time. The HPROF viewer displays classes, instances of each class, and a reference tree to help you track memory usage and find memory leaks.

Android Studio allows you to track memory allocation as it monitors memory use. Tracking memory allocation allows you to monitor where objects are being allocated when you perform certain actions. Knowing these allocations enables you to adjust the method calls related to those actions to optimize your app's performance and memory use.

Memory and CPU monitor
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.129.253