8
Android basic application file structure (https://kickwe.com/tutorial/andr oid-development-tutorial/) 10th Feb 2017 | Android Development Tutorial (Https://Kickwe.Com/Tutorial/Category/Android-Development-Tutorial/) | 0 Comments (Https://Kickwe.Com/Tutorial/Android-Development- Tutorial/#Respond) | Post Views:0 (https://kickwe.com/tutorial/android-development-tutorial/) Android development tutorial- android basic project file structure should be your first step to learn Android application development. Difficulty Level: Easy Duration: 30 minutes or less Application: Nothing , just patience and understanding. Before we move forward to learn Android development tutorial

Android development-tutorial-android-basic-project-file-structure

Embed Size (px)

Citation preview

Page 1: Android development-tutorial-android-basic-project-file-structure

Android basic application filestructure(https://kickwe.com/tutorial/android-development-tutorial/)

10th Feb 2017 |

Android Development Tutorial(Https://Kickwe.Com/Tutorial/Category/Android-Development-Tutorial/) |

0 Comments (Https://Kickwe.Com/Tutorial/Android-Development-Tutorial/#Respond) |

Post Views:0

(https://kickwe.com/tutorial/android-development-tutorial/)

Android development tutorial- android

basic project file structure should be your

first step to learn Android application

development.

Difficulty Level: Easy

Duration: 30 minutes or less

Application: Nothing , just patience and

understanding.

Before we move forward to learn

Android development tutorial

Page 2: Android development-tutorial-android-basic-project-file-structure

from scratch; we must have to understand Android application

architecture. Which atually recognized by the android system

and IDE’s.

An Android application consists with many image-video-gif or

any media items, Graphical User Interface(GUI) design, System

information, Web information and interactions.

Let’s see a basic Android application structure. This tutorial

prepared in assistance for beginner’s level. That doesn’t show

you actual programming process but understanding the basic

project structure. Thus, it’s very effective in the process of

Android development tutorial.

Few things we need to keep in mind before we dive into this

android development tutorial :

1. Android application graphics is initially handled by XML but

you can also perform graphical stunt using Java.

2. Build.gradle is the core project class identification file where

we have to familiarize the application which are going to use.

Yes I Mean libraries and library resources.

(https://kickwe.com/tutorial/wp-

content/uploads/2017/02/android_beginners_tutorial.jpg)

Android basic project structure by kickwe

The infograph above shows you basic structure of android

source code. Let us go in deep.

Let’s assume you have created a new android project in

android studio named as kickwe. Navigate to kickwe folder. You

will see some files and folders. I’m mentioning only important

among them :

Page 3: Android development-tutorial-android-basic-project-file-structure

1. app (folder)

2. build.gradle (root project gradle file)

Here, app contains all the necessary files which we are going to

make. Some are automatically generated by android studio as

well.

Root build.gradle , this folder is very important. Here

you need to declare source of libraries which you are

going to mention in module build.gradle.

Example :

buildscript {

repositories {

jcenter()

}

Inside the app folder we will see below one folder named main.

Going through that main folder, there are few more files and

folders which play vital role regarding the android development

tutorial e.g:

build

It has all generated files made by the IDE. You don’t need to

worry about it,  those are automatically created. However for

some troubleshooting you might need to delete this libs folder

to reset & make further generated files.

libs

Above folder is initially empty. If you want to use any .jar library,

you can place them here. Any library will be automatically

added if you places .jar files e.g:volley.jar here (you will need to

declare that in module build.gradle).

build.gradle (module gradle file)

This is the build.gradle file where we are going to mention

about application supported os API, application version, all

libraries name we are going to use and apply any plugin if

necessary.

Example:

Page 4: Android development-tutorial-android-basic-project-file-structure

src contains only one important folder addressed as  main.

Inside, it has most important folder that contains two folders

and one file .

manifest.xml

This file provides essential information about your application to

the android operating system. This can be about required

permissions or activity lists and themes.

resres

layout

activity_main.xml

activity_second.xml

values

colors.xml

dimens.xml

strings.xml

styles.xml

drawable

menu

In res section there are several folders, let’s just notice what it

does but remember these are just for good practice and not

necessary to always maintain this.

Layout

1234567891011121314151617181920212223242526

android {    compileSdkVersion 23    buildToolsVersion "23.0.1"defaultConfig { applicationId "com.example.amigoo.myapplication" minSdkVersion 19 targetSdkVersion 23 versionCode 1 versionName "1.0" } dependencies { compile 'com.android.support:cardview-v7:+' compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.android.support:design:23.1.1'}

12345678910111213141516171819

//package name of the application  package=”com.example.kickwe.myapplication” //declares this application requires internet connection     <uses-permission android:name=”android.permission.INTERNET”/> //declares that you have an activity with specific activity name,theme <activity             android:name=”.MainActivity”             android:label=”@string/app_name”             android:theme=”@style/AppTheme.NoActionBar”> </activity>

Page 5: Android development-tutorial-android-basic-project-file-structure

Layout

It contains several XML files which is called through Java files.

Placing all your layout XML files here are good practice. So lets

follow those on our android development tutorial process.

Example :

activity_main.xml

activity_second.xml

Please note: xml file name can’t start with numeric number and

capital letter. Also there are limitations to use symbols as well.

values

It may contains 4 files.

1. colors.xml

2. dimens.xml

3. strings.xml

4. styles.xml

colors.xml usually contains all the colors used often in your

application. Specially the Google material design guideline

recommends you to define primary color, accent color and

primary dark. Indeed these are just proper way of android

application development, not obvious.

Example:

dimens.xml usually contains  frequently used dimensions in the

application.

Example:

strings.xml lists all the static strings you are going to use in the

application. You can also write directly string in other layout xml

or Java files but these is also part of good practise.

1234567891011

<?xml version=”1.0″ encoding=”utf-8″?> <resources> <color name=”colorPrimary”>#3F51B5</color> <color name=”colorPrimaryDark”>#303F9F</color> <color name=”colorAccent”>#FF4081</color> </resources>

1234567891011

<resources> <!– Default screen margins, per the Android Design guidelines. –> <dimen name=”activity_horizontal_margin”>16dp</dimen> <dimen name=”activity_vertical_margin”>16dp</dimen> <dimen name=”fab_margin”>16dp</dimen> </resources>

Page 6: Android development-tutorial-android-basic-project-file-structure

Example:

styles.xml defines overal theme preferences and connects with

colors.xml.

Example:

drawable

Mostly images used by the application which is user defined. It

can contain some xml that defines vector or svg images.

Remember , the application icon (ic_launcher.png)  also

belongs here.

Menu (optional)

along with other it’s menu.xml that provides menu item names.

Example:

java

1234567

<resources> <string name=”app_name”>kickwe Android development tutorial </string> <string name=”action_settings”>Settings</string> </resources>

1234567891011121314151617181920212223242526272829303132333435

<resources> <!– Base application theme. –> <style name=”AppTheme” parent=”Theme.AppCompat.Light.DarkActionBar”> <!– Customize your theme here. –> <item name=”colorPrimary”>@color/colorPrimary</item> <item name=”colorPrimaryDark”>@color/colorPrimaryDark</item> <item name=”colorAccent”>@color/colorAccent</item> </style> <style name=”ButtonGray”> <item name=”colorButtonNormal”>@color/colorAccent</item> </style> <style name=”AppTheme.NoActionBar”> <item name=”windowActionBar”>false</item> <item name=”windowNoTitle”>true</item> </style> <style name=”AppTheme.AppBarOverlay” parent=”ThemeOverlay.AppCompat.Dark.ActionBar <style name=”AppTheme.PopupOverlay” parent=”ThemeOverlay.AppCompat.Light” /> </resources>

12345678

<menu 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” tools:context=”com.android.development.tutorial.MainActivity”><itemandroid:id=”@+id/action_settings”android:orderInCategory=”100″android:icon=”@drawable/cart24″app:showAsAction=”always” /> </menu>

Page 7: Android development-tutorial-android-basic-project-file-structure

This is where you are going to program the application.

Ultimately you may have seen there are several folders inside

it, which is automatically generated according to your choice.

While you choose your package name at new project wizard of

Android studio.

Example : com.android.development.tutorial

PS: this can’t contain capital letter.

After that you will see only one class file made by Android

studio called activity_main.java

Alright now keep writing more on the blank project. How ? Next

we are going to start practice & experiment through various

example of Android development tutorial Ё

 

Post A Reply

Tags: android beginners tutorial

(https://kickwe.com/tutorial/tag/android-

beginners-tutorial/), android development

tutorial

(https://kickwe.com/tutorial/tag/android-

development-tutorial/), android

programming tutorial

(https://kickwe.com/tutorial/tag/android-

programming-tutorial/), download android

application source code

(https://kickwe.com/tutorial/tag/download-

android-application-source-code/)

(http://reddit.com/submit?url=https://kickwe.com/tutorial/android-development-tutorial/&title=Android basic application file structure)

(http://www.tumblr.com/share/link?url=https%3A%2F%2Fkickwe.com%2Ftutorial%2Fandroid-development-tutorial%2F&name=Android+basic+application+file+structure&description=Android+development+tutorial-+android+basic+project+file+structure+should+be+your+first+step+to+learn+Android+application+development.Difficulty+Level%3A+EasyDuration%3A+30+minutes+or+less+Application%3A+Nothing+%2C+just+patience+and+understanding.Before+we+move+forward+to+learn+Android+development+tutorial+from+scratch%3B+we+must+have+to+understand+Android+application+architecture.+Which+atually+recognized+by+the+android+%5B%26hellip%3B%5D)

Page 8: Android development-tutorial-android-basic-project-file-structure

All Right Reserved © KickWe (https://kickwe.com)

Full Name

Email

Website (optional)

Write your comment here

Post Comment