0% found this document useful (0 votes)
37 views

Android Development Tool

Uploaded by

bhargavramkp02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Android Development Tool

Uploaded by

bhargavramkp02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

ANDROID DEVELOPMENT TOOL

To create an interactive and powerful application for android platform. The tools can be
generally categorized into two types.
 SDK Tools
 Platform Tools
SDK Tools

SDK tools are generally platform independent and are required no matter which android
platform you are working on. When you install the Android SDK into your system, these
tools get automatically installed. The list of SDK tools has been given below −
1. Android:This tool lets you manage AVDs, projects, and the installed components
of the SDK.
2. Ddms: This tool lets you debug Android applications.
3. Draw 9-Patch: This tool allows you to easily create a NinePatch graphic using a
WYSIWYG editor.
4. Emulator: This tools let you test applications without using a physical device.
5. Mksdcard: Helps you to create a disk image (external SDcard storage) that you
can use with the emulator
6. Proguard: Shrinks, optimizes, and obfuscates your code by removing unused
code.
7. Sqlite3: Lets you access the SQLite data file created and used by Android
applications.
8. traceview: Provides a graphical viewer for execution logs saved by your
application
9. Adb: Android Debug Bridge (adb) is a versatile command line tool that lets you
communicate with an emulator instance or connected Android-powered device.

Android

Android is a development tool that lets you perform these tasks:


 Manage Android Virtual Devices (AVD)
 Create and update Android projects
 Update your sdk with new platform add-ons and documentation
android [global options] action [action options]

DDMS

DDMS stands for Dalvik debug monitor server, that provide many services on the device.
The service could include message formation, call spoofing, capturing screenshot,
exploring internal threads and file systems e.t.c

Running DDMS

From Android studio click on Tools>Android>Android device Monitor.

How it works

In android, each application runs in its own process and each process run in the virtual
machine. Each VM exposes a unique port, that a debugger can attach to.

When DDMS starts, it connects to adb. When a device is connected, a VM monitoring


service is created between adb and DDMS, which notifies DDMS when a VM on the
device is started or terminated.

Making SMS: Making sms to emulator.we need to call telnet client and server as shown
below

Now click on send button, and you will see an sms notification in the emulator window. It is
shown below −

Making Call

In the DDMS, select the Emulator Control tab. In the emulator control tab , click on voice
and then start typing the incoming number. It is shown in the picture below −
Now click on the call button to make a call to your emulator. It is shown below −

Now click on hangup in the Android studio window to terminate the call.

The fake sms and call can be viewed from the notification by just dragging the notification
window to the center using mouse. It is shown below −

Capturing ScreenShot

You can also capture screenshot of your emulator. For this look for the camera icon on the
right side under Devices tab. Just point your mouse over it and select it.

As soon as you select it , it will start the screen capturing process and will capture whatever
screen of the emulator currently active. It is shown below −

The eclipse orientation can be changed using Ctrl + F11 key. Now you can save the image or
rotate it and then select done to exit the screen capture dialog.
Sqlite3

Sqlite3 is a command line program which is used to manage the SQLite databases created by
Android applications. The tool also allow us to execute the SQL statements on the fly.

There are two way through which you can use SQlite , either from remote shell or you can
use locally.

Use Sqlite3 from a remote shell.

Enter a remote shell by entering the following command −


adb [-d|-e|-s {<serialNumber>}] shell

From a remote shell, start the sqlite3 tool by entering the following command −
sqlite3

Once you invoke sqlite3, you can issue sqlite3 commands in the shell. To exit and return to
the adb remote shell, enter exit or press CTRL+D.

Using Sqlite3 directly

Copy a database file from your device to your host machine.


adb pull <database-file-on-device>

Start the sqlite3 tool from the /tools directory, specifying the database file −
sqlite3 <database-file-on-host>

Platform tools

The platform tools are customized to support the features of the latest android platform.

The platform tools are typically updated every time you install a new SDK platform. Each
update of the platform tools is backward compatible with older platforms.

Some of the platform tools are listd below −


 Android Debug bridge (ADB)
 Android Interface definition language (AIDL)
 aapt, dexdump , and dex e.t.c

