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 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
- THIS OPTIMIZES APP SIZE ON OLDER PLATFORMS
- 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.