SlideShare uma empresa Scribd logo
1 de 35
Baixar para ler offline
Building Top-Notch 
Android SDKs 
Hugo Doménech 
@hudomju
relayr 
bring things to life
relayr 
bring things to life 
easy tools to connect 
things and apps
Building Top-Notch 
Android SDKs 
Hugo Doménech 
@hudomju
Agenda 
1. Why? 
2. How? 
3. What?
Agenda 
1. Why? 
2. How? 
3. What?
Reasons 
• Developers are lazy - reuse code 
• Separate concerns (build independent blocs) 
• Write better software 
• Speed up compile time 
• Make other people happy…
Make it open source! 
• Feel better 
• Code better: Power of shame 
• Get features and bug fixes for free 
• Easier to sell - quality prove 
• Excitement from the community 
• Security 
• It’s free 
• But most important: Be famous!
Agenda 
1. Why? 
2. How? 
3. What?
Decide what you are providing 
Library Project 
jar 
(Java ARchive) 
Apk Lib 
aar 
(Android Archive Resource)
Let’s build a SDK!
Create a SDK! 
1. Don’t start with code: README.md and ROADMAP.md 
2. Put it in a Git Repository 
3. Include it in your CI (Continuous Integration) 
4. Add static code analysis tools (i.e. FindBugs, Lint) 
5. Autogenerate documentation (i.e. JavaDoc) 
6. Prepare for testing 
7. Make it accessible (i.e. distribute via maven) 
8. Add a sample project
Managing Releases 
Use the library in a real project 
Master 
SDK as a git submodule 
Master 
Develop 
Develop 
Feature Branch 
Feature Branch
Agenda 
1. Why? 
2. How? 
3. What?
Great SDK Qualities 
• Available 
• Easy to use 
• Flexible 
• Testable 
• Performant 
• Reliable 
• Lightweight
Available 
build.gradle 
dependencies { 
include ‘io.relayr:android-sdk:0.0.5’ 
} 
*gradle-mvn-push.gradle by Chris Banes
Easy to use 
• Intuitive 
• Consistent 
• Easy to use, hard to misuse
Easy to use 
• Easy to initialise 
RelayrSdk.init(this); 
• Easy to use 
RelayrSdk.logMessage(“At droidcon Krakow!”);
Flexible 
new RelayrSdk.Builder(this) 
.inMockMode(true) 
.apiEndpoint(“api.relayr.io”) 
.withDebugger(new DefaultDebugger()) 
.build();
Flexible - minimize permisions
Flexible - minimize permisions 
public boolean canVibrate() { 
String permission = "android.permission.VIBRATE"; 
int result = mContext.checkCallingOrSelfPermission(permission); 
return result == PackageManager.PERMISSION_GRANTED; 
}
Flexible - minimize requisites 
<uses-permission 
android:name="android.permission.BLUETOOTH"/> 
<uses-permission 
android:name="android.permission.BLUETOOTH_ADMIN"/> 
<uses-feature 
android:name=“android.hardware.bluetooth_le" 
android:required="false"/> 
public boolean isBleSupported() { 
String feature = PackageManager.FEATURE_BLUETOOTH_LE; 
return getPackageManager().hasSystemFeature(feature); 
}
Flexible - support different versions 
defaultConfig { 
applicationId 'io.relayr.wunderbar' 
minSdkVersion 15 
targetSdkVersion 21 
versionCode 22 
versionName '1.0.22' 
} 
public boolean isSdk18() { 
return android.os.Build.VERSION.SDK_INT >= 
Build.VERSION_CODES.JELLY_BEAN_MR2; 
}
Flexible - be context aware 
mApplication.registerActivityLifecycleCallbacks( 
new Application.ActivityLifecycleCallbacks() { 
@Override 
public void onActivityResumed(Activity activity) { 
// we know there’s a UI! 
} 
} 
);
Testable 
• Mock mode (no network requests) 
• No static methods 
• Avoid final classes 
• Avoid access to fields directly
Performant 
• Don’t block the current thread! 
RelayrSdk.sendMessage(“At droidcon Krakow!”);
Performant - Don’t log in production 
• With Code 
RelayrSdk.Builder(this) 
.setDebuggable(false) 
.build(); 
• On the Manifest 
debuggable=false
Reliable 
• Don’t crash silently - inform the user when a 
problem occurs 
RelayrSdk.login(new LoginCallback() { 
public void onSuccess() { 
// sign the user into the app 
} 
public void onError() { 
// show error message 
} 
});
Lightweight 
• Poor network conditions 
• Association between small and fast 
• Reluctance to include large libraries
Lightweight - don’t require libraries 
private boolean hasOkHttpOnClasspath() { 
try { 
Class.forName("com.squareup.okhttp.OkHttpClient"); 
return true; 
} catch (ClassNotFoundException e) { } 
return false; 
} 
dependencies { 
provided ‘com.squareup.okhttp:okhttp:2.0.0’ 
}
Lightweight - be modular 
dependencies { 
} 
include ‘io.relayr:java-sdk:0.0.5’ 
include ‘io.relayr:android-sdk:0.0.5’ 
include ‘io.relayr:android-onboarding:0.0.7’ 
include ‘io.relayr:master-module:1.2.0’ 
include ‘io.relayr:android-commons:1.0.0’
Recapitulate 
1. Why? 
2. How? 
3. What?
Take away
Questions? 
Hugo Doménech 
@hudomju
Building Top-Notch Androids SDKs

