Adding a Simple Menu

Menus are a very typical UI component for any app.  A menu resource is shown in the toolbar of the app and allows the user to do common tasks such as saving information in an activity, accessing an options menu, and so on.  Here’s how you add a menu to an activity.

Add the Menu Resource Directory

Right click on the “Res” directory and go to New->Android resource directory.

Select “Menu” from the drop-down and click okay.

Create the Menu Resource File

Right click on your new “Menu” directory and click on New->Menu resource file.

Create the Options Menu From the Activity

In the activity that will host this menu, call this method.

public boolean onCreateOptionsMenu(Menu menu)
    getMenuInflater().inflate(, menu);
    return true;

Respond to Menu Item Clicks

public boolean onOptionsItemSelected(MenuItem item)
    if (item.getItemId() ==
    return super.onOptionsItemSelected(item);

There you have it.  A simple menu!

Android Studio Error Log

Here are all of the errors I’ve encountered in Android Studio, what they mean, and how to solve them.

(This will be updated regularly)

android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity; context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

I got this error by creating an adapter from MainActivity like this.

adapter = new MainCardAdapter(getApplicationContext());

Then in the adapter, I attempted to create a new Intent and start that Intent.

public MainCardAdapter(Context context)
    this.context = context;

public void onClick(View v)
    Intent i = new Intent(context, ResumeSectionsActivity.class);

The error came up because I was starting the new task from outside of the activity. I thought this was odd because I passed “GetApplicationContext()” for an argument. I thought that would include the MainActivity but apparently it does not. I fixed this error by sending “this” as an argument for context like so.

adapter = new MainCardAdapter(this);

The Floating Action Button

Floating Action Button’s are those neat little buttons you see generally in the lower right corner of an app. They perform some sort of positive action like creating something, like an email or a text. We’re going to see how to add a simple Floating Action Button (hereafter referred to as FAB) to an activity.

For an excellent list of design considerations when creating FAB’s, see Google’s page here.

Add the Gradle Dependency

In your “build.gradle (Module: app)” file, add the line

compile '’

Where the x’s are your apps support library version number. This should be the same as the ‘’ number.

Add an Image for Your FAB

Add a vector asset to be used in your button by right clicking on your Drawable folder, and going to New -> Vector Asset.


Before you finish adding the icon you want, (I added the plus symbol, called “ic_add”), change the word black to white. We won’t actually change the color here because we need to create the file first but it’s easier to change the name now than later.

Change the Icon Color

Once you’ve created the icon, it will be added to your Drawable folder. Double click on it to open the file. Change the fillColor from “#FF000000” to “FFFFFFFF”.

<vector xmlns:android=""

Now Code the FAB

Now add the Floating Action Button in your activity_main xml file.


AlignParentEnd and AlignParentRight are in there to support Right-To-Left (RTL) layouts, where the end would actually be the left.

If you add the FAB and get rendering errors, go to the Build menu and click on Clean Project. If this doesn’t fix it and you get an error that says “Exception raised during rendering: Unable to locate mode 0” this is because of a bug in the 25.0.0 library. Update your library and this should go away.


Respond to Clicks

Now in Main Activity, add the reference to the FAB and add the click listener

public class MainActivity extends AppCompatActivity
    FloatingActionButton fab;

    protected void onCreate(Bundle savedInstanceState)

        fab = (FloatingActionButton) findViewById(;
        fab.setOnClickListener(new View.OnClickListener()
            public void onClick(View view)
                Toast.makeText(getApplicationContext(), "I've been clicked", Toast.LENGTH_SHORT).show();

There you have it! A fine looking Floating Action Button!


RecyclerViews and CardViews

Recycler Views and Card Views

RecyclerView and CardView's are easy ways to add a professional look to your app.  They are good for previewing top level features of your app like, say, a concert.  Each card could be a different concert for bands the user likes.  When you click on the card, you are brought to a detailed page of the concert events like time, venue, ticket cost, etc. 

The RecyclerView is an advanced list-view-like feature of Android's material design.  It is meant to be used when the items in the list change during runtime in response to user interaction. 

The CardView is one item in the list except that the card can contain it's own custom layout that you define however you want. 

Here's how to use these features.

Start with the dependencies

First, open your build.gradle (Module:app) file and add the dependencies required for the CardView and RecyclerView.


Make sure the CardView and RecyclerView version's match the appcompat version number placed here when your project was created.

Create the CardView layout

Right click on your Layout folder and create a new layout.  I named mine c_main.xml (c for card).  Add this code to create the card. 

(As a side note here, I often prefix the layout name with the first letter of the type of layout it is.  a for activities, f for fragments, d for dialogs, etc.)

             android:text="Party on, Wayne"/>


If you switch to the design tab in the layout file and get some errors, follow its instructions and try to build your project.  If that fails, go to the Build menu at the top and click on Clean Project.


We'll also need to add a vector asset to use for the ImageView in the layout.  To do this, right click on your Drawable folder and go to New -> Vector Asset.


Choose an icon and finish importing it into your library.  It is now in your Drawable folder.  This is the drawable asset we referenced in the ImageViews "android:src..." attribute.  Change the name to the name of the image you used here.

Create a custom adapter

In order to use our cards, we must create an adapter.  The purpose of an adapter is to tell the cards what they should look like in the RecyclerView and what actions they should perform when interacted with, among some other bookkeeping items.  RecyclerView's are more complex so we must roll our own adapter when we use them. 

Right click on your project folder and add a new class.  I called mine MainCardAdapter.  Since you may have multiple CardView's in your app, I recommend naming them with the activity they will be used in.

This is the adapter.

public class MainCardAdapter extends RecyclerView.Adapter<MainCardAdapter.ViewHolder>
     private Context context;
     List<String> items; // This will hold the strings to display on each card.
     public MainCardAdapter(Context context)
         this.context = context;
         items = new ArrayList<>();
     // Inflate card view
     public MainCardAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int position)
         View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.c_main, viewGroup, false);
         return new ViewHolder(view);
     public int getItemCount()
         return items.size();
     public void onBindViewHolder(MainCardAdapter.ViewHolder viewHolder, int position)
     // Call from MainActivity to add cards
     public void AddCard(String message)
   // Separate class that is used to hold the individual views for each card
     public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
         public MainCardAdapter adapter;
         TextView tv;
         public ViewHolder(View view)
             // This is where you set individual view properties like onClickListeners...
             tv = (TextView)view.findViewById(;

        // This is where you set references to your View objects to interact with later.

        // This is also where you would put onClickListener properties and the like
         public void SetViews(MainCardAdapter adapter)
             this.adapter = adapter;

        // To detect a click on the whole card.  If you want to click on just one individual view, do that

        // in the above method
         public void onClick(View v)
             Toast.makeText(context, "You clicked card: " + getAdapterPosition(), Toast.LENGTH_SHORT).show();


I commented the most important pieces of this code so hopefully it makes sense.  If not, leave your questions below and I'll answer them!

Create the RecyclerView

In activity_main.xml, insert a RecyclerView like so. 


Wire it up!

This is the entire MainActivity class code.  Create a private method that will handle the initial setup of the RecyclerView.  Call adapter.AddCard("words"); to add cards.

public class MainActivity extends AppCompatActivity
    RecyclerView recyclerView;
    MainCardAdapter adapter;

    protected void onCreate(Bundle savedInstanceState)
        recyclerView = (RecyclerView)findViewById(;
        adapter.AddCard("Party on, Wayne");
        adapter.AddCard("Party on, Garth");

    private void SetupRecyclerView()
        recyclerView = (RecyclerView)findViewById(;
        recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
        adapter = new MainCardAdapter(getApplicationContext());

Now run your code!  When you click on the cards, you will get a toast notification telling you which number of card you clicked on.


When you're done it should look something like this.


There you have it, a simple RecyclerView!

We'll extend the functionality in a later post but if you'd like to play around with it, add some views on screen and interact with them by creating methods in the adapter.

Thanks for joining and leave a comment below if you have any questions.  I read them all!

Terms you Need to Know

Software Terms

  1. IDE - Integrated Development Environment.  This is where you will do all of your programming, debugging, editing, and publishing.  Basically, it is the piece of software that takes you from the very beginning of your project to the very end.  Android Studio is the IDE we will be using for Android apps.
  2. SDK - Software Development Kit.  This is the set of tools you will use to design your software for a specific platform.  We will be using the Android SDK which is included with Android Studio.  This will allow us to build Android apps, but unlike an IDE, cannot be used to build apps for other platforms.
  3. API - Application Program Interface.  These are sets of tools used to build specific more software.  Say you wanted to write an app that included a way to post to Facebook.  You would have to use one of Facebook's API's to interact with their platform.
  4. AVD - Android Virtual Device.  This is the emulator, a piece of software that will replicate the physical device you want to test your app on.  If you have an Android device, and its recommended that you have one if not more, you can use that too.  But an emulator allows you to set up different screen sizes, memory capabilities, pixel densities and much more.  You can test your app on a wide variety of different devices without having to shell out the money for them.

Android Terms

  1. Activity - An activity is just one page in an app.  The name Activity might lead you to believe that it is an action, or some sort of logic/system that gets performed but it is not.  It is just one page.  So an app can be made of several activities.  There are all sorts of derivatives of Activities but in the most basic sense, just remember that every page is it's own Activity
  2. View - This is any item on screen that either let's the user know some information about the page or let's the user interact with the app.  Examples of Views are check boxes, buttons, text views, and images.   So an Activity is comprised of one or more views and the views allow the user to make the app do what it is intended to do.
  3. Fragment - A fragment is a set of views that can be reused or moved around the app.  It is contained within an Activity just like a view but unlike a view, it can contain child elements inside of it that the user can interact with.

How to use Android Studio



Let's break down Android Studio into some more manageable pieces

Project Folder - This where you can access all of your files.  This file structure is very rigid and should not be changed in anyway, just added on to if necesarry.  There are two top level folders here; App and Gradle Scripts.  The app folder contains one of your app's most important files, the manifest file, which contains essential information about your app that it gives to the operating system before any code in your app can be executed.  Then there are the java code files and the resource directory, which includes things like layout files, images, style rules and much more.

Palette - This is where you pick the tools, called Views, that you want to display on screen.  You can simply drag each View over to the Layout Screen to place them or down into the Component Tree.  The views are categorized by type with the more common ones at the top.  You will get familiar with this panel very quickly. 

Component Tree - This panel shows you how you app is laid out in a topological view.  You can expand each parent View to see the child Views it contains.  This is helpful as you get more views into your activity and it becomes difficult to select the right one on screen.  You can also drop Views from the Palette into the tree for more precise placement.

Layout Screen - This is where all that hard work you're putting in will show up.  Drag Views from the Palette into here to see what they will look like on a real device.  The controls at the top let you select if you want the blueprint to be displayed, whether you want portrait or landscape orientation, which API version you want to target, and the theme you want your app to use.

Properties - The Properties panel is perhaps the most important part of all of this.  Each View has certain characteristics that allow it to respond to user interaction and the Properties panel is how you as a developer control them.  Each View should have a unique ID so that it can be referenced through java code.  Along with this, each View has layout properties so that it appears in an attractive way.  It has the ability to call methods in your code in response to certain events, and much more.

What's that Res folder all about?

By default, a few of these folders are included in the res directory (marked with an *).  Often you will find that you need another resource but aren't sure where to put it.  Also, if you try and add a directory that is not names exactly like one of these following folders, it will not show up in your Project Folder.  When you need to add a new resource, right click on the 'res' directory and go to 'New' -> 'Android resource directory'.


Here is the list of folders you can add and what each of them should contain.

  • Anim - Also referred to as the tween animator.  This is used for scaling, rotating, translating, or changing the alpha on Views.  What sets this apart from the next folder is that these files don't actually animate the view, they just animate how the view is shown.  Say you have a wide, short button on screen and you animate it 360 degrees around.  As the user sees it rotating, the button itself is in that exact same position, so if you were to click it in its rotated state outside of it's original location, it would have no effect.  The button is not actually there.
  • Animator - This is for property animations, or animations that are not only for views, but any object.  This also animates the whole object, not just the drawing of it.  So if you animate a View with the property animator, the whole view is moved around screen.  It is not just drawn elsewhere.
  • Color - This folder is for providing state-lists of colors.  Many View's can have different operating states, that is, pressed vs not pressed, checked vs not checked, etc.  Based on the state of the View, you can change how it is drawn, or it's color perhaps.  That's what you keep in this folder.  For defining single colors, like red as #FF0000, store that in Values/Colors.xml.
  • Drawable - This folder is for storing either vector drawable files, images that can be scaled without losing resolution.  These are images that are described in Xml format instead of rgb data.  It's like instructions for building the image rather than the image itself.  This is my preferred method for storing images because it keeps total app size down but the images are harder to create.
  • Interpolator - This is for smoothing transitions and animations in your app.  It is not realistic looking to show linear movement on most objects so it is best to smooth in and out of the transition.  This gives a much more visually pleasing look to an app.
  • Layout - This is the folder that holds all of your Layout xml files, the files that describe the look of your Activities, Views, and Fragments. 
  • Menu - This holds the information for the toolbar menu's in your activities.  To set them, use the onCreateOptionsMenu() method and to respond to clicks, use the onOptionsItemSelected() method.
  • Mipmap - Mipmap is the term used to describe different levels of detail of an image.  This is commonly seen in video games.  When you are very far away from an object, say, a mountain, the mountain kind of just looks like a brownish/grayish triangle in the distance.  As you get closer to this mountain, more detail is revealed.  This is because a different, much less detailed mountain was drawn when you were further away from it.  It saves system resources to do things this way.  This is how images are saved in Android.  When you create an image, you should import five different resolutions of that image to accommodate various devices with different screen sizes and pixel densities. 
  • Raw - This is for any files that you can save in their raw form, although it is often used for sound files your app may need. 
  • Transition
  • Values - Strings, colors, dimensions, and other hard coded values that will be used throughout the app.  This is so that if you want to change one value, maybe change an error message if a user forgets to enter a piece of information on a form, you can easily find it right here instead of looking through pages and pages of xXml files for the right line.  Strings are also stored to provide easy ways to translate your app into multiple languages.
  • Xml - This is an odd name since all of these other folders can hold Xml files with the exception of Mipmap maybe.  I've found that when you create a settings Activity, files are automatically put into this folder.

First Things First – Download Android Studio

You've decided you want to take the leap and see what Android development is all about.  Well let's tackle jump the first hurdle and download Android Studio, the official development environment for Android software.  There's going to be a few terms that come up a lot during this process so let's knock those out of the way now.

The Acronyms

  1. IDE - Integrated Development Environment.  This is where you will do all of your programming, debugging, editing, and publishing.  Basically, it is the piece of software that takes you from the very beginning of your project to the very end.  Android Studio is the IDE we will be using for Android apps.
  2. SDK - Software Development Kit.  This is the set of tools you will use to design your software for a specific platform.  We will be using the Android SDK which is included with Android Studio.  This will allow us to build Android apps, but unlike an IDE, cannot be used to build apps for other platforms.
  3. API - Application Program Interface.  These are sets of tools used to build specific more software.  Say you wanted to write an app that included a way to post to Facebook.  You would have to use one of Facebook's API's to interact with their platform.
  4. AVD - Android Virtual Device.  This is the emulator, a piece of software that will replicate the physical device you want to test your app on.  If you have an Android device, and its recommended that you have one if not more, you can use that too.  But an emulator allows you to set up different screen sizes, memory capabilities, pixel densities and much more.  You can test your app on a wide variety of different devices without having to shell out the money for them.

The installation

Those are the big ones you need to worry about in the beginning.  Now let's get to the good stuff.  The first thing you do is navigate to the Android Studio home page and click the big, green download button. 


Agree to their terms, click the final download button and save the executable to your downloads folder.  When this is done, navigate to that downloads folder and start it up.  Next you'll see this screen so click next and follow the on screen instructions.


On the next screen we're asked if we want to install the SDK and the Android Virtual Device (AVD).  Remember those?  We definitely want those so keep them selected and click next.


Then just agree to their terms if you feel so inclined.  On the next page, just leave the locations the same for Android Studio and the SDK unless you have reason to change them.  On the last page, hit Install, and let Android Studio do it's thing!

That's it.  Easy peezy!  Stick around and we'll go through learning your way around Android Studio in another post.

A Good Programmer is like a Good Chef

Learning programming is like learning how to cook.  At first, it's daunting, and best left to those that know what they're doing.  But the day will come when you need to learn how to do it yourself.  That is, if you don't want to keep paying other people to do it for you.  So you start with something small and easy that's been done before and has a lot of very detailed instructions.  When it's done you feel amazing!  You have something tangible, right in front of you, that you made and can be proud of.  An unnoticeable victory for the rest of the world but a milestone for you!

Then you get the itch to do it a little better next time so you try cooking something a little more challenging.  It has a few more steps to it, some of which you have to get a second opinion on to make sure you're doing them correctly.  You make a few mistakes and learn a couple things along the way but you make progress.  You keep trying again and again, each time adding a step or two you've never done before.  Sometimes you go back to the easy recipes because you need that confidence boost, that reminder that you can do it.  And then you move on.  Eventually you're using ingredients you didn't even know existed and cooking dishes with names you could barely pronounce.  Then comes the real joy.  You're bringing your own ideas to reality and inspiring others with what you can do!  And you help out the beginner because you remember what it was like the first time reading those detailed instructions for that simple meal.  

Programming is a lot like cooking.  It is learned in the same way.  Day by day it doesn't feel like you are getting any better but look back over the last year or two and you can see you've learned things you used to only dream about.  Now you laugh when you look back at some of your old code you thought was unbelievably clever at the time.  That compiler error that had you tearing your hair out for an entire weekend once, you can now fix in a matter of seconds. Every program you write is a little more sophisticated than the last.  Of course, there were still those programs that were abandoned because right as things were starting to look good, they got way too far out of control.  It's all a part of the process.

Keep learning

I haven't met many people who say they can't cook at least a simple meal.  Why do I keep running in to people that say they could never create software?  It just takes time and determination.  You just have to sit down and do it.  Yet I see so many posts with the titles of "Is it too late for me to start programming?", "Can a man in their 50's learn to create a web page?".  The answer is that it is never too late.  Is it too late to learn how to poach an egg?  No.  Can a man in their 50's learn how to make a pot roast?  Yes.  Stop putting it off and sit down and do it.

I didn't start programming until I was 22.  I was terrified of it actually.  I was in school to be an engineer and I had to take an introductory programming class in the upcoming semester.  The only exposure I had to writing software was when I was really young, maybe 10 or 11.  My dad showed me a simple C program because thought I might be interested in coding.  As smart as he was, my dad was never supposed to be a teacher.  He was a brilliant man, but as with many brilliant people, they forget what it was like to be a beginner.  They forget that some things of the things that are so trivial now pose the biggest obstacle to the newcomer.  So after an hour of watching this text on screen cause this other text to turn a different color, I was thoroughly confused, disappointed, and wanted absolutely nothing to do with this horrific topic.  

So now I had to take this class.  I bought a C++ for dummies book and went to town on it.  I spent every night of a winter break learning how to use variables and functions, how to create a program that converted Fahrenheit to Clausius and back again.  I didn't want that horrific experience again.  And the class wasn't horrific.  In fact I got an A.  I sat down, did the work, figured out the parts that went wrong, asked questions when I got confused, and just did it.  How is that different from learning any other skill?

For an entrepreneur, having at least a little knowledge of programming is essential.  Even if you're not going to do the coding yourself, it's important to know what can be done with it.  I can't tell you how many people I've met that when I tell them what a piece of software can do for them, they respond with "I didn't know that was possible!".  I have saved hours each day at jobs by automating simple tasks.  And this was usually done with programs that were no longer than fifty lines.  That's when I found out what I really wanted to do.

Enter Android

My passion has become Android programming.  Why?  Because it is a perfect combination of resources, accessibility, and practicality, along with a little fun, too.    I just published my first app a few months ago and I love seeing that another person has downloaded my app.  I have created something and shared it with the world.  But it wasn't easy.  It took three years of failed attempts before I landed on something I actually could finish. Maybe failed isn't the right word.  A lot of my previous apps just weren't app store worthy.  I created a lot of apps that I personally used that just weren't polished enough to publish.  I'm not saying that out of modesty, they really weren't finished.  They were buggy, had features that wouldn't work, and were visually displeasing.  The problem was that I would get really excited about an idea so I would start programming it.  There would be a couple features I needed to implement that took a little longer to learn than I had expected.  Then another feature would pop up that I didn't know how to do so I would have to learn something else.  Inevitably, I would let the frustration take over and abandon the project, telling myself that I just wasn't meant to create an Android app.  

That couldn't be farther from the truth.  First of all, most people don't even get as far as a failed attempt because they don't even try. Second, you learn a lot more by your failures than you do your successes.  The first time I made macaroni and cheese, I forgot to drain the water from the noodles before I added the cheese.  Don't laugh, I was young (not that young).  If I would have told myself then that I was never supposed to cook, I would be a very hungry and/or poor man today.  And let me tell you, I can make some mean mac n' cheese today.  The best thing you can do is learn from your failure and try again.  

Android is a great platform to learn on, fail on, succeed on, and keep going because of it's awesome community and abundance of helpful resources.  That's why I develop Android apps and teach Android programming.  The thing that sets me apart is that I teach the hard stuff.  Everybody and their brother has a tutorial about getting started with Android and I am no exception.  But when the beginner tutorials end, it's difficult to find quality resources to learn from about the harder topics like providing services or streaming content.  That is what I aim to solve.  So after asking if it's possible to become an Android developer, the next question might be, "is it worth it?".

Let's do the math

Near the end of 2015, there were over 1.4 billion Android users that accounted for over 53% of mobile devices.  That is an insane amount of technology.  The internet is a fascinating place and never has it been easier to get your ideas out to the world.  The best part is that you need only need a tiny chunk of that 1.4 billion to make even a meager profit.  Say you have an app that sells for $2.99 and you want to make an extra $1000 a month.  That's 335 downloads per month.  That's 0.000024% of the Android user population!  That's it!  You only need a relatively few amount of customers to make even a little extra income each month.  

Obviously, there is no guarantee that you can just write an app and have it take off.  Rovio only found success with Angry Birds after 51 previous attempts at other games.  51 tries!  That means they put in work, time, and effort only to have it not go as planned.  Then they got up and tried again.  Did I mention they did that 51 times?  Giving up so early is the easy way out.  Success belongs to the one's who don't let failures get to them.  Let's apply the Pareto Principle here.  The Pareto Principle states that roughly 80% of the results come from 20% of the work.  Now let's apply this to writing apps.  If your first app doesn't work out, you need to try at least four more times before you give up.  The one that matters just might not have been written yet.  

Anything can be learned.  And anything learned can be improved upon.  You just have to want it and be willing to put in the work.  If people say it's not possible, prove them wrong.  If you hear that it's too late for you to accomplish something, prove them wrong.  Even when it comes to developing software.

Instead of asking if you can be a programmer, or a chef for that matter, try one thing first.  Start.  

Learn Android Quickly – Intermediate Essentials

New Course!

We just finished our latest course, Learn Android Quickly - Intermediate Essentials.  Check out the promo video!

Learn these great skills

-Create a menu with awesome icons

-Animate items on screen

-Create dynamic notifications

-Explore the Card View

-Add a floating action button

-Get started with debugging your app

And much, much more!

We had a blast making this one so check it out on Udemy!

How does Gradle Work for Android Apps?

What is gradle

What is it?

If you’ve ever used Android Studio, you’ve no doubt seen the word Gradle thrown all over.  It’s one of those things that seems really important even though you don’t know much about it.  And if you are anything like me, you kind of just hope it will keep working…whatever it is.  I’m going to clear up what Gradle is, why it is so important, and why you don’t need to live in fear of it anymore.

What is it?

According to Wikipedia,

Gradle is an open source build automation system that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL)…”

While accurate, it’s still a little cryptic and it sure doesn’t make Gradle look any less scary.  Let’s break this down further.

Gradle is open source

Open source simply means that the source code that makes up the program is available for free to whoever wants it and they can do whatever it is they want with it.  This is as opposed to closed source which is what commercial software is; the code is private to the company that created it.

Gradle is a build automation system…

In software, a build is just as it is in any other part of life; the construction of a tangible object.  But in software development, the tangible product is the piece of software which is made of many other files like the source code.  When put together in the correct order, these files come together to make an executable program, more commonly known as an app.

With just a build system, the developer has to manually compile all of the files.  This isn’t so much of a task with small programs with just a few source files, but as programs grow larger and larger and require more resources like images, sounds, screen layouts, etc., it becomes a lot of work to compile a program.  This is where the automation comes in to play.

Believe it or not, a lot of work goes in to combining all of these files to make a program run.  And before these processes could be automated, instructions had to be written by the developer on how to compile the program and this was not done with a nice code editor like Android Studio.  By automating this process, human error is removed and production time is greatly sped up.  Think how many times you hit that play button in a single sitting!

…Builds upon the concepts of Apache Ant and Apache Maven…

Ant is a command-line build system written in java that can be used to build non java applications like C or C++.

Maven is another build automation system meant for any java based project.  Maven’s main goals are to create easy, uniform build systems in the most productive way possible.  Sounds pretty good right?

So basically we have these two tried and true systems that build java apps, now let’s make Gradle improve on them.

…Introduces a Groovy-type…

Groovy, like java, is an object oriented programming language that is meant to work with other java code and libraries.  It omits the commonly used parentheses and periods from java syntax which results in a very human readable context.

…domain specific language (DSL)…

A domain specific language is a programming language made for a specific purpose which in this case is Android development.  So a Groovy-type domain specific language means an object oriented programming language made specifically for the Android platform.  Kind of cool, huh?

So if we were to make the Wikipedia definition simpler, we could say that Gradle is a tool that creates our app using all of the files we have created for it based on methods proven to work by similar tools before it.

That’s a little easier right?

Why two Gradle files?

1I’m sure you’ve noticed by now that there are two Gradle files inside of you Android Studio project, one with the description of “Project” and one with the description of “Module”.  When you start your Android Studio project, you start it with one module.  A single Android studio project can have multiple modules.  Therefore the Project Gradle file are the build instructions for the whole app and the Module Gradle file are the build instructions for just one module of your app.







Hopefully that clears up a little bit about what Gradle is.  It doesn’t have to be as scary as you may think it is and maybe now you’ll have an introductory understanding in why it is there.  However there are all sorts of things you can do with it.  Configuring Gradle builds allows you to create free and paid versions of your app, debug and release versions, and much more.  But alas, that is content for another day.