Author:Pankaj Kumar
No description
Tags
Support Statistics
¥.00 ·
0times
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
(This page has no text content)
Page
3
Building Android Projects with Kotlin Use Android SDK, Jetpack, Material Design, and JUnit to Build Android and JVM Apps That Are Secure and Modular Pankaj Kumar www.bpbonline.com
Page
4
Copyright © 2023 BPB Online All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor BPB Online or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. BPB Online has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, BPB Online cannot guarantee the accuracy of this information. Group Product Manager: Marianne Conor Publishing Product Manager: Eva Brawn Senior Editor: Connell Content Development Editor: Melissa Monroe Technical Editor: Anne Stokes Copy Editor: Joe Austin Language Support Editor: Justin Baldwin Project Coordinator: Tyler Horan Proofreader: Khloe Styles Indexer: V. Krishnamurthy Production Designer: Malcolm D'Souza Marketing Coordinator: Kristen Kramer First published: 2023 Published by BPB Online WeWork, 119 Marylebone Road London NW1 5PU UK | UAE | INDIA | SINGAPORE ISBN 978-93-5551-092-1 www.bpbonline.com
Page
5
Dedicated to My beloved Parents: Shri Ranjeet Kumar Singh Smt. Dr Manju Verma & My wife Sangeeta Kumari and My Daughters Shanvi Pankaj and Pankhudi Pankaj
Page
6
About the Author Pankaj Kumar holds a master’s degree in computer science and has worked as a lead Android application developer for more than a decade. He has expertise in various domains including banking, enterprise security, multimedia, e-commerce and real estate. He also knows about AOSP development. He presently serves as the mobile tech lead and mentors for developers at PropertyGuru Singapore. He contributes frequently to a few development communities and has earned more than 81,000 Stackoverflow reputation. He wrote stories and poems for a few local and national magazines while still a teenager. His debut book is this one. He spends time with his daughters when he is not working.
Page
7
About the Reviewers Alexey Mostovoy An android developer from Ukraine with 5 years of experience in building mobile applications. Have been successfully involved in the development of various banking, communications, news and entertainment applications. Believe that nothing is impossible with well-coordinated team Milap He believes that any fellow can write code that a computer can understand. “Good programmers” write code that humans can understand. Milap holds a master’s degree in computer science. He has worked on the Android platform since Android 2.2(Froyo), and he has more than nine years of experience as a skilled Android developer. He is working with Accenture India as a tech lead. He has extensive industry experience, including those in banking, health, digital, multimedia, e-commerce, and many others. For him, it’s always been about breaking out of his comfort zone. He also makes a contribution to his current organization as the innovation lead. He also contributes frequently to tech communities and has earned more than 10,000 reputations on Stackoverflow. He’s also active on Github, where he has published a library of reusable Android components.
Page
8
Acknowledgements There are many whom I want to thank for the continued and ongoing support they have given me during the writing of this book. To my wife Sangeeta, Dear backbone of my family, without you nothing is possible. Thank you for your continuous encouragement. I could have never completed this book without your support. To my daughters, The day when you will be old enough to read this book, you will be happy to understand that most of our playtime was invested in something awesome. Shanvi (my photocopy), thank you for being caring and waking up late nights with me to just giving me company while writing this book. And Pankhudi, without your hard work and support I could have completed this book before 5-6 months. I will not share this secrete with anyone. Lots of love my princesses. I am grateful to my teacher Mr Jay Sinha, my teammates, my juniors, my seniors, and mentors from each organization where I worked or work now. You gave me support throughout the learning process, your support and belief in me allowed me to explore everything in Android and take risks while developing something new in Android. These all things open doors to see the Android world in depth, and I tried to express all my learning to explain topics in the book, which can help readers to understand Android differently. Prabhat Singh, thank you for reviewing initial chapters and your valuable feedback, so I continued writing this book. My gratitude also goes to the team at BPB Publication (including Nrip, Surbhi, Lubna, Shalli and the team) for being supportive enough to provide me with a long time to finish the book. You all helped me to write good quality content with very good quality reviews. And I want to mention Alexey Mostovoy and Milap Tank for their technical reviews of the book and for helping to enhance the contents with their valuable feedback.
Page
9
Preface This book covers everything you need to learn for developing an amazing Android application. It explains the basics of Android, components of Android and their uses. This book also introduces the importance of clean code and architecture patterns. It also explains the use and benefits of using modularized code. This book introduces important tools which can be used while developing an Android application, it let the reader understand how to evaluate a layout performance, how to choose a better image type and the basics of multiscreen application development. This book explains the development of chat applications, video sharing applications and a game. While developing and explaining functionalities for these projects, the book will explain best practices, libraries, functional requirement gathering and developing features. It covers a real-time industry example while explaining the implementation of any feature. This book also explains the backend, it explains a bit about it and gives you an idea about choosing the right server for your application. And it also covers Firebase and implements a few features of Firebase in those three projects which will be discussed in the book. This book is divided into 10 chapters. These chapters will cover Android basics, optimizing layouts and images, use of important tools for development, writing clean code, developing the app for multiscreen, and developing a chat app, video sharing app and a game. Each chapter is written considering three things “what are options for doing a particular task”, “why an option is better to perform a particular task” and “how to do a particular task by using that better option”. So, the reader/ learners can get more interest in Android. The details are listed below. Chapter 1 will let you know to create your first Android application using an Android template. It will explain about Android project structure, modules and creation of launcher icons and emulators. It will also cover a few important things like Layout Inspector, Memory Profiler and Database Inspector.
Page
10
Chapter 2 will cover basic components of Android like Activity, Fragment, Service, Broadcast receiver, Content Provider and the lifecycle of Activity and Fragment. It will also explain a few important tools like GPU Overdraw, Systrace, and Perfetto which help us to measure the performance of the layout, so you can write an optimized layout design for your application. Chapter 3 will explain Architecture patterns. It will cover commonly used architecture patterns like MVP and MVVM, and it also explain usecases. It will also cover writing scalable, testable, and maintainable code using these architecture patterns and writing clean code. Chapter 4 will explain everything about developing chat applications. It will explain requirement gathering and choosing backend technology. It will also cover Firebase and its services, and Jetpack libraries like RecyclerView and ViewPager2. And this chapter will cover to design and develop each screen of the chat application. Chapter 5 will explain the process for publishing an Android application to Play Store. It will cover build variants, creating release Keystore, pricing strategies and preparing a checklist for app release. It will also cover account creation on Play Store, updating information about the app, publishing the update for the app, and analysing a few statistics like the number of installs and uninstalls. Chapter 6 will explain about developing a video-sharing application. It will cover data storage options in Android, Material design library and UI components like BottomNavigationView. It will explain the Repository pattern, and it also explains about Exoplayer library to implement video features. Chapter 7 will cover the basics of game development. First, it will explain game engines which are commonly being used to develop Android applications and then it will explain the basics of Unity, like creating the first project in Unity, adding some game objects and playing with a few properties of those game objects. It will explain about writing C# scripts for the game objects, and it will also cover creating Android build for the game. Chapter 8 will explain about developing a game using Unity. It will cover adding all components for the game and adding C# scripts for it. It will
Page
11
explain about adding game objects dynamically. It will also explain about adding support for multiple screens, so users can run your game on any screen. Chapter 9 will explain about adding support for big screens in your application. It will cover qualifiers for Android resources. It will cover designing and developing the application for tablets, wearables, and TV. It will explain about optimizing image resources for better performance and minimizing the size of the application. Chapter 10 the last chapter let you know about commonly used tools, and libraries. It covers Jetpack Compose, App bundles, SafetyNet and Hilt. It also covers writing test cases in Android using Junit, Espresso and Robolectric. It explains best practices and some awesome 3rd party libraries.
Page
12
Code Bundle and Coloured Images Please follow the link to download the Code Bundle and the Coloured Images of the book: https://rebrand.ly/9ff9fd The code bundle for the book is also hosted on GitHub at https://github.com/bpbpublications/Building-Android-Projects-with- Kotlin. In case there's an update to the code, it will be updated on the existing GitHub repository. We have code bundles from our rich catalogue of books and videos available at https://github.com/bpbpublications. Check them out! Errata We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors, if any, that may have occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at : errata@bpbonline.com Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family. Did you know that BPB offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.bpbonline.com and as a print book
Page
13
customer, you are entitled to a discount on the eBook copy. Get in touch with us at: business@bpbonline.com for more details. At www.bpbonline.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on BPB books and eBooks.
Page
14
Piracy If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at business@bpbonline.com with a link to the material. If you are interested in becoming an author If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit www.bpbonline.com. We have worked with thousands of developers and tech professionals, just like you, to help them share their insights with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Reviews Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions. We at BPB can understand what you think about our products, and our authors can see your feedback on their book. Thank you! For more information about BPB, please visit www.bpbonline.com.
Page
15
Table of Contents 1. Creating Hello World Project Structure Objectives Creating a project from Android Studio Template Introducing templates Understanding files in the created project AndroidManifest.xml Java/ res/ build.gradle gradle-wrapper.properties gradle.properties proguard-rules.pro settings.gradle local.properties Creating a custom launcher icon Creating android virtual device (AVD) Running the Hello World application Important tools to develop, debug, and improve Android application Gradle Logcat Writing Logs Android Lint How to use Lint from Android Studio Using Lint from command/terminal Layout inspector and layout validator Using Layout Inspector Introducing Layout Validator Memory profiler Database Inspector Modifying table from Database Inspector Run query from Database Inspector and DAO Conclusion
Page
16
Points to remember Multiple Choice Questions Answers Questions Key Terms 2. Basics of Android Components Structure Objectives Basic components of Android Activity Service Broadcast receiver Static broadcast receivers Dynamic broadcast receivers Content provider Content resolver Introducing Fragment and View View Fragment Ways to show Fragments Lifecycle of an Activity Lifecycle of a Fragment Introducing dimensions and screen sizes Dimensions Handling of screen sizes Understanding different types of Layouts LinearLayout RelativeLayout TableLayout FrameLayout ConstraintLayout Choosing a better Layout for a design GPU overdraw Perfetto/Systrace Basics of material design Conclusion
Page
17
Points to remember Multiple Choice Questions Answers Questions Key Terms 3. Architecture Patterns Structure Objectives Understanding the need for an architecture pattern Understanding clean architecture Understanding SOLID principle Single responsibility principle Open-closed principle Liskov’s substitution principle Interface segregation principle Dependency inversion principle Understanding MVP Points to remember: Understanding MVP with code Advantages of using MVP Disadvantages of MVP Understanding MVVM Understanding MVVM with code Using databinding Advantages of using MVVM Disadvantages of MVVM MVVM with UseCases Conclusion Points to remember Multiple Choice Questions Answers Questions Key Terms 4. Developing Chat Application Structure
Page
18
Objectives Gathering functional requirement Creating user flow diagrams Introducing server Choosing better backend technology Introducing BaaS Introducing Firebase and its services Adding Firebase to application Step 1: Creating a Firebase project Step 2: Registering the Android application with the Firebase project Step 3: Adding Firebase configuration file to the Android project Step 4: Adding Firebase SDKs to the app Identifying and introducing Firebase services Introducing Firebase Authentication Introducing Firebase real-time database Introducing Cloud Storage Introducing FirebaseUI Introducing Android Jetpack Introducing RecyclerView Understanding important classes of RecyclerView Understanding how RecyclerView works Introducing TabLayout and ViewPager Understanding project structure of Chat app Writing code for the first screen Developing login screen Developing of chat home screen Developing contacts screen Developing chat screen Developing profile screen Using of notifications Conclusion Points to remember Multiple Choice Questions Answers Questions Key Terms
Page
19
5. Publishing the Application Structure Objectives Introducing build variants Customizing build configurations Build types Product flavors Build variants Creating release Keystore Introducing R8 and Proguard Renaming identifiers Enabling of R8 Adding custom rules Creating a distributable file (release application) Creating a Google Play Store developer profile Pricing the application Understanding pricing strategy Free Freemium Paid Subscription plan Getting screenshots for the application Preparing Android app release checklist Uploading application to the Play Store Settings for paid applications Creating App at Google Play console Setting up your app Publishing/releasing the application Watching the number of installs Updating application at Play Store Conclusion Points to remember Multiple Choice Questions Answers Questions Key Terms
Page
20
6. Developing Video Sharing Application Structure Objectives Gathering functional requirement Creating user flow diagram Introducing material UI components Introducing BottomNavigationView Introducing data storage in Android Introducing files Storage Access Framework (SAF) Preferences Database Room Creating CRUD for video sharing application Creating database Introducing repository pattern Introduction Package structure for repository pattern Implementing the repository pattern Introducing ExoPlayer Dependencies for ExoPlayer Understanding project structure Developing home screen Implementing the likes feature on clips Implementing the share feature for clips Implementing the comment feature on clips Developing add clips screen Conclusion Points to remember Multiple Choice Questions Answers Questions Key Terms 7. Introduction to Game Development Introduction Structure
Comments 0
Loading comments...
Reply to Comment
Edit Comment