Mais conteúdo relacionado

Mais procurados

Introduction to Containers & Diving a little deeper into the benefits of Con...
 Introduction to Containers & Diving a little deeper into the benefits of Con... Introduction to Containers & Diving a little deeper into the benefits of Con...
Introduction to Containers & Diving a little deeper into the benefits of Con...Synergetics Learning and Cloud Consulting
 
Jenkins for java world
Jenkins for java worldJenkins for java world
Jenkins for java worldAshok Kumar
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developersDmitry Guyvoronsky
 
Louisville Software Engineering Meet Up: Continuous Integration Using Jenkins
Louisville Software Engineering Meet Up: Continuous Integration Using JenkinsLouisville Software Engineering Meet Up: Continuous Integration Using Jenkins
Louisville Software Engineering Meet Up: Continuous Integration Using JenkinsJames Strong
 
Introduction to Docker - Learning containerization XP conference 2016
Introduction to Docker - Learning containerization  XP conference 2016Introduction to Docker - Learning containerization  XP conference 2016
Introduction to Docker - Learning containerization XP conference 2016XP Conference India
 
Integrating Git, Gerrit and Jenkins/Hudson with Mylyn
Integrating Git, Gerrit and Jenkins/Hudson with MylynIntegrating Git, Gerrit and Jenkins/Hudson with Mylyn
Integrating Git, Gerrit and Jenkins/Hudson with MylynSascha Scholz
 
Jenkins Introduction
Jenkins IntroductionJenkins Introduction
Jenkins IntroductionPavan Gupta
 
A Skeptic's Guide to Docker
A Skeptic's Guide to DockerA Skeptic's Guide to Docker
A Skeptic's Guide to DockerTori Wieldt
 
DEVNET-1169 CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...
DEVNET-1169	CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...DEVNET-1169	CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...
DEVNET-1169 CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...Cisco DevNet
 
Jenkins tutorial for beginners
Jenkins tutorial for beginnersJenkins tutorial for beginners
Jenkins tutorial for beginnersBugRaptors
 
Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2
Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2
Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2Amrita Prasad
 
Rundeck's History and Future
Rundeck's History and FutureRundeck's History and Future
Rundeck's History and Futuredev2ops
 
SBG Infrastructure Tools
SBG Infrastructure ToolsSBG Infrastructure Tools
SBG Infrastructure Tools🤘Ivan Vandot
 
Practical Approaches to Cloud Native Security
Practical Approaches to Cloud Native SecurityPractical Approaches to Cloud Native Security
Practical Approaches to Cloud Native SecurityKarthik Gaekwad
 
Yale Jenkins Show and Tell
Yale Jenkins Show and TellYale Jenkins Show and Tell
Yale Jenkins Show and TellE. Camden Fisher
 
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Controlindiver
 
Introduction to jenkins
Introduction to jenkinsIntroduction to jenkins
Introduction to jenkinsAbe Diaz
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for DocumentationAnne Gentle
 

Mais procurados (20)

Introduction to Containers & Diving a little deeper into the benefits of Con...
 Introduction to Containers & Diving a little deeper into the benefits of Con... Introduction to Containers & Diving a little deeper into the benefits of Con...
Introduction to Containers & Diving a little deeper into the benefits of Con...
 
Jenkins for java world
Jenkins for java worldJenkins for java world
Jenkins for java world
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developers
 
Louisville Software Engineering Meet Up: Continuous Integration Using Jenkins
Louisville Software Engineering Meet Up: Continuous Integration Using JenkinsLouisville Software Engineering Meet Up: Continuous Integration Using Jenkins
Louisville Software Engineering Meet Up: Continuous Integration Using Jenkins
 