launching your first android application

Here are some steps to build your first Android app using Android Studio:

1. Open Android Studio


2. Select Start a new Android Studio project
3. Choose Basic Activity
4. Name your application
5. Set the language to Java
6. Choose a template
7. Define a layout for each screen
8. Write code using Java
9. Build and run the app
10. Test and debug the app

Here are some other steps you can take to launch your app: Create a website with information
about your app, Establish a pricing approach, and Improve user experience.

Here are some steps you can take to launch an app successfully:

 Identify your market


 Validate your idea
 Research your competitors
 Define success criteria for your app
 Choose an App Store
 Submit your App
 Monitor reviews

Building your first Android application

Step 1: Create a new project

1. Select File > New Project.


2. Fill out the Create Android Project dialog, and click Next.
The requirements for the new project include:
 Application name
 Company domain (this gets reversed into com.domain) to keep applications
partitioned even if they have the same Application name.
 Project Location – where to store the files
 The Package name is suggested from the Application Name and Company
domain
 By default, Android applications are written in Java. If you want to support
alternate languages, such as C++ (for native code) or Kotlin, select the
appropriate check boxes.

3. On the Target Android Devices dialog, specify the API level and target platforms. As
mentioned earlier, Android is for more than just phones, though for our purposes we
will simply select the Phone and Tablet form. Then, click Next.
4. On the Add an Activity to Mobile dialog, select the Empty Activity type. Then,
click Next. This will create a default application ready to be built and run directly
from Android Studio.
5. On the Configure Activity dialog, name the files for the application.

Step 2: Review the code


The following figure shows the components of our new project:

There are two folders: app and Gradle Scripts.

 The app folder contains all of our application’s code.


 The manifests folder in the app folder contains AndroidManifest.xml which is the
deployment descriptor for this application. This file tells the Android device about
how to interact with the application, which Activity to show when the application is
started, which Intents the application services, which icons to display and much
more.
 The java folder contains the source code for the application. In this case, the file
which implements our activity plus a couple of class files for performing automated
tests (which we will ignore for this tutorial).
 The res folder contains the resources for the application, including icons, layout
files, strings, menus, and so on.
 The Gradle Scripts folder contains all of the scriptable elements for building the
application. The Gradle build system is a topic unto itself. For now, understand that
these scripts govern the process of building the application – and importantly for
more mature projects and teams, each of these steps is able to be run from the
command line. This is important because this approach supports automation and fall
into the category of Continuous Integration.

Primary activity for the application

Our sample application consists of a single activity, named MainActivity.

package com.navitend.saysomething;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import android.util.Log;
import android.widget.Button;
import android.widget.TextView;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Log.i("IBM","Hello there logcat!");

setContentView(R.layout.activity_main);

final Button btnHitMe = (Button) findViewById(R.id.hitme);


final Button btnMapMe = (Button) findViewById(R.id.mapme);
final TextView tvLabel = (TextView) findViewById(R.id.thelabel);
final EditText etLatitude = (EditText) findViewById(R.id.etLatitude);
final EditText etLongitude = (EditText) findViewById(R.id.etLongitude);
btnHitMe.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
tvLabel.setText("Ouch!");
}

}
);

btnMapMe.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

String coords = etLatitude.getText()+","+etLongitude.getText();


Log.i("IBM",coords);
Uri mapsIntentUri = Uri.parse("geo:" + coords);

Intent mapIntent = new Intent(Intent.ACTION_VIEW, mapsIntentUri);

startActivity(mapIntent);
}
}
);
}
}

Things to note about this source snippet:

 MainActivity is a normal Java class, with a package and imports, as expected.


 MainActivity extends a base Android class named AppCompatActivity, which is
located in the package named android.support.v7.app.
 The onCreate() method is the entry point to this activity, receiving an argument of
type Bundle. The Bundle is a class which is essentially a wrapper around a map or
hashmap. Elements required for construction are passed in this parameter.
 The setContentView(..) is responsible for creating the primary UI using
the R.layout.main argument. This is an identifier representing the main layout found
in the resources of the application. Note that any identifiers in the "R" class are
automatically generated by the build process. Essentially all of the xml resource
files under the res folder described earlier are accessed with the R class.

