Friday, 31 July 2015

Solution To: cannot start Android Studio. No JDK found.


cannot start Android Studio. No JDK found. Please validate either ANDROID_STUDIO_JDK, or JDK_HOME or JAVA_HOME points to valid JDK installation. ECHO is off. Press any key to continue


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. 

Select Start menu > Computer > System Properties > Advanced System Properties. Then open Advanced tab > Environment Variables, add new system variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.7.0_21.

Solution To: Your Android SDK is out of date


Your Android SDK is out of date or is missing templates. Please ensure you are using SDK version 22 or later.


1) Run SDK Manager. Open your SDK manager in the ADT Bundle and update you Android SDK Tools from 21.1 to 22

For windows user the tools and other SDK packages are saved with the Android Studio application directory ie: \Users\AppData\Local\Android\android-studio\sdk\

For Mac: /Applications/Android\

2) Run Android Studio. Open the Configure > Project Defaults > Project Structure, set your project sdk is Android SDK. Then select SDK tab and select build target (eg: Android 4.2.2)

Download and Install Android Studio


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. For a summary of the latest changes to Android Studio, see the Android Studio Release Notes.

Project and File Structure

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 that provides quick access to the key source files of Android projects and helps you work with theGradle-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.

Figure 1. Show the Android project view.

Figure 2. Show 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 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.
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 to the segregated project view, select Project from the Project drop-down.

Other Android Studio views

When you use the Project view 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, including src/main/ andsrc/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. View Android Studio Project structure.
You can also customize the view of the project files to focus on specific aspects of your app development:
  • Packages
  • Project Files
  • Scratches
  • Problems
  • Production
  • Tests
For example, selecting the Problems view of your project displays links to the source files containing any recognized coding and syntax errors, such as missing an XML element closing tag in a layout file.
For more information, see IntelliJ project organization and Managing Projects.

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.

Debug and Performance

Android Studio provides a number of improvements to assist you in debugging and improving the performance of your code, including an improved virtual device management, inline debugging, and performance analysis tools.

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 Intel® x86 Hardware Accelerated Execution Manager (HAXM) emulator accelerator and creates a default emulator for quick app prototyping.
For more information, see Managing AVDs.

Inline debugging

Use inline debugging to enhance your code walk-throughs in the debugger view with inline verification of references, expressions, and variable values. Inline debug information includes:
  • Inline variable values
  • Referring objects that reference a selected object
  • Method return values
  • Lambda and operator expressions
  • Tool tip values
To enable inline debugging, in the Debug window click the Settings icon  and select the check box for Show Values In Editor.

Memory and CPU monitor

Android Studio provides a memory and CPU monitor view so you can more 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 the Android tab in the lower left corner of the runtime window to launch the Android runtime window. Click the Memory or CPU tab.

Figure 4. Monitor memory and CPU usage.

Heap dump

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

Figure 5. HPROF viewer with heap dump.
To create a snapshot of the Android app heap memory, click the Dump Java Heap icon () in the Memory Monitor. Android Studio creates the heap snapshot file with the filename in the Capturestab. Double-click the heap snapshot file to open the HPROF viewer.
To convert a heap dump to standard HPROF format in Android Studio, right-click a heap snapshot in the Captures view and select Export to standard .hprof.

Allocation tracker

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.

Figure 6. Allocation tracker.
Perform the following steps to track and analyze allocations:
  1. Click the Start/Stop Allocation Tracking icon () in the Memory Monitor. Android Studio starts tracking memory allocations.
  2. Perform the tasks whose mallocs you want to track.
  3. Click the Start/Stop Allocation Tracking icon again. Android Studio stops tracking mallocs and saves the data to a file named The resulting file appears in the Captures tab.
  4. Double-click the file to open it in the allocation viewer.
    The allocation viewer allows you to view and analyze the allocations your app made while running.

Data file access

The Android SDK tools, such as Systracelogcat, and Traceview, generate performance and debugging data for detailed app analysis.
To view the available generated data files, click Captures in the left corner of the runtime window. In the list of the generated files, double-click a file to view the data. Right-click any .hprof files to convert them to a standard .hprof file format.

Code inspections

