SlideShare a Scribd company logo
From Containerization
to Modularity
by @oasisfeng
Modular Future of Mobile Ecosystem
Modular hardware lead to modular software
Modular Hardware
• Smartphones become modular
• Prototypes: Project Ara, Phonebloks
• Products: LG G5, Moto Z
• More devices are connected
• Smart accessories (wristband, BT devices)
• Connected devices (smart watch, home kits)
• External hardware
• Secondary display
• Dock-hub with keyboard & track-pad (or mouse)
Modular Software
• Software becomes even more modular in an open ecosystem.
• Android itself becomes more and more modular.
• Assembly: Android Wear & TV, 3rd-party ROM
• Pluggable: IME, TTS, Doc Provider, Notification Listener
• Forkable: Shared Library (Services & Shared), System UI*
• Modular app ecosystem
• Launcher, Widget, Lock Screen, Live Wallpaper, Complication (Wear)
• Google Docs & Sheets Addons
• Community-driven: Tasker, Xposed, Nevolution, Island...
• The future of mobile belongs to the union of small teams and individuals.
Modular App Architecture
Every modular is a tiny app
What is Modularity?
• Modules separated by certain level of isolation
• Characteristics
• Independent
• Interchangeable
• Interoperable
• The price
• Confine
• Contract
• Compatibility
Why Modular?
• Engineering
• Enforced decoupling for high-cohesion code.
• Module-independent (parallel) development and testing
• Flexible integration, deployment & upgrade
• The infamous "64K methods limit"
• Product
• Selective installation (light-weight initial install)
• Hybrid-friendly (web & native, mix and match)
• Open to (3rd-party) extensions
Basic Solutions
• Java packages
• Pros: lowest cost
• Cons: loose isolation
• Gradle library modules
• Pros: tool-chain support
• Cons: build efficiency
• Multiple APKs
• Pros: build & install time (development productivity)
• Cons: Less user-friendly
In-House Modular Frameworks
Mainstream approaches in the wild:
• Multi-Dex: Inject dex-elements
• Pros: Easy to implement, taking full advantage of AOT & JIT
• Cons: Weak isolation
• Container: Proxy components by hooking. (DroidPlugin)
• Pros: Direct APK loading
• Cons: Massive reflective hooking (prone to compatibility issues)
• Semi-container: Transparent merge with class-loader proxy. (Atlas)
• Pros: Light-weight, modest hooking, minimal module constraints
• Cons: Runtime AndroidManifest lock-in
The Adventure of Project Atlas (Taobao)
• 1st gen (2012 - 2013): Container-based
• Goal: Fast and easy (business) plug-in integration across BUs.
• Challenge: Compatibility (both ROM and plug-in)
• 2nd gen (2013 - 2014): Semi-container
• Goal: Compatibility, reliability, maintainability.
• Benefits: 50% less code, 80% less reflective-hooking.
• 3rd gen: (2014-): Semi-container with flexible module management
• Goal: Deploy by module » Deploy-on-demand by UI pagelet (like web)
• Benefits: Agile development, fast deployment, incremental installation.
The Problem
• A complex framework for mixed purposes
• Modularity, incremental deployment, runtime upgrade and even hot-fix
• The reality
• A big mess of compromise and inefficiency
• The way out – Layered frameworks for separate purpose
• Modularity framework, to modularize the project structure.
• Runtime container, to manage deployment and upgrade.
• Hot-fix mechanism, for highly efficient and fast bug-fix.
Well-Known Open Source Containers
• They are actually much more complex beyond your imagination.
• Despite open sourced, it is still hard to evaluate.
• Check out its compatibility list (Android versions, Dalvik / ART, Devices)
• Check out its issue tracker
• Check out the KNOWN ISSUES in README or wiki
• Check out the LIMITATIONS in README or wiki
Be careful about projects with few KNOWN ISSUES and LIMITATIONS.
The Future of Runtime Container
• The Android infrastructure
• Split-APK (Android 5+): Requires modular project
• Instant App (Google Play services): Requires highly modular project
• Ephemeral App (Android 7+): Possibly requires modular project *
• Runtime container as a platform (Virtual App)
• Hack existent app (like Xposed for apps, without root)
• App automation (like UiAutomator for user)
• Privacy concerns (that’s why it should be open sourced)
Life is hard, don't waste your time!
Talk is cheap, show me the code!
Advice for Practice
• If you are a small team or developing a fast-iterating product
• Modularize your project as early as possible.
• Avoid developing in-house runtime container.
• Adopt open-source hot-fix solutions.
• If you are a large team, focus on shared low-level platform.
• Layer your frameworks, do modularization first.
• Avoid container-based approach, unless it’s your product model.
• The forbiddance enforced by developer agreement of Google Play Store
• Plan the exit route of containerization within its core design.
Our Practice - Bare Modularization
• Project: Regular Gradle project with modules
• Module: Hybrid (Sample: github.com/oasisfeng/nevolution)
• Act as application module in debug, but as library module in release.
• Build
• Debug: One APK for each module with shared UID
• Release: Single APK for all modules together
build.gradle of module assembly-public
ext.assembly = gradle.startParameter.taskNames.find { it.startsWith(":assembly-public") } != null;
if (ext.assembly) {
configure(subprojects.findAll { ! it.name.startsWith("assembly-public") }) { apply plugin:'com.android.library' }
} else configure(subprojects.findAll { it.name.startsWith("decorators-") }) { apply plugin:'com.android.application' }
AndroidManifest.xml of module assembly-public
<manifest ... tools:remove="android:sharedUserId,android:sharedUserLabel" />
"Bare" means A LOT
• Minimal efforts, pure Android development experience
• Fully managed by Android Studio & Gradle, without extra tools, plug-ins
• Future-proof for your development investment
• Effective building and debugging in large project
• Just build your module only, not the whole project.
• Only install the APKs of dependent modules.
• Only upgrade the APKs of changed modules.
• Inherently compatible and friendly with most runtime containers
• Split APKs (Android 5+), Instant Apps (Google Play)
• Hot-patch solutions: Tinker, Instant Run (Android Studio)
Dependency Injection
• DI in pure Android way
• Intent against intent filter
• AndroidManifest – The dependency configuration
• Gradle build types & variants – AndroidManifest override for different scenarios
• Comparison to the classic DI frameworks (JSR-330 based)
• Share components beyond app boundary.
• IPC (multi-process) support.
• Completely lazy.
• User re-configurable. (ActivityChooser, DocumentsProvider)
• Highly interoperable. (No library required)
Flexible UI bus
• Activity identified by URL (fragment by # within URL)
<activity android:name=".XxxActivity“ ... >
<intent-filter android:priority="1" > <!-- priority higher than catch-all WebViewActivity -->
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" android:scheme="https" android:host="www.example.com" android:path="/xxx" />
</intent-filter>
</activity>
<activity android:name=".WebViewActivity“ ... > <!– The catch-all web container activity -->
<intent-filter android:priority=“0" > <!-- priority lower than local Activities -->
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" android:scheme="https" android:host="www.example.com" android:pathPrefix="/" />
</intent-filter>
</activity>
• Hybrid handling: Native if module installed, web as fallback.
Flexible UI bus (cont.)
• Browser  App: Capture standard HTTP links in browser
<activity android:name=".XxxActivity“ ... >
<intent-filter android:autoVerify="true" android:priority="1" > <!– App Links -->
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <!-- Only if to be captured in browser -->
<data android:scheme="http" android:scheme="http" android:host="www.example.com" android:path="/xxx" />
</intent-filter>
</activity>
• Fully compatible with Verified App Links (Android 6+)
• Support Deep-Link (including "android-app" schema)
• Login can be handled with URL redirection and "referer" (nav. back).
• Standard-compliant, pure Android, cross-platform and future-proof.
Light Infrastructures on top of "Bare"
• Services to simplify the usage of AIDL service
• AidlService to reduce boilerplate code of AIDL service.
• LocalAidlServices for highly efficient local AIDL service.
• Synchronous service binding, no more hassles about ServiceConnection
Reference implementation: https://github.com/oasisfeng/deagle/.../com/oasisfeng/android/service
Services.use(context, INevoEngine.class, INevoEngine.Stub::asInterface, engine -> engine.evolve(...));
public class NevoEngine extends INevoEngine.Stub implements NevoEngineInternal, Closeable {
@Override public StatusBarNotificationEvo evolve(...) { ... }
public static class Service extends AidlService<INevoEngine.Stub> {
@Override protected INevoEngine.Stub createBinder() { return new NevoEngine(getContext()); }
}
}
final INevoRules rules = Services.bindLocal(context, INevoRules.class);
Other Hiccups You May Experience
• Where to place .aidl and related files
• Avoid AIDL interface between independent modules. (consider broadcast)
• Separate interface module for service module. (engine & engine-api)
• Libraries are built into every dependent modules, state not shared.
• Redundant only in debug build, no difference in actual behaviors.
• Library should NEVER share state between modules.
• Use (wrapper) service if state needs to be shared.
• Share UI among modules
• Consider self-contained Activity in one module.
• Share M+V (fragment & layout) in library module.
Thanks
@oasisfeng
anywhere

More Related Content

What's hot

Introduction to Android
Introduction to AndroidIntroduction to Android
Introduction to AndroidMurat Aydın
 
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows PhoneWinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows PhoneAndreas Jakl
 
Eskills4change by Fondazione Mondo Digitale
Eskills4change by Fondazione Mondo DigitaleEskills4change by Fondazione Mondo Digitale
Eskills4change by Fondazione Mondo DigitaleAngelo Gino Varrati
 
Fight back android fragmentation
Fight back android fragmentationFight back android fragmentation
Fight back android fragmentationBitbar
 
Convert Your Web App to Tizen
Convert Your Web App to TizenConvert Your Web App to Tizen
Convert Your Web App to TizenCheng Luo
 
Native Android Development with Spring
Native Android Development with SpringNative Android Development with Spring
Native Android Development with SpringRoy Clarkson
 
Mobile Day - Intel XDK & Testing
Mobile Day - Intel XDK & TestingMobile Day - Intel XDK & Testing
Mobile Day - Intel XDK & TestingSoftware Guru
 
Tizen introduction & architecture
Tizen introduction & architectureTizen introduction & architecture
Tizen introduction & architectureYoonsoo Kim
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
Appcelerator Overview
Appcelerator OverviewAppcelerator Overview
Appcelerator OverviewJeff Haynie
 
Domo Arigato Mr. Roboto - Open Source Bridge 2009
Domo Arigato Mr. Roboto - Open Source Bridge 2009Domo Arigato Mr. Roboto - Open Source Bridge 2009
Domo Arigato Mr. Roboto - Open Source Bridge 2009sullis
 
Android introduction
Android introductionAndroid introduction
Android introductionRaynaITSTEP
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndreas Jakl
 
Extending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScriptExtending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScriptRoy Clarkson
 
Making the Mobile Web Native with PhoneGap
Making the Mobile Web Native with PhoneGapMaking the Mobile Web Native with PhoneGap
Making the Mobile Web Native with PhoneGapRoy Clarkson
 
Mobile Web Development with HTML5
Mobile Web Development with HTML5Mobile Web Development with HTML5
Mobile Web Development with HTML5Roy Clarkson
 
OSGi on Android - Value Proposition
OSGi on Android - Value PropositionOSGi on Android - Value Proposition
OSGi on Android - Value PropositionJoachim Ritter
 
Developing Windows Phone Apps with the Nokia Imaging SDK
Developing Windows Phone Apps with the Nokia Imaging SDKDeveloping Windows Phone Apps with the Nokia Imaging SDK
Developing Windows Phone Apps with the Nokia Imaging SDKNick Landry
 

What's hot (20)

Introduction to Android
Introduction to AndroidIntroduction to Android
Introduction to Android
 
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows PhoneWinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
 
Eskills4change by Fondazione Mondo Digitale
Eskills4change by Fondazione Mondo DigitaleEskills4change by Fondazione Mondo Digitale
Eskills4change by Fondazione Mondo Digitale
 
Fight back android fragmentation
Fight back android fragmentationFight back android fragmentation
Fight back android fragmentation
 
Convert Your Web App to Tizen
Convert Your Web App to TizenConvert Your Web App to Tizen
Convert Your Web App to Tizen
 
Native Android Development with Spring
Native Android Development with SpringNative Android Development with Spring
Native Android Development with Spring
 
Mobile Day - Intel XDK & Testing
Mobile Day - Intel XDK & TestingMobile Day - Intel XDK & Testing
Mobile Day - Intel XDK & Testing
 
Android
AndroidAndroid
Android
 
Tizen introduction & architecture
Tizen introduction & architectureTizen introduction & architecture
Tizen introduction & architecture
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Appcelerator Overview
Appcelerator OverviewAppcelerator Overview
Appcelerator Overview
 
Domo Arigato Mr. Roboto - Open Source Bridge 2009
Domo Arigato Mr. Roboto - Open Source Bridge 2009Domo Arigato Mr. Roboto - Open Source Bridge 2009
Domo Arigato Mr. Roboto - Open Source Bridge 2009
 
Android introduction
Android introductionAndroid introduction
Android introduction
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
 
Extending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScriptExtending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScript
 
Making the Mobile Web Native with PhoneGap
Making the Mobile Web Native with PhoneGapMaking the Mobile Web Native with PhoneGap
Making the Mobile Web Native with PhoneGap
 
Mobile Web Development with HTML5
Mobile Web Development with HTML5Mobile Web Development with HTML5
Mobile Web Development with HTML5
 
OSGi on Android - Value Proposition
OSGi on Android - Value PropositionOSGi on Android - Value Proposition
OSGi on Android - Value Proposition
 
Developing Windows Phone Apps with the Nokia Imaging SDK
Developing Windows Phone Apps with the Nokia Imaging SDKDeveloping Windows Phone Apps with the Nokia Imaging SDK
Developing Windows Phone Apps with the Nokia Imaging SDK
 
Cross-Platform Development
Cross-Platform DevelopmentCross-Platform Development
Cross-Platform Development
 

Viewers also liked

Android应用的设备体验优化
Android应用的设备体验优化Android应用的设备体验优化
Android应用的设备体验优化oasisfeng
 
Simple c-programs
Simple c-programsSimple c-programs
Simple c-programsrashmi322
 
Chance challenge change Arise Roby
Chance challenge change   Arise RobyChance challenge change   Arise Roby
Chance challenge change Arise RobyArise Roby
 
peran pers nasional KWN by Pangestu chaesar
peran pers nasional KWN by Pangestu chaesar peran pers nasional KWN by Pangestu chaesar
peran pers nasional KWN by Pangestu chaesar Pangestu S
 
HugeTable:Application-Oriented Structure Data Storage System
HugeTable:Application-Oriented Structure Data Storage SystemHugeTable:Application-Oriented Structure Data Storage System
HugeTable:Application-Oriented Structure Data Storage Systemqlw5
 
Nossa Experiência - Promott
Nossa Experiência - PromottNossa Experiência - Promott
Nossa Experiência - Promottpromott12
 
Presentasi wwoooooooooooooookeeeeeeeee
Presentasi wwoooooooooooooookeeeeeeeeePresentasi wwoooooooooooooookeeeeeeeee
Presentasi wwoooooooooooooookeeeeeeeeeOlga Tiara
 
Beat stress, focus and kill procrastination with just a timer!
Beat stress, focus and kill procrastination with just a timer!Beat stress, focus and kill procrastination with just a timer!
Beat stress, focus and kill procrastination with just a timer!Nishant Jacob
 
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...ecommerce poland expo
 
Tonometer Final NSF I-Corps presentation
Tonometer Final NSF I-Corps presentationTonometer Final NSF I-Corps presentation
Tonometer Final NSF I-Corps presentationStanford University
 
aclogを支えるデザイン
aclogを支えるデザインaclogを支えるデザイン
aclogを支えるデザインrot1024
 
All about Interview
All about InterviewAll about Interview
All about InterviewPratik Patel
 
Web Services Catalog
Web Services CatalogWeb Services Catalog
Web Services CatalogRudolf Husar
 

Viewers also liked (20)

Android应用的设备体验优化
Android应用的设备体验优化Android应用的设备体验优化
Android应用的设备体验优化
 
Simple c-programs
Simple c-programsSimple c-programs
Simple c-programs
 
Getumhe ekologi
Getumhe ekologiGetumhe ekologi
Getumhe ekologi
 
Case study
Case studyCase study
Case study
 
Chance challenge change Arise Roby
Chance challenge change   Arise RobyChance challenge change   Arise Roby
Chance challenge change Arise Roby
 
peran pers nasional KWN by Pangestu chaesar
peran pers nasional KWN by Pangestu chaesar peran pers nasional KWN by Pangestu chaesar
peran pers nasional KWN by Pangestu chaesar
 
HugeTable:Application-Oriented Structure Data Storage System
HugeTable:Application-Oriented Structure Data Storage SystemHugeTable:Application-Oriented Structure Data Storage System
HugeTable:Application-Oriented Structure Data Storage System
 
Nossa Experiência - Promott
Nossa Experiência - PromottNossa Experiência - Promott
Nossa Experiência - Promott
 
Presentasi wwoooooooooooooookeeeeeeeee
Presentasi wwoooooooooooooookeeeeeeeeePresentasi wwoooooooooooooookeeeeeeeee
Presentasi wwoooooooooooooookeeeeeeeee
 
Bs 9arr
Bs 9arrBs 9arr
Bs 9arr
 
Beat stress, focus and kill procrastination with just a timer!
Beat stress, focus and kill procrastination with just a timer!Beat stress, focus and kill procrastination with just a timer!
Beat stress, focus and kill procrastination with just a timer!
 
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
 
Tonometer Final NSF I-Corps presentation
Tonometer Final NSF I-Corps presentationTonometer Final NSF I-Corps presentation
Tonometer Final NSF I-Corps presentation
 
aclogを支えるデザイン
aclogを支えるデザインaclogを支えるデザイン
aclogを支えるデザイン
 
All about Interview
All about InterviewAll about Interview
All about Interview
 
Sxsf
SxsfSxsf
Sxsf
 
Intergenerational Networking
Intergenerational NetworkingIntergenerational Networking
Intergenerational Networking
 
Web Services Catalog
Web Services CatalogWeb Services Catalog
Web Services Catalog
 
Sed petrolgy[1]
Sed petrolgy[1]Sed petrolgy[1]
Sed petrolgy[1]
 
Rescue.asd
Rescue.asdRescue.asd
Rescue.asd
 

Similar to From Containerization to Modularity

Android dev o_auth
Android dev o_authAndroid dev o_auth
Android dev o_authlzongren
 
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013DuckMa
 
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionMatteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionDuckMa
 
Introduction to android sessions new
Introduction to android   sessions newIntroduction to android   sessions new
Introduction to android sessions newJoe Jacob
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Javaamaankhan
 
Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA NITIN GUPTA
 
Android Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdfAndroid Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdfNomanKhan869872
 
Android development
Android developmentAndroid development
Android developmentmkpartners
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_uDoris Chen
 
Android Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start GuideAndroid Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start GuideSergii Zhuk
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osArnav Gupta
 
Android - Open Source Bridge 2011
Android - Open Source Bridge 2011Android - Open Source Bridge 2011
Android - Open Source Bridge 2011sullis
 

Similar to From Containerization to Modularity (20)

Android dev o_auth
Android dev o_authAndroid dev o_auth
Android dev o_auth
 
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
 
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionMatteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
 
Introduction to android sessions new
Introduction to android   sessions newIntroduction to android   sessions new
Introduction to android sessions new
 
Android - Anroid Pproject
Android - Anroid PprojectAndroid - Anroid Pproject
Android - Anroid Pproject
 
Android Programming
Android ProgrammingAndroid Programming
Android Programming
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Android ppt
Android ppt Android ppt
Android ppt
 
Android Applications
Android ApplicationsAndroid Applications
Android Applications
 
Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA
 
Android Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdfAndroid Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdf
 
Intro to android (gdays)
Intro to android (gdays)Intro to android (gdays)
Intro to android (gdays)
 
Android development
Android developmentAndroid development
Android development
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_u
 
Google android os
Google android osGoogle android os
Google android os
 
Android
AndroidAndroid
Android
 
Android Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start GuideAndroid Applications Development: A Quick Start Guide
Android Applications Development: A Quick Start Guide
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_os
 
Android - Open Source Bridge 2011
Android - Open Source Bridge 2011Android - Open Source Bridge 2011
Android - Open Source Bridge 2011
 

Recently uploaded

Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxabhinandnam9997
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesSanjeev Rampal
 
How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?Linksys Velop Login
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shoplaozhuseo02
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理aagad
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyDamar Juniarto
 
The AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfThe AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfSiskaFitrianingrum
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxlaozhuseo02
 
Pvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxGal Baras
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEHimani415946
 

Recently uploaded (12)

Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptx
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
The Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI StudioThe Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI Studio
 
How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case Study
 
The AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfThe AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdf
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
Pvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdf
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 

From Containerization to Modularity

  • 2. Modular Future of Mobile Ecosystem Modular hardware lead to modular software
  • 3. Modular Hardware • Smartphones become modular • Prototypes: Project Ara, Phonebloks • Products: LG G5, Moto Z • More devices are connected • Smart accessories (wristband, BT devices) • Connected devices (smart watch, home kits) • External hardware • Secondary display • Dock-hub with keyboard & track-pad (or mouse)
  • 4. Modular Software • Software becomes even more modular in an open ecosystem. • Android itself becomes more and more modular. • Assembly: Android Wear & TV, 3rd-party ROM • Pluggable: IME, TTS, Doc Provider, Notification Listener • Forkable: Shared Library (Services & Shared), System UI* • Modular app ecosystem • Launcher, Widget, Lock Screen, Live Wallpaper, Complication (Wear) • Google Docs & Sheets Addons • Community-driven: Tasker, Xposed, Nevolution, Island... • The future of mobile belongs to the union of small teams and individuals.
  • 5. Modular App Architecture Every modular is a tiny app
  • 6. What is Modularity? • Modules separated by certain level of isolation • Characteristics • Independent • Interchangeable • Interoperable • The price • Confine • Contract • Compatibility
  • 7. Why Modular? • Engineering • Enforced decoupling for high-cohesion code. • Module-independent (parallel) development and testing • Flexible integration, deployment & upgrade • The infamous "64K methods limit" • Product • Selective installation (light-weight initial install) • Hybrid-friendly (web & native, mix and match) • Open to (3rd-party) extensions
  • 8. Basic Solutions • Java packages • Pros: lowest cost • Cons: loose isolation • Gradle library modules • Pros: tool-chain support • Cons: build efficiency • Multiple APKs • Pros: build & install time (development productivity) • Cons: Less user-friendly
  • 9. In-House Modular Frameworks Mainstream approaches in the wild: • Multi-Dex: Inject dex-elements • Pros: Easy to implement, taking full advantage of AOT & JIT • Cons: Weak isolation • Container: Proxy components by hooking. (DroidPlugin) • Pros: Direct APK loading • Cons: Massive reflective hooking (prone to compatibility issues) • Semi-container: Transparent merge with class-loader proxy. (Atlas) • Pros: Light-weight, modest hooking, minimal module constraints • Cons: Runtime AndroidManifest lock-in
  • 10. The Adventure of Project Atlas (Taobao) • 1st gen (2012 - 2013): Container-based • Goal: Fast and easy (business) plug-in integration across BUs. • Challenge: Compatibility (both ROM and plug-in) • 2nd gen (2013 - 2014): Semi-container • Goal: Compatibility, reliability, maintainability. • Benefits: 50% less code, 80% less reflective-hooking. • 3rd gen: (2014-): Semi-container with flexible module management • Goal: Deploy by module » Deploy-on-demand by UI pagelet (like web) • Benefits: Agile development, fast deployment, incremental installation.
  • 11. The Problem • A complex framework for mixed purposes • Modularity, incremental deployment, runtime upgrade and even hot-fix • The reality • A big mess of compromise and inefficiency • The way out – Layered frameworks for separate purpose • Modularity framework, to modularize the project structure. • Runtime container, to manage deployment and upgrade. • Hot-fix mechanism, for highly efficient and fast bug-fix.
  • 12. Well-Known Open Source Containers • They are actually much more complex beyond your imagination. • Despite open sourced, it is still hard to evaluate. • Check out its compatibility list (Android versions, Dalvik / ART, Devices) • Check out its issue tracker • Check out the KNOWN ISSUES in README or wiki • Check out the LIMITATIONS in README or wiki Be careful about projects with few KNOWN ISSUES and LIMITATIONS.
  • 13. The Future of Runtime Container • The Android infrastructure • Split-APK (Android 5+): Requires modular project • Instant App (Google Play services): Requires highly modular project • Ephemeral App (Android 7+): Possibly requires modular project * • Runtime container as a platform (Virtual App) • Hack existent app (like Xposed for apps, without root) • App automation (like UiAutomator for user) • Privacy concerns (that’s why it should be open sourced)
  • 14. Life is hard, don't waste your time! Talk is cheap, show me the code!
  • 15. Advice for Practice • If you are a small team or developing a fast-iterating product • Modularize your project as early as possible. • Avoid developing in-house runtime container. • Adopt open-source hot-fix solutions. • If you are a large team, focus on shared low-level platform. • Layer your frameworks, do modularization first. • Avoid container-based approach, unless it’s your product model. • The forbiddance enforced by developer agreement of Google Play Store • Plan the exit route of containerization within its core design.
  • 16. Our Practice - Bare Modularization • Project: Regular Gradle project with modules • Module: Hybrid (Sample: github.com/oasisfeng/nevolution) • Act as application module in debug, but as library module in release. • Build • Debug: One APK for each module with shared UID • Release: Single APK for all modules together build.gradle of module assembly-public ext.assembly = gradle.startParameter.taskNames.find { it.startsWith(":assembly-public") } != null; if (ext.assembly) { configure(subprojects.findAll { ! it.name.startsWith("assembly-public") }) { apply plugin:'com.android.library' } } else configure(subprojects.findAll { it.name.startsWith("decorators-") }) { apply plugin:'com.android.application' } AndroidManifest.xml of module assembly-public <manifest ... tools:remove="android:sharedUserId,android:sharedUserLabel" />
  • 17. "Bare" means A LOT • Minimal efforts, pure Android development experience • Fully managed by Android Studio & Gradle, without extra tools, plug-ins • Future-proof for your development investment • Effective building and debugging in large project • Just build your module only, not the whole project. • Only install the APKs of dependent modules. • Only upgrade the APKs of changed modules. • Inherently compatible and friendly with most runtime containers • Split APKs (Android 5+), Instant Apps (Google Play) • Hot-patch solutions: Tinker, Instant Run (Android Studio)
  • 18. Dependency Injection • DI in pure Android way • Intent against intent filter • AndroidManifest – The dependency configuration • Gradle build types & variants – AndroidManifest override for different scenarios • Comparison to the classic DI frameworks (JSR-330 based) • Share components beyond app boundary. • IPC (multi-process) support. • Completely lazy. • User re-configurable. (ActivityChooser, DocumentsProvider) • Highly interoperable. (No library required)
  • 19. Flexible UI bus • Activity identified by URL (fragment by # within URL) <activity android:name=".XxxActivity“ ... > <intent-filter android:priority="1" > <!-- priority higher than catch-all WebViewActivity --> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http" android:scheme="https" android:host="www.example.com" android:path="/xxx" /> </intent-filter> </activity> <activity android:name=".WebViewActivity“ ... > <!– The catch-all web container activity --> <intent-filter android:priority=“0" > <!-- priority lower than local Activities --> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http" android:scheme="https" android:host="www.example.com" android:pathPrefix="/" /> </intent-filter> </activity> • Hybrid handling: Native if module installed, web as fallback.
  • 20. Flexible UI bus (cont.) • Browser  App: Capture standard HTTP links in browser <activity android:name=".XxxActivity“ ... > <intent-filter android:autoVerify="true" android:priority="1" > <!– App Links --> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- Only if to be captured in browser --> <data android:scheme="http" android:scheme="http" android:host="www.example.com" android:path="/xxx" /> </intent-filter> </activity> • Fully compatible with Verified App Links (Android 6+) • Support Deep-Link (including "android-app" schema) • Login can be handled with URL redirection and "referer" (nav. back). • Standard-compliant, pure Android, cross-platform and future-proof.
  • 21. Light Infrastructures on top of "Bare" • Services to simplify the usage of AIDL service • AidlService to reduce boilerplate code of AIDL service. • LocalAidlServices for highly efficient local AIDL service. • Synchronous service binding, no more hassles about ServiceConnection Reference implementation: https://github.com/oasisfeng/deagle/.../com/oasisfeng/android/service Services.use(context, INevoEngine.class, INevoEngine.Stub::asInterface, engine -> engine.evolve(...)); public class NevoEngine extends INevoEngine.Stub implements NevoEngineInternal, Closeable { @Override public StatusBarNotificationEvo evolve(...) { ... } public static class Service extends AidlService<INevoEngine.Stub> { @Override protected INevoEngine.Stub createBinder() { return new NevoEngine(getContext()); } } } final INevoRules rules = Services.bindLocal(context, INevoRules.class);
  • 22. Other Hiccups You May Experience • Where to place .aidl and related files • Avoid AIDL interface between independent modules. (consider broadcast) • Separate interface module for service module. (engine & engine-api) • Libraries are built into every dependent modules, state not shared. • Redundant only in debug build, no difference in actual behaviors. • Library should NEVER share state between modules. • Use (wrapper) service if state needs to be shared. • Share UI among modules • Consider self-contained Activity in one module. • Share M+V (fragment & layout) in library module.