Udacity Kotlin Nanodegree: Course 1

I have been waiting for this course to come out for the past six months and now it is here! I was able to get a 50% off on the course so that was really helpful. So far, the course has been amazing and I have built my first app, a dice roller!

You can check it out here. https://github.com/esegebart/diceroller

This is what I have learned in my first course. I am posting this as reference to myself later.

Namespaces – tools – define dummy content that is only used when you preview the app in the preview pane

Attr using the namespace tools will be gone when the app compiles

Two namespaces at top: tool and android. Android is part of the core framework.

Gradle determines what devices can run your app, compiles app to executable, handles dependency management, automated testing, and app signing for Google play. Gradle packages your app into an apk with its resources, compiled code, Android manifest, etc and then transfers the apk to your emulator or device.

There are two Gradle files: build.gradle (project) and build.gradle (app). The app gradle file handles your different modules that has different functionalities, libraries, and supporting android wearables. In larger apps, each module will have its own gradle file. Inside the Gradle project file, there are repos that are available to the whole project: google() and jcenter().

Gradle also handles all the dependencies which is external code and libraries a project depends on. These are handled in the dependencies block.

dependencies {

           dependencies are managed here

           app dependencies do not go here


The app folder gradle file configures how to set up the app module and deals with the plugins to run and build Android and kotlin projects. This also tells the app the compilesdk, targetsdk, and minsdk. These are pretty straighforward. Min is the minimum version it can run on. The target will always match the compilesdk. This also has the appID which is a unique identifier and necessary for Google Play. It is the domain your app is hosted on, reversed, followed by the app name. So if my app was hosted on elyse.com and my app is named diceroller, it would be com.elyse.diceroller. This is set up when the project is started.

The version level you lists matches to an API level, and all api levels are named after tasty treats.

ANDROID JETPACK is the new android support libraries – androidx – and has all the support libraries for new and old apis.

APPCOMPATACTIVITY – The main activity extends from this. It is a compatibility class that makes sure activity includes a menu bar (action bar) that looks the same across OS levels and is a part of androidx. I never knew exactly what this was, so this was helpful.

Adding Vector Drawables: The proper way to use vector drawables and keep compatibility with older versions of android is followed.

  • In Gradle build.app file – under default config add vectorDrawables.useSupportLibrary = true.
  • Add app:srcCompat=”@drawable/image_name” in the ImageView tag
Add the namespace to the root of the layout xmlns:app="http://schemas.android.com/apk/res-auto"
  • This is using the support library to reference the image resource in the layout file and enable the support library for vector drawables in the app level build.gradle
  • Open drawable (dice.xml) to see the colors and shapes listed in xml

build.gradle app file will generate png files that are use on those devices that are below minsdk. Png files will make app larger and make it slower. Large apps have high chance of being uninstalled. Androidx compat library supports devices all the way back to api level 7.

Adding app namespace supports either custom code or libraries in your project and not core android libraries.

Dependencies required to build the project or enable additional functionality are defined in the build.gradle.

Basic app structure:
Layouts – xml files the define what your app will look like
Activites – Kotlin classes where you write the dynamic parts of your app
Layouts and activities are connected by the process of layout inflation – and finding view objects by their unique id
TextView – displays text to the user
ImageView – display images to the user
Images are a drawable resource type.

Build gradle project in command line:
Change the directory of your project.
Type gradle run.
You can also include gradle run –warning-mode=all to see specific warnings.
Or you can type gradle tasks –info. Shows all tasks and what they are doing.

Memo Writing Practice

For my last assignment of this quarter, I was “hired” as a lead mobile developer and had to provide recommendations on BuySell Inc’s buying and selling application, research market competitors (LetGo, Mercari, and OfferUp) and choose a Cloud Service Provider and recommend at least three MBaaS services for the new application. I had to also list the requirements and scope of the work. It seems persuasive, yet professional.

BuySell, Inc.

To:      Chief Technology Officer

From:  Elyse Segebart

Date:   December 13, 2019

Re: MBaaS Services for BuySell Application

Chief Technology Officer,

After careful research and consideration, I have determined BuySell, Inc.’s BuySell application will benefit from using a Cloud Service Provider (CSP) and Mobile Backend as a Service (MBaaS) services to compete with other applications in the market. This will allow BuySell Inc. to get the application running quickly while reducing cost of implementing a mobile backend infrastructure. The business problem lies in which CSP to choose and what MBaaS services will be necessary for the application. After outlining the scope and requirements of the application, I will provide the MBaaS services I recommend and their necessity.

BuySell requirements scope includes:

  1. Advertise and browse products and services
    • a. Sellers advertise products and services using a variety of media
    • b. Buyers browse a catalog of advertised products and services grouped into common categories and subcategories such as clothing, electronics, household, handmade, etc.
  2. Connect buyers and sellers
    • 2.a.Buyers interested in purchasing an item from a seller will be able to communicate with each other about said item
  3. Transactions to buy an item will be completed in an easy and secure environment
  4. Shipping options provided for buyer to include shipping or offer Free shipping by paying the shipping out of purchase amount
    • 4.a. Prepaid label will be provided for all shipped transactions
  5. Users will be able to provide feedback on the buying and selling experience

Scope does not include:

  1. Methods to verify sellers (such as ID check, phone number, or badges indicating factors such as fast shipper, member since, or quick responder)
  2. Other payment methods such as PayPal or Stripe integration
  3. Moneyback guarantee or Purchase Protection on items bought and sold within the application
  4. Targeted ads within application

In reviewing different CSPs such as Amazon AWS, Google Firebase, and Microsoft Azure App Service, I have determined Google Firebase will be the best option since it is designed to be scalable and user-centric while aiding in creating the best user experience. Firebase provides a real-time database platform and a real-time database management API so there is no need for a backend server, the ability to sync real time data in the application, authentication, cloud storage, analytics, and crash reports.

The MBaaS services I would recommend for this application are:

  1. Firebase Authentication. Signing up and signing in are an integral part of the user experience and should be made as simple as possible with security being a forefront consideration. Firebase makes this easy to integrate different methods of signing up and signing in using phone authentication, email and password, or social media authentications in 10 lines of code or less.
  2. Firebase Real-Time Database. The application will include messaging between users and listings that include a variety of media that will need to be stored. The Real-Time Database is a good choice since it stored in a NoSQL database using JSON and is hosted on the cloud. It integrates with Firebase Authentication making the security model very intuitive.
  3. Firebase Cloud Storage. Photos and messaging will be hosted on the cloud and storing it in the cloud would be a logical option. Using cloud storage will improve the user experience by making data efficient and accurate while improving bandwidth.
  4. Google Analytics for Firebase SDK. Metrics are a very useful and integral part of improving business and optimizing applications. Metrics may include user demographics, app engagement, or user retention. There is unlimited reporting for up to 500 unique events for free and across all devices for web, iOS, and Android.
  5. Firebase Crashlytics. Making a quality application will enhance user experience. This service will help identify and categorize errors at runtime and determine which bugs require immediate attention. This will also enhance productivity by using resources efficiently.

If you have any questions or concerns regarding my recommendations, I encourage you to contact me and we can review them together.


Elyse Segebart

Lead Mobile Application Engineer

Cell: (555) 222-3333

PhoneGap Tips: Beginner Guide to Creating and Testing Your First App

Recently, I took a Cross-Platform Mobile Application Development class and worked with PhoneGap for the past five weeks. PhoneGap was developed by Nitobi Systems, but was acquired by Apache so it’s actually Apache Cordova now, but you can still download it as PhoneGap and use the PhoneGap commands in your terminal. I will refer to it as PhoneGap throughout the rest of this article.

So PhoneGap allows developers to create mobile applications without having to write the mobile application in its native language. Cool, right? The application can be developed in HTML5, CSS3, and JavaScript and PhoneGap does all the under the hood stuff to make your application run on the platform you desire. I used PhoneGap to create Android applications and used the PhoneGap application on Play Store to run my PhoneGap application on my physical device.

Before you get started, you will need to install the PhoneGap CLI and node.js for your JavaScript to run in your application. The documentation is very easy to follow and you can find it here:

Documentation for PhoneGap CLI is located here -> http://docs.phonegap.com/getting-started/1-install-phonegap/cli/ (*make sure you click the CLI tab and not the Desktop App tab above the documentation)

Once you have done that, we are ready to get started! Woo!

To create your PhoneGap application, navigate to the directory you want to save your application. For me, I am navigating to my phoneGapApps folder I created to store my projects.

Navigating to the folder to save my application.

We are now ready to create our first application! The photo below shows the command to create an new PhoneGap project.

Creating your first application from command line.

To use the phonegap commands, you want to change directory to the www folder in your application. Of course, your file directory may be different than mine. SO, if you go into File Explorer, click on your project (I am using my airport info project, use your myFirstApp project), and click into the “www” folder, right click the text box that says what folder you are in, and copy address as text:

Copy address as text from file explorer.

Now we can go into our terminal and cd (change directory) to this directory. Don’t forget to add quotation marks around your file location.

I used the Brackets.io editor because it has live preview for Chrome. If you are in Chrome browser, press CTRL + SHIFT + I and it will open the Chrome Developer Tools. There is a little symbol at the top of the developer tools that looks like a little phone and tablet, click that and BOOM you have Device Mode. Okay? Okay. Now above your device in your browser, you can see you can select different devices with different screen resolutions and add/edit the screens you want to test on. To the right of the tool bar, you will see a little rotation button so you can change the view of the screen to test on that as well. WOW. Pretty cool, right?

Okay, but I want to know how to test from terminal. Yes, testing from the terminal is pretty sweet. So, in order to do this without getting an error, we need to remove the browser platform installed and update it with the new browser. You have to do this on EVERY project. While we can combine these commands together using &&, it has failed me before, so I prefer to do them one at a time. In your terminal, while in the “www” folder of your app in command line (which you still should be) type this:

Removing current browser platform.
Response to removing browser platform.

[PRO TIP: Whenever you see a $ sign in examples on stackoverflow or other sites, it just means you are typing a command like it shows on MacOS when you are in the terminal. I use Windows and this would have been a GREAT thing to have learned about a year into coding. I probably typed so many commands that would’ve worked, had I known that I didn’t need to type the $ sign! BAM, saved you a ton of time and tears.]

Now, we add in the most current browser platform.

Adding the current browser platform.

Now we are all set to run our application from our terminal. The command to run the PhoneGap application is:

Executing PhoneGap application in browser from CLI.
PhoneGap application result from using run command.

This is one way to get it to run in the browser. You can also use the Live Preview mode in Brackets.io. The third way to try it is to type:

phonegap serve –browser

Using server to serve application to browser.

Then switch to your browser window and type localhost:3000 in the URL box. Your application should open and you can CTRL + SHIFT + I to get it to device mode.

Opening application after serve command using localhost:3000.

When you want to get out the application running in command line, just hit CTRL+C a couple of times and it will ask you if you want to end it. Type Y. Boom, you’re out.

So there you have it! You can now create a PhoneGap application from command line, add and remove the browser platform, use Chrome Device Mode in your browser, and test your app in your browser three different ways.

In future posts, I will show you what to remove from your project, how to edit your project using Brackets.io, how to create a barebones template, and how to test on a physical device.

You can download the Brackets editor here -> http://brackets.io/

I hope you enjoyed this post, let me know your thoughts or if this helped you in any way. I love feedback!

Gradle Build Process and Deploying Your App

So far, here’s what I have learned about how the Gradle build process works when you are ready to sign and deploy your Android application:

  1. The application source code needs to be in DEX (Dalvik Executable) files. The compiler converts all source code into compiled resources that include the bytecode that runs on Android Devices.
  2. DEX files and compiled resources are organized in one package by the APK Packager. The final product is an unsigned APK and needs to have a signature in order to be installed or deployed.
  3. There are two ways the APK Packager signs your app:

a. The debug version of your app is for testing and profiling only and will receive a debug keystore which is also the default keystore for new projects in Android Studio.

b. The release version (the one you will release externally) will receive a release keystore.

4. The packager will use zipalign tool before generating your final APK. This ensures it is optimized to use less memory when running on a physical device.

A signed APK file will include a “META-INF” folder containing three files: manifest.mf, cert.sf, and cert.rsa. Unsigned APKs will require a user to enable Unknown Sources to be able to install it. Amazon accepts unsigned apps for their store and Google Play Console does not. When you want to market your application, many users prefer signed ones over unsigned ones because downloading from unknown sources could be dangerous as it might include viruses, malware, or spyware.


Google Developers. (2019, January 23). Configure Your Build. Retrieved from Android Developers: https://developer.android.com/studio/build/#build-process

Mangroliya, S. (2012, April 23). Android differences between signed and unsigned .apk files? Retrieved from StackOverflow: https://stackoverflow.com/questions/10280278/android-differences-between-signed-and-unsigned-apk-files/10280362

Android N Developer Course: D5

Today I created a higher or lower game in Android Studio. Used Random class to generate a random number when the app launches.

Created a method that takes the user input when a button is clicked and converts the String to an int. Then I used If statement to take the int object and compare it to the random number that is generated. The app will tell the user higher or lower based on which statement is true. If the number is correct, it tells the user “That’s right! Try again!” and added the Random number code to generate a new number so the user can play again.

Went one step further and created a method called makeToast that takes a String object as its parameters and will display a message to the screen. So when the makeToast function is called, it will display the appropriate message.

This was super fun and it was great to see how to further simplify code by creating the makeToast function. I didn’t see it right away that it was possible, but with time I think I will get better at simplifying my code. And a photo of the app!

Android N Developer Course: D4

100 days of code: D8&9

Today I built currency converter application to take in Dollars and use toast to pop up the message in pounds. Even added the little squiggly pound sign to make it look more official. This was the end of the Android course section two. Next is the Java deep dive which I am really excited about. Some of the takeaways from the currency converter are using

String.format(“%.2f”, poundAmount)

In this example, the String.format sets the decimal point to two places and accepts the variable it will be formatting as the second parameter. If you are wondering what the “%.2f” means, like I did, %f is the format specifier for float data type in the functions printf and scanf. This format specifier will display up to six digits after the decimal point, but using %.1f or %.2f will make the precision to the first or second digit.

I added in the currency photo from Google and matched parent width.

I had to take the EditText (which is a String) and create a new variable and parse it to a Double. I added the conversion and assigned it to the variable poundAmount.

Then I used toast to display the conversion to pounds at the bottom of the screen.

Here is the code snippet:

And the application output!

Android N Developer Course: D3

100 days of code D6 & 7.

Created an application that takes two photos uploaded to the drawable folder. Added a button called New Cat and when clicked, will display a photo of a different cat. First tested that my button worked by using the Log.i to display a message to the log to ensure that my button was clicked. Created the onClick function called “clickCat”. Worked very similar to the EditText, only used ImageView and typecasted the findView to ImageView. The second part was to use


to set the image to the second photo upon being clicked.

You can use Properties > Scale Type to change how the photo is displayed in the screen. FitXY stretches it to the edge of the container, fitStart keeps it in proportion and aligns to top of container, Center keeps it in proportion and centers the image. Center is probably one I will use the most.

And here are my results!

Beautiful cats aren’t they?

Android N Developer Course: D2

Day 5 of 100 days of code.

Learned about Toast today. I think its cute they call it toast because it pops up at the bottom of the screen like toast does out of the toaster.

Toast can only be Long or Short: meaning it will show up at the bottom of the screen for a short or long time. You can also use the variableName.getText().toString() to retrieve what the user entered and display it to the bottom of the screen as well as concatenate any message you want to go along with it. In this case, I added “Hi there, ” so it would display before the name retrieved.

I made a small toast program that has a TextView, a PlainText spot to enter your name, and a button that says “Click me!”.

In the MainActivity, I created an EditText variable and typecasted so the program can find it in the Resources. Here is the code to create this program and the result below!

Overall, I thought this was a neat little bit. I remember watching this video like a year ago and I didn’t think I was ever going to understand it. Well, LOOK AT ME NOW! 🙂

Android N Developer Course: D1

Days 3 and 4 of 100 days of code.

What I’ve Learned:

I had a problem getting my project set up and kept getting the error “Add Google Maven Repository and Sync Project”. The solution to this was to go into the Gradle Project: Build files, find “allprojects” and inside of “repositories” add google() and sync. This error was realized in the MainActivity, my class file for the “import android.support.v7.app.AppCompatActivity;” was read and the AppCompatActivity was red. So, if you ever have this problem.. this solves it. I was trying to run a version of Android that was too old since I am working on the Android N Developer course and had to update it to SDK version 28 and it required the Maven repository.

If you are struggling with getting layout to work in the activitymain.xml, check one of two things. First, go into your component tree and see if you have ConstraintLayout or RelativeLayout. RelativeLayout is a lot easier to work with since you can drag and drop the components onto the screen. Right click ConstraintLayout and “convert view”.

Second, if you ARE using RelativeLayout and they keep popping to the top left corner, go to the top left of your design screen and you will see a tiny little magnet. Click this to turn autoconnect on/off.

Something interesting I found out is 1 dp is roughly 1/60th of an inch. So 160dp is about 1″ on any Android Screen. Good to know for design!

If you are working with TextView and trying to retrieve the text from it by clicking a button, you will create a function that is called when you click the button. You will declare a variable of EditText and typecast EditText to the findViewById (since find VIEW is obviously looking for a view). “R” is for resources and then you will find the ID you entered for the component in the xml file. The button you created on the screen will also need an onClick function saved to it in the XML. You can use Log.i which takes a String tag and String msg parameter. I used the tag as “Info” and used the ID and getText().toString() function to return what it retrieved and convert it to string to display to the log. Code below to explain!

Find this helpful? Connect with me to get these kind of tips everyday!

Thank you for checking my post out.