Introduction to Docker - Learning containerization XP conference 2016
Introduction to Docker - Learning containerization  XP conference 2016Introduction to Docker - Learning containerization  XP conference 2016
Introduction to Docker - Learning containerization XP conference 2016
 
Jenkins tutorial
Jenkins tutorialJenkins tutorial
Jenkins tutorial
 
Integrating Git, Gerrit and Jenkins/Hudson with Mylyn
Integrating Git, Gerrit and Jenkins/Hudson with MylynIntegrating Git, Gerrit and Jenkins/Hudson with Mylyn
Integrating Git, Gerrit and Jenkins/Hudson with Mylyn
 
Jenkins Introduction
Jenkins IntroductionJenkins Introduction
Jenkins Introduction
 
A Skeptic's Guide to Docker
A Skeptic's Guide to DockerA Skeptic's Guide to Docker
A Skeptic's Guide to Docker
 
DEVNET-1169 CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...
DEVNET-1169	CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...DEVNET-1169	CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...
DEVNET-1169 CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...
 
Automating the Quality
Automating the QualityAutomating the Quality
Automating the Quality
 
Jenkins tutorial for beginners
Jenkins tutorial for beginnersJenkins tutorial for beginners
Jenkins tutorial for beginners
 
Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2
Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2
Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2
 
Rundeck's History and Future
Rundeck's History and FutureRundeck's History and Future
Rundeck's History and Future
 
SBG Infrastructure Tools
SBG Infrastructure ToolsSBG Infrastructure Tools
SBG Infrastructure Tools
 
Practical Approaches to Cloud Native Security
Practical Approaches to Cloud Native SecurityPractical Approaches to Cloud Native Security
Practical Approaches to Cloud Native Security
 
Yale Jenkins Show and Tell
Yale Jenkins Show and TellYale Jenkins Show and Tell
Yale Jenkins Show and Tell
 
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Control
 
Introduction to jenkins
Introduction to jenkinsIntroduction to jenkins
Introduction to jenkins
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for Documentation
 

Destaque

Prezentacija 1
Prezentacija 1Prezentacija 1
Prezentacija 1Alexsashka
 
Top 12 Vegetables with Protein as Good as Meat
Top 12 Vegetables with Protein as Good as MeatTop 12 Vegetables with Protein as Good as Meat
Top 12 Vegetables with Protein as Good as MeatUrbanWired
 
Developing Hardware: APIs for the physical world
Developing Hardware: APIs for the physical worldDeveloping Hardware: APIs for the physical world
Developing Hardware: APIs for the physical worldrelayr
 
relayr: connect to the Internet of Things
relayr: connect to the Internet of Thingsrelayr: connect to the Internet of Things
relayr: connect to the Internet of Thingsrelayr
 
Developing apps for the physical world
Developing apps for the  physical worldDeveloping apps for the  physical world
Developing apps for the physical worldrelayr
 
Top 6 Delicious Health Breakfast Recipes
Top 6 Delicious Health Breakfast RecipesTop 6 Delicious Health Breakfast Recipes
Top 6 Delicious Health Breakfast RecipesUrbanWired
 
Android Gadgets, Bluetooth Low Energy, and the WunderBar
Android Gadgets, Bluetooth Low Energy, and the WunderBarAndroid Gadgets, Bluetooth Low Energy, and the WunderBar
Android Gadgets, Bluetooth Low Energy, and the WunderBarrelayr
 

Destaque (8)

Prezentacija 1
Prezentacija 1Prezentacija 1
Prezentacija 1
 
Top 12 Vegetables with Protein as Good as Meat
Top 12 Vegetables with Protein as Good as MeatTop 12 Vegetables with Protein as Good as Meat
Top 12 Vegetables with Protein as Good as Meat
 
Developing Hardware: APIs for the physical world
Developing Hardware: APIs for the physical worldDeveloping Hardware: APIs for the physical world
Developing Hardware: APIs for the physical world
 
relayr: connect to the Internet of Things
relayr: connect to the Internet of Thingsrelayr: connect to the Internet of Things
relayr: connect to the Internet of Things
 
Developing apps for the physical world
Developing apps for the  physical worldDeveloping apps for the  physical world
Developing apps for the physical world
 
Family
FamilyFamily
Family
 
Top 6 Delicious Health Breakfast Recipes
Top 6 Delicious Health Breakfast RecipesTop 6 Delicious Health Breakfast Recipes
Top 6 Delicious Health Breakfast Recipes
 