In Android Studio, the configured lint and other IDE inspections run automatically whenever you compile your program. In addition to the configured lint checks, additional IntelliJ code inspections and annotation validation run to streamline code review.
Android Studio enables several lint 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 an inspection 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 also run lint inspections for a specific build variant, or for all build variants. You can configure the lint inspections that run by adding a lintOptions property to the Android settings in the build.gradlefile.
android {
    lintOptions {
       // set to true to turn off analysis progress reporting by lint
       quiet true
       // if true, stop the gradle build if errors are found
       abortOnError false
       // if true, only report errors
       ignoreWarnings true
You can also manage inspection profiles and configure inspections within Android Studio. Choose File > Settings >, expand the Editor options, and select Inspections. The Inspection Configuration page appears with the supported inspections.
Figure 5. Configure inspections.
Note: To change the behavior of specific inspection notifications, change the inspection severity, for example fromwarning to error.
To manually run inspections in Android Studio, choose Analyze > Inspect Code. The Inspections Scope dialog appears so you can specify the desired inspection profile and scope.

Running inspections from the command line

You can also run lint inspections from the command line in your SDK directory.
sdk$ lint [flags] 
Note: The lint --show and --list flags can be used to display the available issues and explanations.
For more information, see Improving Your Code with lint and lint tool.

Annotations in Android Studio

Android Studio supports annotations for variables, parameters, and return values to help you catch bugs, such as null pointer exceptions and resource type conflicts. The Android SDK Manager packages the Support-Annotations library in the Android Support Repository for use with Android Studio. Android Studio validates the configured annotations during code inspection.
To add annotations to your code in Android Studio, first add a dependency for the Support-Annotations library:
  1. Select File > Project Structure.
  2. In the Project Structure dialog, select the desired module, click the Dependencies tab.
  3. Click the  icon to include a Library dependency.
  4. In the Choose Library Dependency dialog, select support-annotations and click Ok.
The build.gradle file is updated with the support-annotations dependency.
You can also manually add this dependency to your build.gradle file, as shown in the following example.
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ''
    compile ''

Inferring nullability

A nullability analysis scans the contracts throughout the method hierarchies in your code to detect:
  • Calling methods that can return null
  • Methods that should not return null
  • Variables, such as fields, local variables, and parameters, that can be null
  • Variables, such as fields, local variables, and parameters, that cannot hold a null value
The analysis then automatically inserts the appropriate null annotations in the detected locations.
To run a nullability analysis in Android Studio, select the Analyze > Infer Nullity menu option. Android Studio inserts the Android @Nullable and @NonNull annotations in detected locations in your code. After running a null analysis, it's good practice to verify the injected annotations.
Note: The nullability analysis may insert the IntelliJ @Nullable and @NotNull annotations instead of the Android null annotations. When running a null analysis, manually search and replace any IntelliJ annotations or includecom.intellij:annotations:12.0 as a compile dependency in your build.gradle file. This example includes the IntelliJ annotations 12.0 library as a dependency in the build.gradle file:
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile ''
    compile ''
    compile 'com.intellij:annotations:12.0'

Validating annotations

You can also manually add nullability, resource, and enumerated annotations throughout your code to perform validations for a variety of reference values, such as R.string resources, Drawable resources, Color resources, and enumerated constants.
Run Analyze > Inspect Code to validate the configured annotations.
For a complete list of the supported annotations, either use the auto-complete feature to display the available options for the import statement or view the contents of the Support-Annotations library.
For more details about Android annotations, see Improving Code Inspection with Annotations.

Dynamic layout preview

Android Studio allows you to work with layouts in both a Design View
Figure 6. Hello World App with Design View.
and a Text View.
Figure 7. 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 8. Multi-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) by clickingAndroid 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.

Install iOS into Android Phone


Android Hacks - Dual-Boot iOS on Your Android Phone

The Gadget Hacks team has built a simple one-tap mod that allows you to dual-boot iOS on your Android phone right from your browser by utilizing a mobile-webkit buffer overflow, and taking advantage of the fact that both Android and iPhone CPUs use the same ARM instruction set. Using the same techniques, we've also built a way to dual-boot Android on an iPhone. Visit from your iPhone for that mod.

Minimum Requirements:

  • Android 4.0 or higher (yes, even Lollipop!)
  • 1 GB of free storage space

It's Safe:

  • No root required
  • 100% reversible (as easy as uninstalling an app)
  • None of your existing data will be touched (no need to reinstall apps or contacts)


  1. Browse to this page ( from your Android phone
  2. Tap the giant "Dual-Boot iOS" button below.
  3. That's it!

Wednesday, 29 July 2015


1) Run Android Studio
2) Create a new Android Studio Project
2) Create New Project
3) Update Build.Gradle (Module:App) File
4) Edit Layout File
5) Rebuild Project
6) Card View Layout Done.

1) Run Android Studio

2) Create a new Android Studio Project

MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 3.03.29 PM.png

2) Create New Project

 MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 3.04.25 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 10.02.35 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 3.07.37 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 3.08.57 PM.png

3) Update Build.Gradle (Module:App) File

Edit cardview compile codes in dependencies section:
compile ''

4) Edit Layout File

<RelativeLayout xmlns:android=""
   xmlns:tools="" android:layout_width="match_parent"
   android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

   <TextView android:text="@string/hello_world" android:layout_width="wrap_content"
       android:layout_height="wrap_content" />


               android:background="@mipmap/ic_launcher" />

               android:text="test" />

               android:text="123" />




5) Rebuild Project

MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 9.53.56 PM.png

6) Card View Layout Done.


Solution To: Error Class Not Found Widget.CardView

Solution To: Error "the following classes could not be found"
This error may occur if you add a cardview widget in layout file without adding the compile class reference in the build.gradle

1) Add the codes "compile ''" to the dependencies section of the file build.gradle (module:app)

2) Rebuild your project.


Solution To: Gradle DSL method not found: 'compile()'

