SlideShare a Scribd company logo
ANDROID 103 - FIREBASE AND
ARCHITECTURE COMPONENTS
KATE HENDERSON & KAI KOENIG
HELLO
HELLO
I’m Kate!
I’m an Android Developer, GDG Organiser, Carpenter
Find me on Twitter: @Mistyepd
and I’m Kai!
I’m a { Software Engineer | Pilot | GDG Organiser | 

Gamer | Dad to 1 cat and 3 chickens | … }
Find me on Twitter: @AgentK
HELLO
CODE
https://github.com/TheRealAgentK/
SummerOfTech-Android-2018
MORE
GDG WELLINGTON
https://www.meetup.com/GDG-Wellington/
MORE
WELLINGTON.KT
https://www.meetup.com/Wellington-kt/
MORE
MOBILE REFRESH WELLINGTON 2018 - 7 SEPTEMBER 2018
FIREBASE ANALYTICS
WHAT IS FIREBASE?
▸ Mobile and web application development platform
▸ Collection of various integrated services
▸ Analytics
▸ Development (Messaging, Auth, RT Database, Storage, Crash Reporting etc)
▸ Grow/Outreach (Notification, App Indexing, Remote Config, Admob etc)
▸ Some free, others commercial
FIREBASE AND FIREBASE ANALYTICS
FIREBASE ANALYTICS
▸ A.k.a. Google Analytics for Firebase
▸ Free analytics and reporting solution
▸ Focus:
▸ General app usage and user demographics
▸ Built-in and custom events
▸ User engagement
FIREBASE AND FIREBASE ANALYTICS
ANALYTICS FEATURES (I)
▸ Max. 500 Events
▸ max. 25 parameters per event
▸ 1 “value” parameter per event
▸ Up to 25 User Properties
▸ Filters
▸ Integration with other Google/Firebase products
FIREBASE AND FIREBASE ANALYTICS
ANALYTICS FEATURES (II)
▸ Dashboard
▸ Audience Segmentation
▸ Conversion/Attribution
▸ Funnels/Cohorts
▸ Streamview (NEW!)
▸ Inferred Data from Google (Play)
FIREBASE AND FIREBASE ANALYTICS
MANUAL SETUP
▸ Login to Firebase console, create a Firebase project
▸ Allows to import existing Google projects, e.g. from Google Cloud Messaging
▸ “Add Firebase to your Android app”
▸ Specify package name of your app
▸ Rinse and repeat for the debug version of your app
SETUP AND INTEGRATION
SETUP AND INTEGRATION
CREATE FIREBASE PROJECT
SETUP AND INTEGRATION
ADD FIREBASE TO ANDROID APP
SETUP AND INTEGRATION
ADD FIREBASE TO ANDROID APP
SETUP AND INTEGRATION
ADD FIREBASE TO ANDROID APP
SETUP AND INTEGRATION
ADD FIREBASE TO ANDROID APP
GOOGLE-SERVICES.JSON (I)
▸ Data file that contains all the information to hook Firebase into your Android
project:
SETUP AND INTEGRATION
{
"project_info": {
"project_number": "45364632432432",
"firebase_url": "https://something.firebaseio.com",
"project_id": "something",
"storage_bucket": "something.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:45364632432432:android:45362432ae",
"android_client_info": {
"package_name": “com.this.is.my.package.app”
}
},
...
GOOGLE-SERVICES.JSON (II)
▸ The file is typically placed in /app
▸ Build flavors:
▸ All in one Firebase project: add more apps to your Firebase setup - 1 file
▸ Each flavor in its own Firebase project: multiple services files, usually placed
in the flavor’s root directory
▸ Firebase Analytics is app-scoped, other Firebase services are project-scoped
SETUP AND INTEGRATION
APP
STEP FA 1 - ADD LIBRARIES
▸ References to FA libraries in Gradle files
▸ When app runs - there should be some FA output in logical
APP
STEP FA 2 - ADD LIBRARIES
▸ Add new Button to DetailActivity
▸ Wire up onClick event handler in Data Binding
▸ When clicked, we “simulate” a purchase (showing a Toast)
WHAT ARE ANALYTICS EVENTS?
▸ System/app or user action that can be tracked
▸ Firebase supports a huge range of built-in events (FirebaseAnalytics.Event)
with built-in parameters (FirebaseAnalytics.Param)
▸ Alternatively: track your own custom events
▸ Logged with:

<firebaseInstance>.logEvent(type, bundle)
▸ General: use built-in events whenever possible!
ANALYTICS EVENTS
BUILT-IN EVENTS (I)
▸ Automatically collected:
▸ first_open, app_update, app_remove etc
▸ Predefined, but not automatically collected:
▸ 4 categories of events: general, retail/commerce, lead generation, gaming
▸ There are predefined parameters, too
▸ Some parameters are mandatory, most data is optional though
ANALYTICS EVENTS
BUILT-IN EVENTS (II)
▸ Simple example:





▸ Create Bundle
▸ Send event type and Bundle object to Firebase
▸ Google recommends to NOT use strings, but the Event/Param constants
ANALYTICS EVENTS
Bundle params = new Bundle();
params.putString("image_name", name);
params.putString("full_text", text);
mFirebaseAnalytics.logEvent("share_image", params);
CUSTOM EVENTS
▸ Simple example:





▸ Come up with whatever you want as event and parameter names
▸ Modify built-in events by adding more parameters
▸ Can be done very informal, but personally I prefer to have typed payload
objects that I validate and then parse into logEvent() calls
ANALYTICS EVENTS
params.putString(“flight_number", flightNumber);
params.putString("destinationAirport", destAP);
mFirebaseAnalytics.logEvent(“flight_selected", params);
EVENT REPORTING
▸ Even if you have NO events you want to track, Firebase Analytics is worthwhile
having for the automatically collected events
▸ On the Firebase Analytics event list, you can set events to be treated as
conversions goals
▸ Some (built-in) events are always treated as conversion
▸ Necessary for funnels and integration with Google Ad Campaigns
ANALYTICS EVENTS
EVENT REPORTING
ANALYTICS EVENTS
APP
STEP FA 3 - ADD CODE FOR PURCHASE EVENT
▸ Track event in onClick handler on DetailViewModel
APP
STEP FA 4 - ADD CODE FOR “ACHIEVEMENT” EVENT
▸ When users add new movies we now track an event in FA
BEHIND THE SCENES
▸ Firebase SDK in your app logs an event or changes a user property
▸ Data gets saved locally on the device
▸ Google Play services on the device then once per hour post the collected data
to the Firebase backend to save processing power and battery
▸ Android: once per hour for all apps
▸ iOS: once per hour for each each
▸ Conversion events trigger a batch upload instantly
SETUP AND INTEGRATION
TESTING AND DEBUGGING YOUR INTEGRATION
▸ Real-time/local via ADB, with a 24hr delay in the FA console or via Streamview:
SETUP AND INTEGRATION
08-02 13:33:15.607 1591-2140/? D/FA: Logging event (FE): sign_up, Bundle[{sign_up_method=unspecified,
firebase_event_origin(_o)=app, firebase_screen_class(_sc)=Main, firebase_screen_id(_si)=-1488012662865927065}]
08-02 13:33:15.766 1591-2140/? D/FA: Logging event (FE): sign_up_female, Bundle[{sign_up_method=unspecified,
firebase_event_origin(_o)=app, firebase_screen_class(_sc)=Main, firebase_screen_id(_si)=-1488012662865927065}]
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
DASHBOARD - ACTIVE USERS
FIREBASE ANALYTICS CONSOLE
DASHBOARD - APP VERSION AND DEVICES
FIREBASE ANALYTICS CONSOLE
DASHBOARD - COUNTRY
FIREBASE ANALYTICS CONSOLE
DASHBOARD - AGE/GENDER AND INTEREST
FIREBASE ANALYTICS CONSOLE
FUNNELS
FIREBASE ANALYTICS CONSOLE
▸ Chain of events, funnel tracks the retention of users
▸ “How many of the users who install, sign_up for free and eventually buy a
membership?”
USER RETENTION OVER TIME
FIREBASE ANALYTICS CONSOLE
▸ “How many of the users who installed still use the app after <n> days?”
USER RETENTION COHORTS
FIREBASE ANALYTICS CONSOLE
▸ How many of the users who installed still use the app broken down by weeks
STREAMVIEW - LIVE DASHBOARD
FIREBASE ANALYTICS CONSOLE
FIREBASE CRASHLYTICS
FIREBASE CRASHLYTICS
PROBLEM
▸ Our app runs on thousands of devices out there
▸ How can we get information on what happens on user’s devices?
▸ Crashes, Exceptions, Errors, Slowness etc
▸ Crashlytics tracks errors and crashes for you
▸ Note: distributing your app in Google Play will also give you bug/crash
statistics - they can have an influence on your Play store ranking
APP
STEP FC 1 - ADD LIBRARIES
▸ Adding the libraries to Gradle
▸ Starts logging fatal errors right away (see in logcat)
APP
STEP FC 2 - ADD A BUTTON TO CRASH THE APP
▸ New Button on DetailView
▸ Crashlytics.getInstance().crash() - simulates a proper app crash
APP
STEP FC 2 - ADD A BUTTON TO CRASH THE APP
▸ New Button on DetailView
▸ Crashlytics.getInstance().crash() - simulates a proper app crash
APP
STEP FC 3 - ADDING AN APPLICATION CLASS AND STARTING CRASHLYTICS
▸ A custom application class allows you access to the application lifecycle
▸ Setup in Manifest, inherit from an Application or AppCompat class
▸ Launching Crashlytics manually to enable debugging
▸ Create an exception (Division by Zero) and deal with it in try/catch
APP
STEP FC 4 - CLEANUP
▸ Just cleanup the manually fabricated exception
FIREBASE MESSAGING
FIREBASE MESSAGING
INTRO
▸ Communicate with a device
▸ Commonly used to send “Push Notifications”
▸ Requires 2 services
▸ Messaging Service
▸ ID Service
▸ Device Token used to push to a particular device
APP
STEP FN 1 - LIBRARIES
▸ Adding the libraries to Gradle
APP
STEP FN 2 - ID SERVICE
▸ Adding 2 services to Manifest
▸ onTokenRefresh in ID Service
APP
STEP FN 3 - MESSAGING SERVICE
▸ Implementation of Messaging service
▸ Difference between immediate handling of message and job scheduling
APP
STEP FN 4 - NOTIFICATION
▸ Showing a notification on the phone
▸ Icons
ROOM AND
ARCHITECTURE
COMPONENTS
APP
STEP AC 1 - ENTITIES
▸ Add all the room gradle dependencies
▸ Convert Film to a Entity
▸ Annotations we use
▸ @Entity
▸ @ColumnInfo
▸ @PrimaryKey
APP
STEP AC 2 - MAKE ROOM FOR EVERYTHING
▸ Realise I made a mistake in step 1 (annotationProcessor vs kapt)
▸ Create a DataManager to use the same database instance everywhere
▸ Add abstract Database definition
▸ Add Dao for films
▸ More annotations!!!
APP
STEP AC 3 - USE DATAMANAGER FOR OFFLINE REMOTE DATA
▸ Use DataManager in the MainActivity to fetch the remote list and update the
database
▸ Observe the LiveData
▸ Still manually combining local and remote lists
APP
STEP AC 4 - USE DATAMANAGER FOR LOCAL DATA
▸ Let DataManger save local films to the database
▸ Stop manually refreshing the films list onActivityResult
▸ Delete LocalData
▸ Notice we aren’t migrating existing locally saved films
VIEWMODEL
APP
WHY VIEWMODEL?
▸ Doesn’t recreate everything on rotate
▸ Google supported
▸ Separation of logic and data from the
activity
APP
STEP AC 5 - VIEWMODEL (THE GOOGLE VERSION)
▸ Create ViewModel with lazy{ }
▸ Move DataManager calls into ViewModel
▸ Observe the film list via the ViewModel
▸ Next Step -> List ordering?
RESOURCES
RESOURCES
RESOURCES
▸ Firebase: https://firebase.google.com/
▸ Firebase in a weekend: https://www.udacity.com/course/firebase-in-a-
weekend-by-google-android--ud0352
▸ Architecture components: https://developer.android.com/topic/libraries/
architecture/
RESOURCES
NEXT STEPS
▸ Udacity online courses:
▸ https://www.udacity.com/courses/android
▸ Android Basics Nanodegree: https://www.udacity.com/course/android-
basics-nanodegree-by-google--nd803
▸ Android Developer Nanodegree: https://www.udacity.com/course/android-
developer-nanodegree-by-google--nd801
RESOURCES
NEXT STEPS
▸ Books:
▸ Kotlin: https://kotlinlang.org/docs/books.html
▸ Android: Soooooo many. Make sure you buy something that is current (at
least for Android 7, better for 8)
RESOURCES
NEXT STEPS
▸ Android developer certifications:
▸ https://home.pearsonvue.com/androidatc
▸ https://developers.google.com/training/certification/associate-android-
developer/
MORE
GDG WELLINGTON
https://www.meetup.com/GDG-Wellington/
MORE
WELLINGTON.KT
https://www.meetup.com/Wellington-kt/
MORE
MOBILE REFRESH WELLINGTON 2018 - 7 SEPTEMBER 2018
RESOURCES
GET IN TOUCH
Kai Koenig
Email: kai@ventego-creative.co.nz
Twitter: @AgentK
Kate Henderson
Email: hi@kate.nz
Twitter: @Mistyepd

More Related Content

What's hot (14)

PDF
Trusted by Default: The Forge Security & Privacy Model
Atlassian
 
PDF
Google analytics
Sean Tsai
 
PPTX
Splunk bangalore user group 2020 08 01
NiketNilay
 
PDF
Serverless Security: Are you ready for the Future?
James Wickett
 
PPTX
How to build your own auto-remediation workflow - Ansible Meetup Munich
Jürgen Etzlstorfer
 
PDF
Let's your users share your App with Friends: App Invites for Android
Wilfried Mbouenda Mbogne
 
PDF
Surviving Serverless in Real-Life
OPEN KNOWLEDGE GmbH
 
PPTX
Monitoring as a Self-Service in Atlassian DevOps Toolchain
Andreas Grabner
 
PDF
Twitter APIs for #MediaHackday
Andy Piper
 
PPTX
Laurentiu macovei meteor. a better way of building apps
Codecamp Romania
 
PDF
I Love APIs 2015: Continuous Integration the Virtuous Cycle
Apigee | Google Cloud
 
PDF
API Creation to Iteration without the Frustration
Nordic APIs
 
PDF
DevOps.2D: two dimensions
of engineering
Antons Kranga
 
PDF
Bootiful Development with Spring Boot and Angular - Connect.Tech 2017
Matt Raible
 
Trusted by Default: The Forge Security & Privacy Model
Atlassian
 
Google analytics
Sean Tsai
 
Splunk bangalore user group 2020 08 01
NiketNilay
 
Serverless Security: Are you ready for the Future?
James Wickett
 
How to build your own auto-remediation workflow - Ansible Meetup Munich
Jürgen Etzlstorfer
 
Let's your users share your App with Friends: App Invites for Android
Wilfried Mbouenda Mbogne
 
Surviving Serverless in Real-Life
OPEN KNOWLEDGE GmbH
 
Monitoring as a Self-Service in Atlassian DevOps Toolchain
Andreas Grabner
 
Twitter APIs for #MediaHackday
Andy Piper
 
Laurentiu macovei meteor. a better way of building apps
Codecamp Romania
 
I Love APIs 2015: Continuous Integration the Virtuous Cycle
Apigee | Google Cloud
 
API Creation to Iteration without the Frustration
Nordic APIs
 
DevOps.2D: two dimensions
of engineering
Antons Kranga
 
Bootiful Development with Spring Boot and Angular - Connect.Tech 2017
Matt Raible
 

Similar to Android 103 - Firebase and Architecture Components (20)

PDF
What I learned about firebase analytics
Nick Guebhard
 
PPTX
What is new in Firebase?
Sinan Yılmaz
 
PDF
The Firebase tier for your mobile app - DevFest CH
Matteo Bonifazi
 
PDF
Firebase overview
Maksym Davydov
 
PPTX
Google Firebase
AliZaidi94
 
PDF
Lecture 11 Firebase overview
Maksym Davydov
 
PPTX
Google Firebase
Mukul parmar
 
PDF
Google Firebase presentation - English
Alexandros Tsichouridis
 
PPTX
Firebase Services
Yasin Çetiner
 
PPTX
Firebase Analytics
Mariam Aslam
 
PPTX
Firebase Analytics
Mariam Aslam
 
PDF
Backendless apps
Matteo Bonifazi
 
PPTX
Introduction to Firebase
Mustafa Şenel
 
PPTX
Tech Winter Break - GDG OnCampus International Institute of Information Techn...
VarnitMittal1
 
PPTX
Introduction to Digital Analytics for Apps - Trusted Conf
In Marketing We Trust
 
PPTX
Google Firebase - Analytics, Remote Config, Authentication
Birender Singh
 
PPTX
Google Firebase Presentation
Aeni Patel
 
PDF
Firebase Analytics - Best Practices To Attract, Engage, Convert & Measure You...
Tatvic Analytics
 
PDF
Firebase-ized your mobile app
Matteo Bonifazi
 
PPT
Firebase
Naveen Kumar Neelam
 
What I learned about firebase analytics
Nick Guebhard
 
What is new in Firebase?
Sinan Yılmaz
 
The Firebase tier for your mobile app - DevFest CH
Matteo Bonifazi
 
Firebase overview
Maksym Davydov
 
Google Firebase
AliZaidi94
 
Lecture 11 Firebase overview
Maksym Davydov
 
Google Firebase
Mukul parmar
 
Google Firebase presentation - English
Alexandros Tsichouridis
 
Firebase Services
Yasin Çetiner
 
Firebase Analytics
Mariam Aslam
 
Firebase Analytics
Mariam Aslam
 
Backendless apps
Matteo Bonifazi
 
Introduction to Firebase
Mustafa Şenel
 
Tech Winter Break - GDG OnCampus International Institute of Information Techn...
VarnitMittal1
 
Introduction to Digital Analytics for Apps - Trusted Conf
In Marketing We Trust
 
Google Firebase - Analytics, Remote Config, Authentication
Birender Singh
 
Google Firebase Presentation
Aeni Patel
 
Firebase Analytics - Best Practices To Attract, Engage, Convert & Measure You...
Tatvic Analytics
 
Firebase-ized your mobile app
Matteo Bonifazi
 
Ad

More from Kai Koenig (20)

PDF
Why a whole country skipped a day - Fun with Timezones
Kai Koenig
 
PDF
Android 102 - Flow, Layouts and other things
Kai Koenig
 
PDF
Android 101 - Building a simple app with Kotlin in 90 minutes
Kai Koenig
 
PDF
Kotlin Coroutines and Android sitting in a tree - 2018 version
Kai Koenig
 
PDF
Kotlin Coroutines and Android sitting in a tree
Kai Koenig
 
PDF
Improving your CFML code quality
Kai Koenig
 
PDF
Summer of Tech 2017 - Kotlin/Android bootcamp
Kai Koenig
 
PDF
2017: Kotlin - now more than ever
Kai Koenig
 
PDF
Anko - The Ultimate Ninja of Kotlin Libraries?
Kai Koenig
 
PDF
Coding for Android on steroids with Kotlin
Kai Koenig
 
PDF
API management with Taffy and API Blueprint
Kai Koenig
 
PDF
Little Helpers for Android Development with Kotlin
Kai Koenig
 
PDF
Introduction to Data Mining
Kai Koenig
 
PDF
Garbage First and you
Kai Koenig
 
PDF
Real World Lessons in jQuery Mobile
Kai Koenig
 
PDF
The JVM is your friend
Kai Koenig
 
PDF
Regular Expressions 101
Kai Koenig
 
PDF
There's a time and a place
Kai Koenig
 
KEY
Clojure - an introduction (and some CFML)
Kai Koenig
 
KEY
AngularJS for designers and developers
Kai Koenig
 
Why a whole country skipped a day - Fun with Timezones
Kai Koenig
 
Android 102 - Flow, Layouts and other things
Kai Koenig
 
Android 101 - Building a simple app with Kotlin in 90 minutes
Kai Koenig
 
Kotlin Coroutines and Android sitting in a tree - 2018 version
Kai Koenig
 
Kotlin Coroutines and Android sitting in a tree
Kai Koenig
 
Improving your CFML code quality
Kai Koenig
 
Summer of Tech 2017 - Kotlin/Android bootcamp
Kai Koenig
 
2017: Kotlin - now more than ever
Kai Koenig
 
Anko - The Ultimate Ninja of Kotlin Libraries?
Kai Koenig
 
Coding for Android on steroids with Kotlin
Kai Koenig
 
API management with Taffy and API Blueprint
Kai Koenig
 
Little Helpers for Android Development with Kotlin
Kai Koenig
 
Introduction to Data Mining
Kai Koenig
 
Garbage First and you
Kai Koenig
 
Real World Lessons in jQuery Mobile
Kai Koenig
 
The JVM is your friend
Kai Koenig
 
Regular Expressions 101
Kai Koenig
 
There's a time and a place
Kai Koenig
 
Clojure - an introduction (and some CFML)
Kai Koenig
 
AngularJS for designers and developers
Kai Koenig
 
Ad

Recently uploaded (20)

PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
 
PDF
From Chaos to Clarity: Mastering Analytics Governance in the Modern Enterprise
Wiiisdom
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PPTX
Cubase Pro Crack 2025 – Free Download Full Version with Activation Key
HyperPc soft
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PPTX
PowerISO Crack 2025 – Free Download Full Version with Serial Key [Latest](1)....
HyperPc soft
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
PDF
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PDF
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
PPTX
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
PPTX
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
 
From Chaos to Clarity: Mastering Analytics Governance in the Modern Enterprise
Wiiisdom
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
Cubase Pro Crack 2025 – Free Download Full Version with Activation Key
HyperPc soft
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PowerISO Crack 2025 – Free Download Full Version with Serial Key [Latest](1)....
HyperPc soft
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 

Android 103 - Firebase and Architecture Components

  • 1. ANDROID 103 - FIREBASE AND ARCHITECTURE COMPONENTS KATE HENDERSON & KAI KOENIG
  • 2. HELLO HELLO I’m Kate! I’m an Android Developer, GDG Organiser, Carpenter Find me on Twitter: @Mistyepd and I’m Kai! I’m a { Software Engineer | Pilot | GDG Organiser | 
 Gamer | Dad to 1 cat and 3 chickens | … } Find me on Twitter: @AgentK
  • 6. MORE MOBILE REFRESH WELLINGTON 2018 - 7 SEPTEMBER 2018
  • 8. WHAT IS FIREBASE? ▸ Mobile and web application development platform ▸ Collection of various integrated services ▸ Analytics ▸ Development (Messaging, Auth, RT Database, Storage, Crash Reporting etc) ▸ Grow/Outreach (Notification, App Indexing, Remote Config, Admob etc) ▸ Some free, others commercial FIREBASE AND FIREBASE ANALYTICS
  • 9. FIREBASE ANALYTICS ▸ A.k.a. Google Analytics for Firebase ▸ Free analytics and reporting solution ▸ Focus: ▸ General app usage and user demographics ▸ Built-in and custom events ▸ User engagement FIREBASE AND FIREBASE ANALYTICS
  • 10. ANALYTICS FEATURES (I) ▸ Max. 500 Events ▸ max. 25 parameters per event ▸ 1 “value” parameter per event ▸ Up to 25 User Properties ▸ Filters ▸ Integration with other Google/Firebase products FIREBASE AND FIREBASE ANALYTICS
  • 11. ANALYTICS FEATURES (II) ▸ Dashboard ▸ Audience Segmentation ▸ Conversion/Attribution ▸ Funnels/Cohorts ▸ Streamview (NEW!) ▸ Inferred Data from Google (Play) FIREBASE AND FIREBASE ANALYTICS
  • 12. MANUAL SETUP ▸ Login to Firebase console, create a Firebase project ▸ Allows to import existing Google projects, e.g. from Google Cloud Messaging ▸ “Add Firebase to your Android app” ▸ Specify package name of your app ▸ Rinse and repeat for the debug version of your app SETUP AND INTEGRATION
  • 13. SETUP AND INTEGRATION CREATE FIREBASE PROJECT
  • 14. SETUP AND INTEGRATION ADD FIREBASE TO ANDROID APP
  • 15. SETUP AND INTEGRATION ADD FIREBASE TO ANDROID APP
  • 16. SETUP AND INTEGRATION ADD FIREBASE TO ANDROID APP
  • 17. SETUP AND INTEGRATION ADD FIREBASE TO ANDROID APP
  • 18. GOOGLE-SERVICES.JSON (I) ▸ Data file that contains all the information to hook Firebase into your Android project: SETUP AND INTEGRATION { "project_info": { "project_number": "45364632432432", "firebase_url": "https://something.firebaseio.com", "project_id": "something", "storage_bucket": "something.appspot.com" }, "client": [ { "client_info": { "mobilesdk_app_id": "1:45364632432432:android:45362432ae", "android_client_info": { "package_name": “com.this.is.my.package.app” } }, ...
  • 19. GOOGLE-SERVICES.JSON (II) ▸ The file is typically placed in /app ▸ Build flavors: ▸ All in one Firebase project: add more apps to your Firebase setup - 1 file ▸ Each flavor in its own Firebase project: multiple services files, usually placed in the flavor’s root directory ▸ Firebase Analytics is app-scoped, other Firebase services are project-scoped SETUP AND INTEGRATION
  • 20. APP STEP FA 1 - ADD LIBRARIES ▸ References to FA libraries in Gradle files ▸ When app runs - there should be some FA output in logical
  • 21. APP STEP FA 2 - ADD LIBRARIES ▸ Add new Button to DetailActivity ▸ Wire up onClick event handler in Data Binding ▸ When clicked, we “simulate” a purchase (showing a Toast)
  • 22. WHAT ARE ANALYTICS EVENTS? ▸ System/app or user action that can be tracked ▸ Firebase supports a huge range of built-in events (FirebaseAnalytics.Event) with built-in parameters (FirebaseAnalytics.Param) ▸ Alternatively: track your own custom events ▸ Logged with:
 <firebaseInstance>.logEvent(type, bundle) ▸ General: use built-in events whenever possible! ANALYTICS EVENTS
  • 23. BUILT-IN EVENTS (I) ▸ Automatically collected: ▸ first_open, app_update, app_remove etc ▸ Predefined, but not automatically collected: ▸ 4 categories of events: general, retail/commerce, lead generation, gaming ▸ There are predefined parameters, too ▸ Some parameters are mandatory, most data is optional though ANALYTICS EVENTS
  • 24. BUILT-IN EVENTS (II) ▸ Simple example:
 
 
 ▸ Create Bundle ▸ Send event type and Bundle object to Firebase ▸ Google recommends to NOT use strings, but the Event/Param constants ANALYTICS EVENTS Bundle params = new Bundle(); params.putString("image_name", name); params.putString("full_text", text); mFirebaseAnalytics.logEvent("share_image", params);
  • 25. CUSTOM EVENTS ▸ Simple example:
 
 
 ▸ Come up with whatever you want as event and parameter names ▸ Modify built-in events by adding more parameters ▸ Can be done very informal, but personally I prefer to have typed payload objects that I validate and then parse into logEvent() calls ANALYTICS EVENTS params.putString(“flight_number", flightNumber); params.putString("destinationAirport", destAP); mFirebaseAnalytics.logEvent(“flight_selected", params);
  • 26. EVENT REPORTING ▸ Even if you have NO events you want to track, Firebase Analytics is worthwhile having for the automatically collected events ▸ On the Firebase Analytics event list, you can set events to be treated as conversions goals ▸ Some (built-in) events are always treated as conversion ▸ Necessary for funnels and integration with Google Ad Campaigns ANALYTICS EVENTS
  • 28. APP STEP FA 3 - ADD CODE FOR PURCHASE EVENT ▸ Track event in onClick handler on DetailViewModel
  • 29. APP STEP FA 4 - ADD CODE FOR “ACHIEVEMENT” EVENT ▸ When users add new movies we now track an event in FA
  • 30. BEHIND THE SCENES ▸ Firebase SDK in your app logs an event or changes a user property ▸ Data gets saved locally on the device ▸ Google Play services on the device then once per hour post the collected data to the Firebase backend to save processing power and battery ▸ Android: once per hour for all apps ▸ iOS: once per hour for each each ▸ Conversion events trigger a batch upload instantly SETUP AND INTEGRATION
  • 31. TESTING AND DEBUGGING YOUR INTEGRATION ▸ Real-time/local via ADB, with a 24hr delay in the FA console or via Streamview: SETUP AND INTEGRATION 08-02 13:33:15.607 1591-2140/? D/FA: Logging event (FE): sign_up, Bundle[{sign_up_method=unspecified, firebase_event_origin(_o)=app, firebase_screen_class(_sc)=Main, firebase_screen_id(_si)=-1488012662865927065}] 08-02 13:33:15.766 1591-2140/? D/FA: Logging event (FE): sign_up_female, Bundle[{sign_up_method=unspecified, firebase_event_origin(_o)=app, firebase_screen_class(_sc)=Main, firebase_screen_id(_si)=-1488012662865927065}] adb shell setprop log.tag.FA VERBOSE adb shell setprop log.tag.FA-SVC VERBOSE adb logcat -v time -s FA FA-SVC
  • 32. DASHBOARD - ACTIVE USERS FIREBASE ANALYTICS CONSOLE
  • 33. DASHBOARD - APP VERSION AND DEVICES FIREBASE ANALYTICS CONSOLE
  • 34. DASHBOARD - COUNTRY FIREBASE ANALYTICS CONSOLE
  • 35. DASHBOARD - AGE/GENDER AND INTEREST FIREBASE ANALYTICS CONSOLE
  • 36. FUNNELS FIREBASE ANALYTICS CONSOLE ▸ Chain of events, funnel tracks the retention of users ▸ “How many of the users who install, sign_up for free and eventually buy a membership?”
  • 37. USER RETENTION OVER TIME FIREBASE ANALYTICS CONSOLE ▸ “How many of the users who installed still use the app after <n> days?”
  • 38. USER RETENTION COHORTS FIREBASE ANALYTICS CONSOLE ▸ How many of the users who installed still use the app broken down by weeks
  • 39. STREAMVIEW - LIVE DASHBOARD FIREBASE ANALYTICS CONSOLE
  • 41. FIREBASE CRASHLYTICS PROBLEM ▸ Our app runs on thousands of devices out there ▸ How can we get information on what happens on user’s devices? ▸ Crashes, Exceptions, Errors, Slowness etc ▸ Crashlytics tracks errors and crashes for you ▸ Note: distributing your app in Google Play will also give you bug/crash statistics - they can have an influence on your Play store ranking
  • 42. APP STEP FC 1 - ADD LIBRARIES ▸ Adding the libraries to Gradle ▸ Starts logging fatal errors right away (see in logcat)
  • 43. APP STEP FC 2 - ADD A BUTTON TO CRASH THE APP ▸ New Button on DetailView ▸ Crashlytics.getInstance().crash() - simulates a proper app crash
  • 44. APP STEP FC 2 - ADD A BUTTON TO CRASH THE APP ▸ New Button on DetailView ▸ Crashlytics.getInstance().crash() - simulates a proper app crash
  • 45. APP STEP FC 3 - ADDING AN APPLICATION CLASS AND STARTING CRASHLYTICS ▸ A custom application class allows you access to the application lifecycle ▸ Setup in Manifest, inherit from an Application or AppCompat class ▸ Launching Crashlytics manually to enable debugging ▸ Create an exception (Division by Zero) and deal with it in try/catch
  • 46. APP STEP FC 4 - CLEANUP ▸ Just cleanup the manually fabricated exception
  • 48. FIREBASE MESSAGING INTRO ▸ Communicate with a device ▸ Commonly used to send “Push Notifications” ▸ Requires 2 services ▸ Messaging Service ▸ ID Service ▸ Device Token used to push to a particular device
  • 49. APP STEP FN 1 - LIBRARIES ▸ Adding the libraries to Gradle
  • 50. APP STEP FN 2 - ID SERVICE ▸ Adding 2 services to Manifest ▸ onTokenRefresh in ID Service
  • 51. APP STEP FN 3 - MESSAGING SERVICE ▸ Implementation of Messaging service ▸ Difference between immediate handling of message and job scheduling
  • 52. APP STEP FN 4 - NOTIFICATION ▸ Showing a notification on the phone ▸ Icons
  • 54. APP STEP AC 1 - ENTITIES ▸ Add all the room gradle dependencies ▸ Convert Film to a Entity ▸ Annotations we use ▸ @Entity ▸ @ColumnInfo ▸ @PrimaryKey
  • 55. APP STEP AC 2 - MAKE ROOM FOR EVERYTHING ▸ Realise I made a mistake in step 1 (annotationProcessor vs kapt) ▸ Create a DataManager to use the same database instance everywhere ▸ Add abstract Database definition ▸ Add Dao for films ▸ More annotations!!!
  • 56. APP STEP AC 3 - USE DATAMANAGER FOR OFFLINE REMOTE DATA ▸ Use DataManager in the MainActivity to fetch the remote list and update the database ▸ Observe the LiveData ▸ Still manually combining local and remote lists
  • 57. APP STEP AC 4 - USE DATAMANAGER FOR LOCAL DATA ▸ Let DataManger save local films to the database ▸ Stop manually refreshing the films list onActivityResult ▸ Delete LocalData ▸ Notice we aren’t migrating existing locally saved films
  • 59. APP WHY VIEWMODEL? ▸ Doesn’t recreate everything on rotate ▸ Google supported ▸ Separation of logic and data from the activity
  • 60. APP STEP AC 5 - VIEWMODEL (THE GOOGLE VERSION) ▸ Create ViewModel with lazy{ } ▸ Move DataManager calls into ViewModel ▸ Observe the film list via the ViewModel ▸ Next Step -> List ordering?
  • 62. RESOURCES RESOURCES ▸ Firebase: https://firebase.google.com/ ▸ Firebase in a weekend: https://www.udacity.com/course/firebase-in-a- weekend-by-google-android--ud0352 ▸ Architecture components: https://developer.android.com/topic/libraries/ architecture/
  • 63. RESOURCES NEXT STEPS ▸ Udacity online courses: ▸ https://www.udacity.com/courses/android ▸ Android Basics Nanodegree: https://www.udacity.com/course/android- basics-nanodegree-by-google--nd803 ▸ Android Developer Nanodegree: https://www.udacity.com/course/android- developer-nanodegree-by-google--nd801
  • 64. RESOURCES NEXT STEPS ▸ Books: ▸ Kotlin: https://kotlinlang.org/docs/books.html ▸ Android: Soooooo many. Make sure you buy something that is current (at least for Android 7, better for 8)
  • 65. RESOURCES NEXT STEPS ▸ Android developer certifications: ▸ https://home.pearsonvue.com/androidatc ▸ https://developers.google.com/training/certification/associate-android- developer/
  • 68. MORE MOBILE REFRESH WELLINGTON 2018 - 7 SEPTEMBER 2018
  • 69. RESOURCES GET IN TOUCH Kai Koenig Email: [email protected] Twitter: @AgentK Kate Henderson Email: [email protected] Twitter: @Mistyepd