Resources for the application

Resources in Android are organized into a subdirectory of the project named res, as described
previously. Resources fall into a number of categories. Three of these categories are:

 Drawables - This folder contains graphics files, such as icons and bitmaps
 Layouts - This folder contains XML files that represent the layouts and views of the
application. These will be examined in detail below.
 Values - This folder contains a file named strings.xml. This is the primary means for
string localization for the application. The file colors.xml is useful for defining color
codes used by the application. This file is analogous to a css style sheet for those
familiar with web programming techniques.
Primary

UI resources in the main_activity.xml file

The sample application contains a single activity and a single view. The application contains
a file named main_activity.xml that represents the visual aspects of the primary UI of the
activity. Note that there is no reference in the main_activity.xml where the layout is used.
This means it may be used in more than one activity, if desired. See the following code listing

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="301dp">

<Button
android:id="@+id/hitme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hit Me!"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="383dp" />

<Button
android:id="@+id/mapme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Map Me!"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="460dp" />

</LinearLayout>

<TextView
android:id="@+id/thelabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Hello World, Say Something!!!!!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/etLatitude"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Latitude"
android:inputType="numberDecimal"
android:text="40.9241164" />

<EditText
android:id="@+id/etLongitude"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Longitude"
android:inputType="numberDecimal"
android:text="-74.7213913" />

</LinearLayout>

Step 3: Build the application

To build the application, select the wrench icon (looks more like a hammer to me) in the
menu of Android Studio.

The build process, as introduced earlier, is a multi-step process that may be customized for
any particular application. For this tutorial, we do not modify the build process. The output of
the build process should look something like this:

Step 4: Run the application

Now that the application has compiled successfully, it's time to run the sample application.

Earlier in this tutorial the AVD Manager was introduced as the means for configuring the
emulator for testing applications without the need for a real device. Running an application
by using the emulator is particularly useful because it permits testing without the need to
purchase numerous costly devices.

To setup an emulator, or more properly, an Android Virtual Device (AVD),


select Tools > AVD Manager. Or, simply click on the Play (Run) icon.

If there are connected devices, each shows up in the drop-down below Connected Devices.
Alternatively, select from one of the available Virtual Devices. In the previous figure, there is
a single AVD defined entitled Nexus One API P. To create a new AVD, select the Create
New Virtual Device button.

Finally, click OK to launch the application on the selected deployment target. The AVD or
emulator launches with our sample application running on it.

Step 5: Test the application in the emulator


Now that the application is running on the emulator, let's have a look at what is happening
behind the scenes. Within Android Studio, select View > Tool Windows. We will highlight
just a couple of these tool options, though each of them is a topic unto itself

Exploring the IDE:


An IDE (Integrated Development Environment) is software that combines commonly
used developer tools into a compact GUI (graphical user interface) application. It is a
combination of tools like a code editor, code compiler, and code debugger with an
integrated terminal. Integrating features like software editing, building, testing, and
packaging in a simple-to-use tool, IDEs help boost developer productivity. IDEs are
commonly used by programmers and software developers

Common Features of an IDE (Integrated Development Environment)


IDEs provide a broad variety of features which typically consist of:
 Editor: Typically a text editor can help you write software code by highlighting syntax
with visual cues, providing language-specific auto-completion, and checking for bugs as
you type.
 Compiler: A compiler interprets human-readable code into machine-specific code that
can be executed on different operating systems like Linux, Windows, or Mac OS. Most
IDEs usually come with built-in compilers for the language it supports.
 Debugger: A tool that can assist developers to test and debug their applications and
graphically point out the locations of bugs or errors if any.
 Build-in Terminal: Terminal is a text-based interface that can be used for
interacting with the machine’s operating system. Developers can directly run the scripts
or commands within an IDE with a built-in terminal/console.
 Version Control: Version control helps bring clarity to the development of the
software. Some IDEs also support version control tools like Git, through which a user
can track and manage the changes to the software code.
 Code snippets: IDEs support code snippets that are usually used to accomplish a single
task and can also reduce redundant work to some great extent.
 Extensions and Plugins: Extensions and Plugins are used to extend the functionality of
