Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Building the Fabric SDKs 
Ty Smith 
October 28, 2014 @tsmith
Ty Smith 
Sr. Android Engineer, Fabric 
@tsmith
.io
Cannonball 
Fabric Sample App 
Open source for iOS & Android: 
github.com/twitterdev
Powerful 
Lightweight
Powerful
Ease of 
Integration
Ease of Integration 
Fabric.with(this, new Crashlytics());
Extensible
Extensible 
Crashlytics.start(this);
Extensible 
Crashlytics.start(this, 5); 
Crashlytics.setListener(createCrashlyticsListener()); 
Crashlytics.setPinningInfo...
Extensible 
Crashlytics.setListener(createCrashlyticsListener()); 
Crashlytics.setPinningInfo(createPinningInfoProvider())...
Extensible 
Crashlytics.start(this, delay, listener, pinningInfo, 
debugMode);
Extensible 
Crashlytics.start(this, 0, null, null, null, true);
Fluent Pattern 
Crashlytics crashlytics = new Crashlytics.Builder() 
.delay(1) 
.listener(createCrashlyticsListener()) 
.p...
Fluent Pattern 
Fabric.with(this, new Fabric.Builder(this) 
.kits(new Crashlytics()) 
.debuggable(true) 
.logger(new Defau...
Gracefully 
Degrade
Gracefully Degrade 
if (TextUtils.isEmpty(apiKey) 
if (debuggable){ 
throw new IllegalArgumentException( 
“apiKey is null!...
Minimizing 
Permissions
Minimizing Permissions 
<uses-permission android:name="android.permission.INTERNET"/>
Minimizing Permissions 
Crashlytics.setUserEmail(“appuser@domain.com”);
Permissions: 
Runtime Detection 
protected boolean canCheckNetworkState() { 
String permission = 
“android.permission.ACCE...
Multiple 
Application 
Types
Multiple Application Types 
package com.example; 
import android.app.Service; 
public class MyService 
extends Service { 
...
UI from Application Context 
private WeakReference<Activity> currentActivity = new 
WeakReference<Activity>(); 
@TargetApi...
Powerful SDKs 
Ease of Integration 
Extensibility 
Support all app types 
Permission detection
Lightweight
Binary Size
Binary Size
3rd Party 
Library 
Mindfulness
3rd Party 
Library Mindfulness 
30 
20 
10 
0
3rd Party Library Mindfulness 
PROTOBUF 
KB 
OURS 
KB
Dalvik 
Method 
Count
Dalvik Method Count 
>./gradlew assemble 
… 
Unable to execute dex: method ID not in [0, 
0xffff]: 65536 
Conversion to Da...
Dalvik Method Count 
> git clone git@github.com:mihaip/dex-method-counts.git 
> cd dex-method-counts 
> ant jar 
> ./dex-m...
Minimize 
Network 
Usage
Network Usage 
10X SMALLER 
XML PROTOBUF 
100X FASTER
Reduce 
Startup 
Time
Startup Time 
Thread.start(); 
Executors.newSingleThreadExecutor();
Startup Time 
class MyThreadFactory implements ThreadFactory { 
@Override 
public Thread newThread(Runnable runnable) { 
f...
Lightweight SDKs 
Binary size 
3rd party library mindfulness 
Dalvik Method Count 
Network usage 
Startup time
Lightweight 
Powerful
Thank You 
@tsmith
#MBLTdev: Разработка первоклассных SDK для Android (Twitter)
#MBLTdev: Разработка первоклассных SDK для Android (Twitter)
#MBLTdev: Разработка первоклассных SDK для Android (Twitter)
#MBLTdev: Разработка первоклассных SDK для Android (Twitter)
Upcoming SlideShare
Loading in …5
×

#MBLTdev: Разработка первоклассных SDK для Android (Twitter)

839 views

Published on

#MBLTdev: Конференция мобильных разработчиков
Спикер: Ty Smith
Старший инженер-программист, Twitter
http://mbltdev.ru/

Published in: Mobile
  • Login to see the comments

  • Be the first to like this

#MBLTdev: Разработка первоклассных SDK для Android (Twitter)

  1. 1. Building the Fabric SDKs Ty Smith October 28, 2014 @tsmith
  2. 2. Ty Smith Sr. Android Engineer, Fabric @tsmith
  3. 3. .io
  4. 4. Cannonball Fabric Sample App Open source for iOS & Android: github.com/twitterdev
  5. 5. Powerful Lightweight
  6. 6. Powerful
  7. 7. Ease of Integration
  8. 8. Ease of Integration Fabric.with(this, new Crashlytics());
  9. 9. Extensible
  10. 10. Extensible Crashlytics.start(this);
  11. 11. Extensible Crashlytics.start(this, 5); Crashlytics.setListener(createCrashlyticsListener()); Crashlytics.setPinningInfo(createPinningInfoProvider()) Crashlytics.getInstance().setDebugMode(true);
  12. 12. Extensible Crashlytics.setListener(createCrashlyticsListener()); Crashlytics.setPinningInfo(createPinningInfoProvider()); Crashlytics.getInstance().setDebugMode(true); Crashlytics.start(this, 5);
  13. 13. Extensible Crashlytics.start(this, delay, listener, pinningInfo, debugMode);
  14. 14. Extensible Crashlytics.start(this, 0, null, null, null, true);
  15. 15. Fluent Pattern Crashlytics crashlytics = new Crashlytics.Builder() .delay(1) .listener(createCrashlyticsListener()) .pinningInfo(createPinningInfoProvider()) .build(); Fabric.with(this, crashlytics);
  16. 16. Fluent Pattern Fabric.with(this, new Fabric.Builder(this) .kits(new Crashlytics()) .debuggable(true) .logger(new DefaultLogger(Log.VERBOSE)) .looper(getCustomLooper()) .executor(getCustomExecutorService()) .build());
  17. 17. Gracefully Degrade
  18. 18. Gracefully Degrade if (TextUtils.isEmpty(apiKey) if (debuggable){ throw new IllegalArgumentException( “apiKey is null!"); } else { return null; } }
  19. 19. Minimizing Permissions
  20. 20. Minimizing Permissions <uses-permission android:name="android.permission.INTERNET"/>
  21. 21. Minimizing Permissions Crashlytics.setUserEmail(“appuser@domain.com”);
  22. 22. Permissions: Runtime Detection protected boolean canCheckNetworkState() { String permission = “android.permission.ACCESS_NETWORK_STATE”; int result = context.checkCallingOrSelfPermission(permission); return (result == PackageManager.PERMISSION_GRANTED); }
  23. 23. Multiple Application Types
  24. 24. Multiple Application Types package com.example; import android.app.Service; public class MyService extends Service { }
  25. 25. UI from Application Context private WeakReference<Activity> currentActivity = new WeakReference<Activity>(); @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void registerLifecycleCallbacks() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { final Application app = ((Application)context); app.registerActivityLifecycleCallbacks( new ActivityLifecycleCallbacks() { @Override public void onActivityResumed(Activity activity) { currentActivity.set(activity); } }); } }
  26. 26. Powerful SDKs Ease of Integration Extensibility Support all app types Permission detection
  27. 27. Lightweight
  28. 28. Binary Size
  29. 29. Binary Size
  30. 30. 3rd Party Library Mindfulness
  31. 31. 3rd Party Library Mindfulness 30 20 10 0
  32. 32. 3rd Party Library Mindfulness PROTOBUF KB OURS KB
  33. 33. Dalvik Method Count
  34. 34. Dalvik Method Count >./gradlew assemble … Unable to execute dex: method ID not in [0, 0xffff]: 65536 Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
  35. 35. Dalvik Method Count > git clone git@github.com:mihaip/dex-method-counts.git > cd dex-method-counts > ant jar > ./dex-method-counts path/to/App.apk Read in 65490 method IDs. <root>: 65490 : 3 accessibilityservice: 6 bluetooth: 2 content: 248 pm: 22 res: 45 ... com: 53881 adjust: 283 sdk: 283
  36. 36. Minimize Network Usage
  37. 37. Network Usage 10X SMALLER XML PROTOBUF 100X FASTER
  38. 38. Reduce Startup Time
  39. 39. Startup Time Thread.start(); Executors.newSingleThreadExecutor();
  40. 40. Startup Time class MyThreadFactory implements ThreadFactory { @Override public Thread newThread(Runnable runnable) { final Thread thread = new Thread(runnable); thread.setPriority(Process.THREAD_PRIORITY_BACKGROUND); return thread; } }
  41. 41. Lightweight SDKs Binary size 3rd party library mindfulness Dalvik Method Count Network usage Startup time
  42. 42. Lightweight Powerful
  43. 43. Thank You @tsmith

×