You can reach the Turkish version of the post from here.
While checking if there is a new codelab of Google, I realised that there are some new but not on the standard page for codelabs https://codelabs.developers.google.com/ . I guess, each of you have heard about Google’s certifications. This new codelabs are the preparations codelabs of Associate Android Developer‘s certificate and I suppose they have been renewed because of last years’ changing standards of Android development. I decided to start writing this series of post to refill my knowledge and also giving and alternative reference if there is somebody getting prepared to exam with codelabs. I’ll try to write regularly as much as possible. For the ones preparing, besides of codelabs there are slides in here and also articles in here.
As I know, the exam is in Java but Kotlin is very popular in Android development for the last couple of years. Because of this and also to create a new challenge for me, I’ll try to write and share the samples in Kotlin. I’m a little bit newbie at Kotlin so if you notice there is a problem, please do not hesitate to contact me.
Let’s start 🙂
So which topics do the codelabs include. They are divided into 4 sections in below:
- Unit 1: Get started
- Unit 2: User experience
- Unit 3: Working in the background
- Unit 4: Saving user data
Android fundamentals 01.1: Android Studio and Hello World
Sure as start, if there is someone will get experience with Android as first time, should setup Android Studio into their computer. I’m not giving so much details written already in codelab.
Actually, the first codelab is pretty standard. As the years, the templates projects and classes of Android Strudio has developed so much that they includes everything to start an Android project. If you create a project with empty Activity option, you will have an app written “Hello World” on the screen. If we summarize the codelab in bullet points, Activity is the first interaction point of the app that your user interacted with, xml keeps ui information in a lightweight way. Your layouts(xml files) are under res folder. If you need(you will) define colors, strings, dimens and any other layout files, there all will be under res folder. build.gradle is the file that keeps all the sdk dependencies. The gradle file that is created like Project: HelloWorld keeps the configurations in app, Module: app keeps that module’s configurations. If there will be multiple modules in your application than each of them will have a separate build.gradle file. As last, another important file is AndroidManifest.xml. Android needs to know if an application component exist to be able to start it. As because of this, all the activities should have been defined in manifest file. If you try to start an undefined activity, the app will crash.
Very nice, now we’re ready to run the application. When we run the application, if there is not a live emulator, then it’ll ask to create/open a new one. In this sample, we’re not using Google Play services, so you can pick one with or without it. Android emulator make us test our application in different operating systems and resolution without having a physical device. The tag of package lying on the Manifest file shows the unique package name of the application. Another key point in Manifest file is icon variable. It keeps application’ icon.
If you want to test your application in a physical device, you should be sure that usb debugging is open. If not, when use connect the device, you can’t see the device under devices. If everything is ready, when you run the application, now you’ll start to see the new physical device on selection popup. You can select and run. If you want to see log of the running application, you should select the running device at first dropdown menu and package name of your application at second one under Logcat tab.
Following step of the codelab, a change on gradle file is happening. When something changes on gradle file, a sync warning shows up. You don’t need to anything additional. The only thing is to be sure you’re online.
I mentioned from Logcat shortly at previous paragraphs. Logcat is a very powerful tool to be able to see the errors, debug the application. While using Log.x(d: debug, i:info, w:warning, e:error) method, it can be done logging in different levels. If you select Verbose, while watching logs, you will see logs from each level but you can filter, too.
The cheat-sheet for testing parts:
QUESTİON 1
What is the name of the layout file for the main activity?
MainActivity.java
AndroidManifest.xml
activity_main.xml
build.gradle
QUESTİON 2
What is the name of the string resource that specifies the application’s name?
app_name
xmlns:app
android:name
applicationId
QUESTİON 3
Which tool do you use to create a new emulator?
- Android Device Monitor
- AVD Manager
- SDK Manager
- Theme Editor
QUESTİON 4
Assume that your app includes this logging statement:
Log.i("MainActivity", "MainActivity layout is complete");
You see the statement “MainActivity layout is complete” in the Logcat pane if the Log level menu is set to which of the following? (Hint: multiple answers are OK.)
- Verbose
- Debug
- Info
- Warn
- Error
- Assert
Projects:
References and more:
- https://codelabs.developers.google.com/android-training/
- https://codelabs.developers.google.com/codelabs/android-training-welcome/index.html?index=..%2F..android-training#0
- https://codelabs.developers.google.com/codelabs/android-training-hello-world/index.html?index=..%2F..android-training#12
- https://google-developer-training.github.io/android-developer-fundamentals-course-concepts-v2/unit-1-get-started/lesson-1-build-your-first-app/1-1-c-your-first-android-app/1-1-c-your-first-android-app.html
- https://goo.gl/RN2osg