TRADE TOOLS OF THE - YOW! Conferences...DEBUG TOOL WINDOW DEBUG TOOL WINDOW FRAMES VARIABLES...

Preview:

Citation preview

TOOLS OF THE TRADE

Hello!

I AM ZARAHI am an Android developer for

Domain.com.au

THE KEY

Know available tools

THE KEY

Know available toolsThere is no “correct” setup

CODE

FRAGMENTS

FRAGMENT LIFECYCLE

FragmentManager.enableDebugLogging(true);

SERVICES

SERVICES

@Override

public void onCreate() {

super.onCreate();

android.os.Debug.waitForDebugger();

// Do stuff in your service

Log.d("MyService", "I am inside the service!");

}

SERVICES

@Override

public void onCreate() {

super.onCreate();

android.os.Debug.waitForDebugger();

// Do stuff in your service

Log.d("MyService", "I am inside the service!");

}

SERVICES

◦ Put a breakpoint AFTER the call to wait

SERVICES

◦ Put a breakpoint AFTER the call to wait◦ Edit your Run Configurations

SERVICES

◦ Trigger service

SERVICES

◦ Trigger service◦ Attach debugger

<service

android:name="com.myapp.MySyncService"

android:exported="true"

android:process=":sync" >

BUILT-IN TOOLS

DEBUGGER

DEBUGGER

Say NO! to the green bug

DEBUGGER

Create a new keyboard shortcut for Attach Debugger to Android Process

Say NO! to the green bug

DEBUGGER

Create a new keyboard shortcut for Attach Debugger to Android Process

Say NO! to the green bug

Preferences > Keymap > Main Menu > Run > Attach Debugger to Android Process > Right Click > Add Keyboard Shortcut

DEBUGGER

Create a new keyboard shortcut for Attach Debugger to Android Process

Say NO! to the green bug

Preferences > Keymap > Main Menu > Run > Attach Debugger to Android Process > Right Click > Add Keyboard Shortcut AIN’T NOBODY GOT TIME FOR

THAT!

DEBUGGER

DEBUGGER

Run then Attach

BREAKPOINTS

BREAKPOINTS

BREAKPOINTS (AN ASIDE)

BREAKPOINTS

BREAKPOINTS

Stop during interesting iterations

BREAKPOINTS

Suspend on exceptions

BREAKPOINTS

If you have a bunch of breakpoints related to a particular bug, GROUP THEM

DEBUG TOOL WINDOW

DEBUG TOOL WINDOW

FRAMES

VARIABLES

VARIABLES

EVALUATING EXPRESSIONS

WATCHES

WATCHES

◦ Add variables and expressions◦ Resolved in the context of the

current frame

WATCHES

◦ Add variables and expressions◦ Resolved in the context of the

current frame

WATCHES

WATCHES

WATCHES

WATCHES

◦ No need to Timber/Toast/Log

WATCHES

◦ No need to Timber/Toast/Log◦ Like evaluated expressions, but

lots of them

WATCHES

◦ No need to Timber/Toast/Log◦ Like evaluated expressions, but

lots of them◦ Persistent across sessions

WATCHES

◦ No need to Timber/Toast/Log◦ Like evaluated expressions, but

lots of them◦ Persistent across sessions◦ Change expressions on the fly

Do even more: IntelliJ blog

SYSTEM INFORMATION

SYSTEM INFORMATION

Info dump of system state

SYSTEM INFORMATION

SYSTEM INFORMATION

Activity Manager StateActivity lifecycle state

Config values

Fragments and their states

View hierarchy

Choreography state

Looper state

SYSTEM INFORMATION

Activity Manager StateActivity lifecycle state

Config values

Fragments and their states

View hierarchy

Choreography state

Looper state

Package Info

Manifest information

APK info

User install info

SYSTEM INFORMATION

Activity Manager StateActivity lifecycle state

Config values

Fragments and their states

View hierarchy

Choreography state

Looper state

Package Info

Manifest information

APK info

User install info

Memory Usage