1) Open the file build.gradle (Module:app)
2) Add the following lines to the dependencies section (look at the example above).

compile ''compile ''

Tuesday, 28 July 2015



0) Pre-requisite        
1) Download Android Studio Installer        
2) Run the installer        
3) Run Android Studio        
4) Download Android SDK and other related tools        

0) Pre-requisite

You need to install Java JDK first.
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.06.02 PM.png

1) Download Android Studio Installer

Download the Installer for Mac.
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 1.59.20 PM.png

2) Run the installer

MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.01.07 PM.png
Double-click the file and drag the icon to Applications folder.
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.01.47 PM.png

3) Run Android Studio

Follow the visual steps below.
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.18.21 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.18.57 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.19.15 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.19.58 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.20.46 PM.png

4) Download Android SDK and other related tools

Android Studio will automatically download the files.
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.22.27 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.48.53 PM.png
MacSSD:Users:user:Desktop:Screen Shot 2015-07-29 at 2.51.40 PM.png

10 Typical Programming Features Borrowed By Swift

10 Typical Programming Features Borrowed By Swift

1) Dictionaries (aka hash tables) -- from JavaScript

JavaScript programmers have long used square brackets to take in an integer as a traditional array or accept a string that then behaves like a hash table. Now Swift programmers can do the same thing. Apple calls the hash tables "Dictionaries" and offers a clean syntax for initializing them.

2)  Inferred data types -- from functional programming languages

Forcing variables to stick to a particular data type is an efficient way for programmers to catch bugs before the code even runs. The compiler checks data types and flags incompatibilities.
Of course, in modern programming, no one wants to spend all of those keystrokes specifying data types for every variable. Lately some of the best compilers have started inferring types from the data, which is usually easy to do when a variable is initialized. This began with some of the functional languages, like ML, and has since appeared in Haskell, Scala, and Opa, among others. Now that Microsoft added the feature to Version 3.0 of .Net, it's practically mainstream. Thanks to Swift, iOS developers can now save a few keystrokes, too.

3) Data structure declarations -- from C# and Java

What kind of data is stored in a data structure? Java introduced Generic types in Version 5 so that programmers could tell the compiler which data type will be pushed into the HashMaps, Arrays, or Collections. The greater-than and less-than symbols, aka angle brackets, specified what types would go inside. Around the same time, Microsoft added them to C#. Now it's Swift's turn to let programmers tell the compiler what to expect.

4) String templating -- from Cold Fusion, JSP, and others

Maybe computers worked with numbers long ago, but today it seems like most of a programmer's job is to glue together strings. Many programming tools offer ways to insert a variable's value into a template. Web tools such as Cold Fusion and Java Server Pages have long provided a simple way to mix data with HTML in templates.
Swift offers a sleek templating system with an escaped open parentheses, followed by the expression to evaluate, followed by a closed parentheses. Three extra characters may be the smallest number of keystrokes needed to offer this functionality.

5) Optional semicolons -- from JavaScript and Python

What's with all the semicolon hate? They're just a simple way for designating the end of a programming statement, but somehow a growing number of developers can't be bothered to type them.
In the past few years, some JavaScript and Python programmers have debated whether semicolons are truly optional. Is a semicolon necessary or merely good form? Swift weighs in definitely in the debate: Semicolons are optional at the end of lines. If you want to pack multiple expressions in the same line, you'll need a semicolon, but if you put them on individual lines, you don't need to wear out your right pinkie tapping the semicolon key.

6)Protocols (aka interfaces) -- from Java and C#

When programmers create elaborate object-oriented class structures in Java and C#, they often begin with an interface at the foundation. The interface is a basic class that defines the structure for all of the functions that the classes must offer if they want to fit the definition. Swift uses the term "protocol" for sketching out a blueprint for a collection of classes.

7)Tuples -- from Lisp and Python

Sometimes a method needs to return more than one value. Early languages like Lisp assumed that everything was a list or a tuple, and more modern languages like Python offer explicit syntax for matching up the N value returned from a method with the N variables that will be bound to them. Swift follows in this tradition.

8)Automatic reference (akin to garbage collection) -- from Java, C#, and (gasp) Objective-C

Early reports suggested that Swift was sporting garbage collection, those automatic routines that sweep through memory reclaiming bytes no longer in use. Java and C# programmers love garbage collection, at least until it causes their machine to freeze up for a second. Swift uses automatic reference counting, a similar solution that's been popular with Objective-C users. In this case, the acorn didn't fall far from the tree.

9) Signed and unsigned integers -- C# and Objective-C

Good system program often means working at the byte level. While some abstract languages, such as Java, have avoided the complexity of unsigned integers, other languages, such as C#, have embraced them. Swift offers signed and unsigned integers of one, two, four, and eight bytes -- just like Objective-C and all the better to hack.

10) Closures -- from Lisp and Scheme via JavaScript

JavaScript programmers love to pack up little anonymous bits of code and pass them around like functions. They picked up these closures from languages like Lisp and Scheme that fully developed the idea of Lambda functions. Swift now comes with closures and the ability to pass along functions as first-class objects.