Android Gadgets, Bluetooth Low Energy, and the WunderBar
Android Gadgets, Bluetooth Low Energy, and the WunderBarAndroid Gadgets, Bluetooth Low Energy, and the WunderBar
Android Gadgets, Bluetooth Low Energy, and the WunderBar
 

Semelhante a Building Top-Notch Androids SDKs

Docker in Production: How RightScale Delivers Cloud Applications
Docker in Production: How RightScale Delivers Cloud ApplicationsDocker in Production: How RightScale Delivers Cloud Applications
Docker in Production: How RightScale Delivers Cloud ApplicationsRightScale
 
Pragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecturePragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecturePiotr Pelczar
 
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...Ambassador Labs
 
React.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIReact.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIMarcin Grzywaczewski
 
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
 
Android : How Do I Code Thee?
Android : How Do I Code Thee?Android : How Do I Code Thee?
Android : How Do I Code Thee?Viswanath J
 
PittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earth
PittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earthPittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earth
PittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earthGrace Jansen
 
DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2Docker, Inc.
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
 
JavaFX - Sketch Board to Production
JavaFX - Sketch Board to ProductionJavaFX - Sketch Board to Production
JavaFX - Sketch Board to ProductionYoav Aharoni
 
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
 Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to realityDaniel Gallego Vico
 
Introduction to React native
Introduction to React nativeIntroduction to React native
Introduction to React nativeDhaval Barot
 
Introduction to Android Development and Security
Introduction to Android Development and SecurityIntroduction to Android Development and Security
Introduction to Android Development and SecurityKelwin Yang
 
Application Lifecycle Management
Application Lifecycle ManagementApplication Lifecycle Management
Application Lifecycle ManagementAmazon Web Services
 
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...Ambassador Labs
 
MvvmCross Introduction
MvvmCross IntroductionMvvmCross Introduction
MvvmCross IntroductionStuart Lodge
 
MvvmCross Seminar
MvvmCross SeminarMvvmCross Seminar
MvvmCross SeminarXamarin
 
Announcing AWS CodeBuild - January 2017 Online Teck Talks
Announcing AWS CodeBuild - January 2017 Online Teck TalksAnnouncing AWS CodeBuild - January 2017 Online Teck Talks
Announcing AWS CodeBuild - January 2017 Online Teck TalksAmazon Web Services
 

Semelhante a Building Top-Notch Androids SDKs (20)

Docker in Production: How RightScale Delivers Cloud Applications
Docker in Production: How RightScale Delivers Cloud ApplicationsDocker in Production: How RightScale Delivers Cloud Applications
Docker in Production: How RightScale Delivers Cloud Applications
 
Pragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecturePragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecture
 
Building XWiki
Building XWikiBuilding XWiki
Building XWiki
 
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
 
React.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIReact.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UI
 
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
 
Android : How Do I Code Thee?
Android : How Do I Code Thee?Android : How Do I Code Thee?
Android : How Do I Code Thee?
 
PittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earth
PittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earthPittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earth
PittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earth
 
DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
JavaFX - Sketch Board to Production
JavaFX - Sketch Board to ProductionJavaFX - Sketch Board to Production
JavaFX - Sketch Board to Production
 
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
 Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
 
Introduction to React native
Introduction to React nativeIntroduction to React native
Introduction to React native
 
Introduction to Android Development and Security
Introduction to Android Development and SecurityIntroduction to Android Development and Security
Introduction to Android Development and Security
 
Application Lifecycle Management
Application Lifecycle ManagementApplication Lifecycle Management
Application Lifecycle Management
 
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
 
CASCON 2017 - OpenAPI v3
CASCON 2017 - OpenAPI v3CASCON 2017 - OpenAPI v3
CASCON 2017 - OpenAPI v3
 
MvvmCross Introduction
MvvmCross IntroductionMvvmCross Introduction
MvvmCross Introduction
 
MvvmCross Seminar
MvvmCross SeminarMvvmCross Seminar
MvvmCross Seminar
 
Announcing AWS CodeBuild - January 2017 Online Teck Talks
Announcing AWS CodeBuild - January 2017 Online Teck TalksAnnouncing AWS CodeBuild - January 2017 Online Teck Talks
Announcing AWS CodeBuild - January 2017 Online Teck Talks
 

