Thursday, December 11, 2014

Android Studio "Unable to elevate [error:1812]


1) Convert the installer file into a CD Image (eg using Magic ISO Maker,

2) Install from CD Drive.

Wednesday, December 10, 2014

Installing Android Studio 2014

Installing Android Studio
Android Studio provides everything you need to start developing apps for Android, including the Android Studio IDE and the Android SDK tools.
If you didn't download Android Studio, go download Android Studio now, or switch to the stand-alone SDK Tools install instructions.
Before you set up Android Studio, be sure you have installed JDK 6 or higher (the JRE alone is not sufficient)—JDK 7 is required when developing for Android 5.0 and higher. To check if you have JDK installed (and which version), open a terminal and type javac -version. If the JDK is not available or the version is lower than 6, go download JDK.
To set up Android Studio on Windows:
  1. Launch the .exe file you just downloaded.
  2. Follow the setup wizard to install Android Studio and any necessary SDK tools.
  3. On some Windows systems, the launcher script does not find where Java is installed. If you encounter this problem, you need to set an environment variable indicating the correct location.
  4. Select Start menu > Computer > System Properties > Advanced System Properties. Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.7.0_21.
  5. The individual tools and other SDK packages are saved outside the Android Studio application directory. If you need to access the tools directly, use a terminal to navigate to the location where they are installed. For example:
  1. Android Studio is now ready and loaded with the Android developer tools, but there are still a couple packages you should add to make your Android SDK complete.
Android Studio Overview
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:
  • 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 Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine
  • And much more
If you're new to Android Studio or the IntelliJ IDEA interface, this page provides an introduction to some key Android Studio features.
For specific Android Studio how-to documentation, see the pages in the Workflow section, such as Managing Projects from Android Studio and Building and Running from Android Studio.
Project and File Structure
Android Project View
By default, Android Studio displays your profile files in the Android project view. This view shows a flattened version of your project's structure that provides quick access to the key source files of Android projects and helps you work with the new Gradle-based build system. The Android project view:
  • Groups the build files for all modules at the top level of the project hierarchy.
  • Shows the most important source directories at the top level of the module hierarchy.
  • Groups all the manifest files for each module.
  • 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.
Figure 1. Show the Android project view.
Figure 2. Project Build Files.
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 three elements at the top level:
  • java/ - Source files for the module.
  • manifests/ - Manifest files for the module.
  • res/ - Resource files for the module.
For example, Android project view groups all the instances of the ic_launcher.png resource for different screen densities under the same element.
Note: The project structure on disk differs from this flattened representation. To switch to back the segregated project view, select Project from the Project
New Project and Directory Structure
When you use the Project view of a new project in Android Studio, you should notice that the project structure appears different than you may be used to in Eclipse. Each instance of Android Studio contains a project with one or more application modules. Each application module folder contains the complete source sets for that module, includingsrc/main and src/androidTest directories, resources, build file and the Android manifest. For the most part, you will need to modify the files under each module's src/main directory for source code updates, the file for build specification and the files under src/androidTest directory for test case creation.
Figure 3. Android Studio project structure
For more information, see IntelliJ project organization and Managing Projects.
Creating new files
You can quickly add new code and resource files by clicking the appropriate directory in the Project pane and pressingALT + INSERT on Windows and Linux or COMMAND + N on Mac. Based on the type of directory selected, Android Studio offers to create the appropriate file type.
For example, if you select a layout directory, press ALT + INSERT on Windows, and select Layout resource file, a dialog opens so you can name the file (you can exclude the .xml suffix) and choose a root view element. The editor then switches to the layout design editor so you can begin designing your layout.
Android Build System
Android Build System
The Android build system is the toolkit you use to build, test, run and package your apps. This build system replaces the Ant system used with Eclipse ADT. It can run as an integrated tool from the Android Studio menu and independently from the command line. You can use the features of the build system to:
  • Customize, configure, and extend the build process.
  • Create multiple APKs for your app with different features using the same project and modules.
  • Reuse code and resources across source sets.
The flexibility of the Android build system enables you to achieve all of this without modifying your app's core source files. To build an Android Studio project, see Building and Running from Android Studio. To configure custom build settings in an Android Studio project, see Configuring Gradle Builds.
Application ID for Package Identification
With the Android build system, the applicationId attribute is used to uniquely identify application packages for publishing. The application ID is set in the android section of the build.gradle file.
    apply plugin: ''


applicationId ""
Note: The applicationId is specified only in your build.gradle file, and not in the AndroidManifest.xml file.
When using build variants, the build system enables you to to uniquely identify different packages for each product flavors and build types. The application ID in the build type is added as a suffix to those specified for the product flavors.
   productFlavors {
= ""
= ""

The package name must still be specified in the manifest file. It is used in your source code to refer to your R class and to resolve any relative activity/service registrations.
Note: If you have multiple manifests (for exmample, a product flavor specific manifest and a build type manifest), the package name is optional in those manifests. If it is specified in those manifests, the package name must be identical to the package name specified in the manifest in the src/main/ folder.
For more information about the build files and process, see Build System Overview.
Debug and Performance
Android Virtual Device (AVD) Manager
AVD Manager has updated screens with links to help you select the most popular device configurations, screen sizes and resolutions for your app previews.
Click the Android Virtual Device Manager in the toolbar to open it and create new virtual devices for running your app in the emulator.
The AVD Manager comes with emulators for Nexus 6 and Nexus 9 devices and also supports creating custom Android device skins based on specific emulator properties and assigning those skins to hardware profiles. Android Studio installs the the Intel x86 Emulator Accelerator (HAXM) and creates a default emulator for quick app prototyping.
For more information, see Managing AVDs.
Memory Monitor
Android Studio provides a memory monitor view so you can more easily monitor your app's memory usage to 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 the Memory Monitor tab in the lower right corner to launch the memory monitor.
Figure 4. Memory Monitor
New Lint inspections
Lint has several new checks to ensure:
  • Cipher.getInstance() is used with safe values
  • In custom Views, the associated declare-styleable for the custom view uses the same base name as the class name.
  • Security check for fragment injection.
  • Where ever property assignment no longer works as expected.
  • Gradle plugin version is compatible with the SDK.
  • Right to left validation
  • Required API version
  • many others
Hovering over a Lint error displays the full issue explanation inline for easy error resolution. There is also a helpful hyperlink at the end of the error message for additional error information.
With Android Studio, you can run Lint for a specific build variant, or for all build variants. You can configure Lint by adding a lintOptions property to the Android settings in the build.gradle file.
    android {
// set to true to turn off analysis progress reporting by lint
// if true, stop the gradle build if errors are found
// if true, only report errors
For more information, see Improving Your Code with Lint.
Dynamic layout preview
Android Studio allows you to work with layouts in both a Design View
Figure 5. Hello World App with Design View
and a Text View. 6. Hello World App with Text View
Easily select and preview layout changes for different device images, display densities, UI modes, locales, and Android versions (multi-API version rendering).
Figure 7. API Version Rendering
From the Design View, you can drag and drop elements from the Palette to the Preview or Component Tree. The Text View allows you to directly edit the XML settings, while previewing the device display.
Log messages
When you build and run your app with Android Studio, you can view adb and device log messages (logcat) in the DDMS pane by clicking Android at the bottom of the window.
If you want to debug your app with the Android Debug Monitor, you can launch it by clicking Monitor in the toolbar. The Debug Monitor is where you can find the complete set of DDMS tools for profiling your app, controlling device behaviors, and more. It also includes the Hierarchy Viewer tools to help optimize your layouts.