Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building the Fabric SDKs - #MBLTDev (30 min)

Ty Smith
October 28, 2014

Building the Fabric SDKs - #MBLTDev (30 min)

Ty Smith

October 28, 2014
Tweet

More Decks by Ty Smith

Other Decks in Programming

Transcript

  1. Extensible Classes class MyApiClient extends TwitterApiClient { interface MyService {

    @GET(“/1.1/statuses/show.json”) Tweet getTweet(@Query(“id”) int id); } MyService getMyService() { return getService(MyService.class); } }
  2. Permissions: Runtime Detection protected boolean canCheckNetworkState() { String permission =

    Manifest.permission.ACCESS_NETWORK_STATE; int result = context.checkCallingOrSelfPermission(permission); return (result == PackageManager.PERMISSION_GRANTED); }
  3. UI from Application Context WeakReference<Activity> currentActivity = new WeakReference<Activity>(); @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)

    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); } }); } }
  4. How big are Fabric AARs? Fabric: 190kb Crashlytics: 90kb Beta:

    13kb Answers: 20kb Twitter API & SSO: 296kb Tweet UI: 120kb Tweet Composer: 5kb Digits: 236kb
  5. 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
  6. Dalvik Method Count > git clone [email protected]: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
  7. 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; } }