Coder Social home page Coder Social logo

hendercine / builditbigger_4.0 Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 52.39 MB

A joke-telling app with multiple flavors, that uses multiple libraries & Google Cloud Endpoints (GCE). There are four modules: A Java library that provides jokes, a GCE project to serve them, an Android Library with an activity to display the jokes, & an Android app that fetches jokes from the GCE & passes them to the Android Library for display.

Java 46.85% HTML 53.15%
android-library java-library retrieves-jokes paid-flavors gradle-task gce

builditbigger_4.0's Introduction

Build it bigger with Gradle for Android & Java!

A joke-telling app with multiple flavors, that uses multiple libraries and Google Cloud Endpoints (GCE). There are four modules: A Java library that provides jokes, a GCE project to serve them, an Android Library with an activity to display the jokes, and an Android app that fetches jokes from the GCE and passes them to the Android Library for display.

Why this Project

As Android projects grow in complexity, it becomes necessary to customize the behavior of the Gradle build tool, allowing automation of repetitive tasks. Particularly, factoring functionality into libraries and creating product flavors allow for much bigger projects with minimal added complexity.

Skills Employed

Explored the role of Gradle in building Android Apps and how to use Gradle to manage apps of increasing complexity. Skills employed included:

  • Adding free and paid flavors to an app, and setting up the build to share code between them
  • Factoring reusable functionality into a Java library
  • Factoring reusable Android functionality into an Android library
  • Configuring a multi project build to compile the libraries and app
  • Using the Gradle App Engine plugin to deploy a backend
  • Configuring an integration test suite that runs against the local App Engine development server

How Did I Complete this Project?

Step 1: Create a Java library

My first task was to create a Java library that provides jokes. I created a new Gradle Java project either using the Android Studio wizard. Then introduced a project dependency between the app and the new Java Library.

I then made the button display a toast showing a joke retrieved from my Java joke telling library.

Step 2: Create an Android Library

I created an Android Library containing an Activity that would display a joke passed to it as an intent extra. I wired up the project dependencies so that the button could pass the joke from the Java Library to the Android Library.

Step 3: Setup GCE

The next task was pretty tricky. Instead of pulling jokes directly from the Java library, I set up a Google Cloud Endpoints development server, and pulled the jokes from there. The starting code already included the GCE module in a folder called backend.

Before going ahead I needed to be able to run a local instance of the GCE server. In order to do that I had to install the Cloud SDK:

https://cloud.google.com/sdk/docs/

Once installed, I followed the instructions in the Setup Cloud SDK section at:

https://cloud.google.com/endpoints/docs/frameworks/java/migrating-android

Note: i did not need to follow the rest of steps in the migration guide, only the Setup Cloud SDK.

I could then start or stop the local server by using the gradle tasks as shown in the following screenshot:

Once my local GCE server was started I could see the following at localhost:8080

I was finally ready to continue!

I introduced a project dependency between the Java library and the GCE module, and modified the GCE starter code to pull jokes from the Java library. I created an AsyncTask to retrieve jokes using the template included in these instructions. I then made the button kick off a task to retrieve a joke, and then launch the activity from the Android Library to display it.

Step 4: Add Functional Tests

I added code to test that the Async task successfully retrieved a non-empty string.

Step 5: Add a Paid Flavor

I added free and paid product flavors to the app. Removed the ad (and any dependencies I could) from the paid flavor.

Add Interstitial Ad

I follow these instructions to add an interstitial ad to the free version. The ad displays after the user hits the button, but before the joke is shown.

https://developers.google.com/mobile-ads-sdk/docs/admob/android/interstitial

Add Loading Indicator

Added a loading indicator that is shown while the joke is being retrieved and disappears when the joke is ready. The following tutorial was where I started:

http://www.tutorialspoint.com/android/android_loading_spinner.htm

builditbigger_4.0's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.