the IDEs with respect to specific programming languages.
 Code navigation: IDEs come with tools like code folding, class and method navigation,
and refactoring tools that make it simple to go through and analyze code.

Developers Use IDE (Integrated Development Environment)

IDEs can help improve a developer’s productivity, code quality, and overall development
experience.
 Productivity: By combining common activities such as editing code, building
executables, debugging, and testing as part of software/application development,
IDEs help by reducing time and increasing overall productivity.
 Code Quality: IDEs come with built-in tools as a part of a single GUI, through which
developers can execute actions without switching between applications. Furthermore, it
can also help in Syntax highlighting, code refactoring, and code analysis boosting
overall code quality.
 Integrated Environment: IDEs come pre-built with a combination of development
tools that allow developers to start programming new applications quickly. With
IDEs, it is no longer necessary to manually configure and integrate numerous utilities as
part of the setup procedure. Additionally, since every utility is available on the same
workbench, developers don’t have to spend hours learning how to use each one
separately.
 Customizability: By incorporating customization options ranging from custom color
schemes, and keyboard shortcuts, to choosing unique layouts, different plugins, and
add-ons; IDEs enable developers to customize their environment to their unique needs
and tastes, improving the comfort and efficiency of the development process.

Types of IDEs
IDEs come in various forms, some are designed to work for a specific language whereas
some are targeted to a particular platform like mobile devices. Hence, it becomes equally
important to choose an IDE best suited to one’s needs.
1. Desktop IDEs
This type includes the IDEs that can be configured locally. They do not need an active
internet connection to build/run programs. Desktop IDEs are highly customizable to suit
developer-specific needs and provide performance irrespective of the internet
speed. Examples: include Microsoft Visual Studio, Eclipse, Netbeans, etc.
2. Cloud IDEs
Cloud IDEs eliminate the overhead of configuring the software locally. They run on remote
servers and can be accessed through desktop browsers. Cloud IDEs provide better
accessibility and platform independence making them accessible through the Internet
Irrespective of the Client Operating System. Cloud IDEs can be used freely or can have
pricing models with respect to the provider. Examples: Include Gitpod, AWS Cloud 9,
Replit, etc.
3. Mobile App Development IDEs
These IDEs are specially designed for creating mobile applications. They include features
like Emulator support and integration for developing and testing mobile applications.
Mobile Development IDEs can be in the form of Desktop IDE or Cloud
IDE. Examples: Include Android Studio, Flutlab.io, etc.
4. Database-Specific IDEs
These IDEs (Integrated Development Environments) are specially designed for working
with databases. They include features like query builders and n for developing and testing
mobile applications. Like mobile-development IDEs, Database IDEs can also be in the form
of Desktop IDE or Cloud IDEs. Examples: Include MySQL Workbench, Oracle SQL
Developer, etc

Advantages of using IDE


Some of common advantages of IDEs or Integrated Development Environments are as
follows:
 Project Management: IDEs make viewing the project directory structure much simpler
which breaks down the tedious tasks of working with multiple files. Typically IDEs also
include a number of tools, such as syntax highlighting, code completion, and code
folding, which makes it easier to manage the overall project.
 Saving plenty of time and Effort: IDEs often include a variety of tools that can not
only assist you in organizing your code but also quickly highlight the error in your
code. They also include a flexible combination of tools for compiling, building, testing,
and deploying your code, through which you can automate these tasks eliminating the
need to manually run each task.
 Productivity: IDEs can increase your productivity by providing a centralized location
for all of your development needs, from writing and editing code to debugging and
deploying. Some of the functionality provided by IDEs can also be accomplished with a
text editor and command-line tools, but IDEs usually make the process more convenient
and user-friendly.
Disadvantages of using IDE
Some of common disadvantages of IDEs or Integrated Development Environments are as
follows:
 Not beginner Friendly: IDEs are complex tools and generally provide quite an
intimidating UI, which can be a little tough to comprehend for a beginner. Maximizing
their benefit generally needs a dedicated effort.
 Frequent Updates: It’s difficult to keep up with constant updates, such as new