Building Top-Notch Androids SDKs

  • 1. Building Top-Notch Android SDKs Hugo Doménech @hudomju
  • 3. relayr bring things to life easy tools to connect things and apps
  • 4. Building Top-Notch Android SDKs Hugo Doménech @hudomju
  • 5. Agenda 1. Why? 2. How? 3. What?
  • 6. Agenda 1. Why? 2. How? 3. What?
  • 7. Reasons • Developers are lazy - reuse code • Separate concerns (build independent blocs) • Write better software • Speed up compile time • Make other people happy…
  • 8. Make it open source! • Feel better • Code better: Power of shame • Get features and bug fixes for free • Easier to sell - quality prove • Excitement from the community • Security • It’s free • But most important: Be famous!
  • 9. Agenda 1. Why? 2. How? 3. What?
  • 10. Decide what you are providing Library Project jar (Java ARchive) Apk Lib aar (Android Archive Resource)
  • 12. Create a SDK! 1. Don’t start with code: README.md and ROADMAP.md 2. Put it in a Git Repository 3. Include it in your CI (Continuous Integration) 4. Add static code analysis tools (i.e. FindBugs, Lint) 5. Autogenerate documentation (i.e. JavaDoc) 6. Prepare for testing 7. Make it accessible (i.e. distribute via maven) 8. Add a sample project
  • 13. Managing Releases Use the library in a real project Master SDK as a git submodule Master Develop Develop Feature Branch Feature Branch
  • 14. Agenda 1. Why? 2. How? 3. What?
  • 15. Great SDK Qualities • Available • Easy to use • Flexible • Testable • Performant • Reliable • Lightweight
  • 16. Available build.gradle dependencies { include ‘io.relayr:android-sdk:0.0.5’ } *gradle-mvn-push.gradle by Chris Banes
  • 17. Easy to use • Intuitive • Consistent • Easy to use, hard to misuse
  • 18. Easy to use • Easy to initialise RelayrSdk.init(this); • Easy to use RelayrSdk.logMessage(“At droidcon Krakow!”);
  • 19. Flexible new RelayrSdk.Builder(this) .inMockMode(true) .apiEndpoint(“api.relayr.io”) .withDebugger(new DefaultDebugger()) .build();
  • 20. Flexible - minimize permisions
  • 21. Flexible - minimize permisions public boolean canVibrate() { String permission = "android.permission.VIBRATE"; int result = mContext.checkCallingOrSelfPermission(permission); return result == PackageManager.PERMISSION_GRANTED; }
  • 22. Flexible - minimize requisites <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-feature android:name=“android.hardware.bluetooth_le" android:required="false"/> public boolean isBleSupported() { String feature = PackageManager.FEATURE_BLUETOOTH_LE; return getPackageManager().hasSystemFeature(feature); }
  • 23. Flexible - support different versions defaultConfig { applicationId 'io.relayr.wunderbar' minSdkVersion 15 targetSdkVersion 21 versionCode 22 versionName '1.0.22' } public boolean isSdk18() { return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2; }
  • 24. Flexible - be context aware mApplication.registerActivityLifecycleCallbacks( new Application.ActivityLifecycleCallbacks() { @Override public void onActivityResumed(Activity activity) { // we know there’s a UI! } } );
  • 25. Testable • Mock mode (no network requests) • No static methods • Avoid final classes • Avoid access to fields directly
  • 26. Performant • Don’t block the current thread! RelayrSdk.sendMessage(“At droidcon Krakow!”);
  • 27. Performant - Don’t log in production • With Code RelayrSdk.Builder(this) .setDebuggable(false) .build(); • On the Manifest debuggable=false
  • 28. Reliable • Don’t crash silently - inform the user when a problem occurs RelayrSdk.login(new LoginCallback() { public void onSuccess() { // sign the user into the app } public void onError() { // show error message } });
  • 29. Lightweight • Poor network conditions • Association between small and fast • Reluctance to include large libraries
  • 30. Lightweight - don’t require libraries private boolean hasOkHttpOnClasspath() { try { Class.forName("com.squareup.okhttp.OkHttpClient"); return true; } catch (ClassNotFoundException e) { } return false; } dependencies { provided ‘com.squareup.okhttp:okhttp:2.0.0’ }
  • 31. Lightweight - be modular dependencies { } include ‘io.relayr:java-sdk:0.0.5’ include ‘io.relayr:android-sdk:0.0.5’ include ‘io.relayr:android-onboarding:0.0.7’ include ‘io.relayr:master-module:1.2.0’ include ‘io.relayr:android-commons:1.0.0’
  • 32. Recapitulate 1. Why? 2. How? 3. What?