Memory allocations

Asset allocations

SYSTEM INFORMATION

Memory Usage over TimeRuntime stats

Memory usages

Low level info

SYSTEM INFORMATION

Memory Usage over TimeRuntime stats

Memory usages

Low level info

Graphics State

How well animations are doing

Cache info

View hierarchy

LAYOUT INSPECTOR

LAYOUT INSPECTOR

THIRD PARTY TOOLS

HUGO

Annotation-based = EASY

HUGO

Annotation-based = EASYShows method calls++

https://github.com/JakeWharton/hugo

9477-9477/io.plaidapp V/DataManager: ⇢ sourceLoaded(data=[Redraw Keyboard, Saas 01, Air Traveller App, Become a driver], page=2, key="DRIBBBLE_QUERY_Material Design")9477-9477/io.plaidapp V/DataManager: ⇠ sourceLoaded [0ms] = true

HUGO (AN ASIDE)

logm live template

ADB PLUGIN

App actions from within Studio

ADB PLUGIN

No fussing with Settings

https://github.com/pbreault/adb-idea

STETHO

Wealth of options

STETHO

Wealth of options◦ DB inspection

STETHO

Wealth of options◦ DB inspection◦ SharedPreferences

STETHO

Wealth of options◦ DB inspection◦ SharedPreferences◦ Network inspection

STETHO

Wealth of options◦ DB inspection◦ SharedPreferences◦ Network inspection◦ View hierarchy

STETHO

Wealth of options◦ DB inspection◦ SharedPreferences◦ Network inspection◦ View hierarchy◦ dumpapp

STETHO

http://facebook.github.io/stetho/

Source: Facebook

PIDCAT

Logcat with less pain

PIDCAT

Logcat with less pain

https://github.com/JakeWharton/pidcat

LEAK CANARY

LEAK CANARY

https://github.com/square/leakcanary

Source: Square

Some practical stuff

STUDIO IS BEING WEIRD

Cannot add breakpoint

STUDIO IS BEING WEIRD

Cannot add breakpointADB cannot see devices

STUDIO IS BEING WEIRD

First aid

STUDIO IS BEING WEIRD

First aid◦ Unplug then re-plug device

STUDIO IS BEING WEIRD

First aid◦ Unplug then re-plug device◦ Disable then re-enable ADB

integration

STUDIO IS BEING WEIRD

First aid◦ Unplug then re-plug device◦ Disable then re-enable ADB

integration◦ Invalidate caches and restart

STUDIO IS BEING WEIRD

First aid◦ Unplug then re-plug device◦ Disable then re-enable ADB

integration◦ Invalidate caches and restart◦ Disable the re-enable USB

debugging on device

But I really don’t want to do all that...

BETTER CODING, (HOPEFULLY) LESS DEBUGGING

Use support annotations

BETTER CODING, (HOPEFULLY) LESS DEBUGGING

Use support annotationsListen to Lint

BETTER CODING, (HOPEFULLY) LESS DEBUGGING

Use support annotationsListen to LintUse AppCompat methods

ADDITIONAL RESOURCES

Philippe Breault [Twitter]Jake Wharton [Github]Square [Github]

THANK YOU!

www.zdominguez.com+ZarahDominguez@zarahjutz

Thank you!

ANY QUESTIONS?

APPENDIX

SUPPORT ANNOTATIONS

Add the dependency**dependencies { compile 'com.android.support:support-annotations:24.2.0'}

SUPPORT ANNOTATIONS

Profitprivate void setThingsToTextView(int res1, int res2, int res3, int res4) { // do stuff}

private void setThingsToTextView(@IdRes int textView, @StringRes int introText, @DrawableRes int heroImage, @ColorRes int backgroundColour) { // do stuff}

SYSTEM INFORMATION

Activity Manager State

SYSTEM INFORMATION

Package Information

SYSTEM INFORMATION

Memory Usage

SYSTEM INFORMATION

Memory Usage over time

SYSTEM INFORMATION

Graphics state

Recommended