samples, templates, and features.
 Only Assist in writing code: As a tool, IDEs (Integrated Development Environments)
are limited to being an assistant. They can’t write code or automatically fix errors, one
still needs the knowledge to write clean code.
 Cost: Some IDE is Expensive or needs additional costs to unlock some add-ons, which
can be a barrier for small-scale companies or learning Individuals.

https://www.jetbrains.com/help/idea/2023.3/using-breakpoints.html#breakpoint-properties

Debug your app

Android Studio provides a debugger that lets you do the following and more:
 Select a device to debug your app on.
 Set breakpoints in your Java, Kotlin
 Examine variables and evaluate expressions at runtime.
Debug code

During a debugging session, you launch your program with the debugger
attached to it. The purpose of the debugger is to interfere with the program
execution and provide you with the information on what’s happening under the
hood. This facilitates the process of detecting and fixing bugs in your program.

Before Debugging

1. Make sure the Generate debugging info option is turned on (the default setting) in Settings |
build, Execution, Deployment | Compiler | Java Compiler.

This setting is not absolutely required for debugging, however, we recommend leaving it
enabled. Disabling it allows you to save disk space at the cost of some debugger
functionality.

2. Configure common debugging properties and behavior in Settings | Build, Execution,


Deployment | Debugger.

If you are new to debugging, the out-of-the-box configuration will work for you. The topics
about each debugger functionality provide references and explain the related settings where
applicable. If you are an advanced user and looking for some particular property, see
the Debugger reference section.

1. Define a run/debug configuration if you are going to use a custom one. This is required if you
need some arguments to be passed to the program or some special activity to be performed
before launch.

General debugging procedure


There is no one-size-fits-all procedure for debugging applications. Depending on actual
requirements, you may have to use different actions in a different order.
1. Define where the program needs to be stopped. This is done
using breakpoints. Breakpoints are special markers, which represent places and conditions
when the debugger needs to step in and freeze the program state. A program, which has been
frozen by the debugger is referred to as suspended.

The alternative to using breakpoints is manually suspending the program at an arbitrary


moment, however this method imposes some limitations on the debugger functionality and
doesn't allow for much precision as to when to suspend the program.

2. Run your program in debug mode.

Just like with regular running of the program, you can run multiple debugging sessions at the
same time.

3. After the program has been suspended, use the debugger to get the information about the state
of the program and how it changes during running.

The debugger provides you with the information about variable values, the current state of
the threads, breakdown of objects that are currently in the heap, and so on. It also allows you
to test your program in various conditions by throwing exceptions (for example, to check
how they are handled) or running arbitrary code right in the middle of the program execution.

While these tools let you examine the program state at a particular instant,
the stepping feature gives you the control over step-by-step execution of the program. By
combining the tools you can deduce where the bug is coming from and test your program for
robustness.

4. When you have determined what needs to be fixed, you can do it without terminating the
session. For this purpose, IntelliJ IDEA provides a functionality allowing you to adjust and
5. reload pieces of your code on the fly. This approach is covered in the Reload modified
classes topic.
Breakpoints

Breakpoints are special markers that suspend program execution at a specific point. This lets you examine the program state
and behavior. Breakpoints can be simple (for example, suspending the program on reaching some line of code) or involve more
complex logic (checking against additional conditions, writing log messages, and so on).

Once set, a breakpoint remains in your project until you remove it explicitly, except for temporary breakpoints.

Types of breakpoints
The following types of breakpoints are available in IntelliJ IDEA:

 Line breakpoints: suspend the program upon reaching the line of code where the breakpoint was set. This type of
breakpoints can be set on any executable line of code.
 Method breakpoints: suspend the program upon entering or exiting the specified method or one of its
implementations, allowing you to check the method's entry/exit conditions.
 Field watch points : suspend the program when the specified field is read or written to. This allows you to react to
interactions with specific instance variables. For example, if at the end of a complicated process you are ending up with an
obviously wrong value on one of your fields, setting a field watchpoint may help determine the origin of the fault.
 Exception breakpoints: suspend the program when Throwable or its subclasses are thrown. They apply globally to
the exception condition and do not require a particular source code reference.

You might also like