TOOLS OF THE TRADE Hello! I AM ZARAH I am an Android developer - - PowerPoint PPT Presentation

tools of the trade
SMART_READER_LITE
LIVE PREVIEW

TOOLS OF THE TRADE Hello! I AM ZARAH I am an Android developer - - PowerPoint PPT Presentation

TOOLS OF THE TRADE Hello! I AM ZARAH I am an Android developer for Domain.com.au THE KEY Know available tools THE KEY Know available tools There is no correct setup CODE FRAGMENTS FRAGMENT LIFECYCLE FragmentManager.


slide-1
SLIDE 1

TOOLS OF THE TRADE

slide-2
SLIDE 2

Hello!

I AM ZARAH

I am an Android developer for Domain.com.au

slide-3
SLIDE 3

THE KEY

Know available tools

slide-4
SLIDE 4

THE KEY

Know available tools There is no “correct” setup

slide-5
SLIDE 5

CODE

slide-6
SLIDE 6

FRAGMENTS

slide-7
SLIDE 7

FRAGMENT LIFECYCLE

FragmentManager.enableDebugLogging(true);

slide-8
SLIDE 8

SERVICES

slide-9
SLIDE 9

SERVICES

@Override public void onCreate() { super.onCreate(); android.os.Debug.waitForDebugger(); // Do stuff in your service Log.d("MyService", "I am inside the service!"); }

slide-10
SLIDE 10

SERVICES

@Override public void onCreate() { super.onCreate(); android.os.Debug.waitForDebugger(); // Do stuff in your service Log.d("MyService", "I am inside the service!"); }

slide-11
SLIDE 11

SERVICES

  • Put a breakpoint AFTER the call to wait
slide-12
SLIDE 12

SERVICES

  • Put a breakpoint AFTER the call to wait
  • Edit your Run Configurations
slide-13
SLIDE 13

SERVICES

  • Trigger service
slide-14
SLIDE 14

SERVICES

  • Trigger service
  • Attach debugger

<service android:name="com.myapp.MySyncService" android:exported="true" android:process=":sync" >

slide-15
SLIDE 15

BUILT-IN TOOLS

slide-16
SLIDE 16

DEBUGGER

slide-17
SLIDE 17

DEBUGGER Say NO! to the green bug

slide-18
SLIDE 18

DEBUGGER Create a new keyboard shortcut for Attach Debugger to Android Process Say NO! to the green bug

slide-19
SLIDE 19

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

slide-20
SLIDE 20

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!

slide-21
SLIDE 21

DEBUGGER

slide-22
SLIDE 22

DEBUGGER

Run then Attach

slide-23
SLIDE 23

BREAKPOINTS

slide-24
SLIDE 24

BREAKPOINTS

slide-25
SLIDE 25

BREAKPOINTS (AN ASIDE)

slide-26
SLIDE 26

BREAKPOINTS

slide-27
SLIDE 27

BREAKPOINTS

Stop during interesting iterations

slide-28
SLIDE 28

BREAKPOINTS

Suspend on exceptions

slide-29
SLIDE 29

BREAKPOINTS

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

slide-30
SLIDE 30

DEBUG TOOL WINDOW

slide-31
SLIDE 31

DEBUG TOOL WINDOW

slide-32
SLIDE 32

FRAMES

slide-33
SLIDE 33

VARIABLES

slide-34
SLIDE 34

VARIABLES

slide-35
SLIDE 35

EVALUATING EXPRESSIONS

slide-36
SLIDE 36

WATCHES

slide-37
SLIDE 37

WATCHES

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

current frame

slide-38
SLIDE 38

WATCHES

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

current frame

slide-39
SLIDE 39

WATCHES

slide-40
SLIDE 40

WATCHES

slide-41
SLIDE 41

WATCHES

slide-42
SLIDE 42

WATCHES

  • No need to Timber/Toast/Log
slide-43
SLIDE 43

WATCHES

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

lots of them

slide-44
SLIDE 44

WATCHES

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

lots of them

  • Persistent across sessions
slide-45
SLIDE 45

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

slide-46
SLIDE 46

SYSTEM INFORMATION

slide-47
SLIDE 47

SYSTEM INFORMATION

Info dump of system state

slide-48
SLIDE 48

SYSTEM INFORMATION

slide-49
SLIDE 49

SYSTEM INFORMATION

Activity Manager State

Activity lifecycle state Config values Fragments and their states View hierarchy Choreography state Looper state

slide-50
SLIDE 50

SYSTEM INFORMATION

Activity Manager State

Activity lifecycle state Config values Fragments and their states View hierarchy Choreography state Looper state

Package Info

Manifest information APK info User install info

slide-51
SLIDE 51

SYSTEM INFORMATION

Activity Manager State

Activity 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

slide-52
SLIDE 52

SYSTEM INFORMATION

Memory Usage

  • ver Time

Runtime stats Memory usages Low level info

slide-53
SLIDE 53

SYSTEM INFORMATION

Memory Usage

  • ver Time

Runtime stats Memory usages Low level info

Graphics State

How well animations are doing Cache info View hierarchy

slide-54
SLIDE 54

LAYOUT INSPECTOR

slide-55
SLIDE 55

LAYOUT INSPECTOR

slide-56
SLIDE 56

THIRD PARTY TOOLS

slide-57
SLIDE 57

HUGO

Annotation-based = EASY

slide-58
SLIDE 58

HUGO

Annotation-based = EASY Shows 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

slide-59
SLIDE 59

HUGO (AN ASIDE)

logm live template

slide-60
SLIDE 60

ADB PLUGIN

App actions from within Studio

slide-61
SLIDE 61

ADB PLUGIN

No fussing with Settings

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

slide-62
SLIDE 62

STETHO

Wealth of options

slide-63
SLIDE 63

STETHO

Wealth of options

  • DB inspection
slide-64
SLIDE 64

STETHO

Wealth of options

  • DB inspection
  • SharedPreferences
slide-65
SLIDE 65

STETHO

Wealth of options

  • DB inspection
  • SharedPreferences
  • Network inspection
slide-66
SLIDE 66

STETHO

Wealth of options

  • DB inspection
  • SharedPreferences
  • Network inspection
  • View hierarchy
slide-67
SLIDE 67

STETHO

Wealth of options

  • DB inspection
  • SharedPreferences
  • Network inspection
  • View hierarchy
  • dumpapp
slide-68
SLIDE 68

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

Source: Facebook

slide-69
SLIDE 69

PIDCAT

Logcat with less pain

slide-70
SLIDE 70

PIDCAT

Logcat with less pain

https://github.com/JakeWharton/pidcat

slide-71
SLIDE 71

LEAK CANARY

slide-72
SLIDE 72

LEAK CANARY https://github.com/square/leakcanary

Source: Square

slide-73
SLIDE 73

Some practical stuff

slide-74
SLIDE 74

STUDIO IS BEING WEIRD

Cannot add breakpoint

slide-75
SLIDE 75

STUDIO IS BEING WEIRD

Cannot add breakpoint ADB cannot see devices

slide-76
SLIDE 76

STUDIO IS BEING WEIRD

First aid

slide-77
SLIDE 77

STUDIO IS BEING WEIRD

First aid

  • Unplug then re-plug device
slide-78
SLIDE 78

STUDIO IS BEING WEIRD

First aid

  • Unplug then re-plug device
  • Disable then re-enable ADB

integration

slide-79
SLIDE 79

STUDIO IS BEING WEIRD

First aid

  • Unplug then re-plug device
  • Disable then re-enable ADB

integration

  • Invalidate caches and restart
slide-80
SLIDE 80

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

slide-81
SLIDE 81

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

slide-82
SLIDE 82

BETTER CODING, (HOPEFULLY) LESS DEBUGGING

Use support annotations

slide-83
SLIDE 83

BETTER CODING, (HOPEFULLY) LESS DEBUGGING

Use support annotations Listen to Lint

slide-84
SLIDE 84

BETTER CODING, (HOPEFULLY) LESS DEBUGGING

Use support annotations Listen to Lint Use AppCompat methods

slide-85
SLIDE 85

ADDITIONAL RESOURCES

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

slide-86
SLIDE 86

THANK YOU!

www.zdominguez.com +ZarahDominguez @zarahjutz

Thank you!

ANY QUESTIONS?

slide-87
SLIDE 87

APPENDIX

slide-88
SLIDE 88

SUPPORT ANNOTATIONS

Add the dependency**

dependencies { compile 'com.android.support:support-annotations:24.2.0' }

slide-89
SLIDE 89

SUPPORT ANNOTATIONS

Profit

private 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 }

slide-90
SLIDE 90

SYSTEM INFORMATION

Activity Manager State

slide-91
SLIDE 91

SYSTEM INFORMATION

Package Information

slide-92
SLIDE 92

SYSTEM INFORMATION

Memory Usage

slide-93
SLIDE 93

SYSTEM INFORMATION

Memory Usage over time

slide-94
SLIDE 94

SYSTEM INFORMATION

Graphics state