TARGI MOBILNE, DZIEN I, SALA A, Narzędziownik programisty Android, Wojciech Kaliciński, We like...

Post on 13-Jan-2015

314 views 2 download

description

 

Transcript of TARGI MOBILNE, DZIEN I, SALA A, Narzędziownik programisty Android, Wojciech Kaliciński, We like...

Narzędziownikczyli co każdy programista

Androida znać powinien

+Wojtek Kaliciński+Wojtek Kaliciński

Najczęstsze problemy

Najczęstsze problemy

Wolno działa

Zacina się interfejs

Zżera całą pamięć

Rozładowuje baterię

ANR

Najczęstsze problemy

Wolno działa

Zacina się interfejs

Zżera całą pamięć

Rozładowuje baterię

ANR

CPU

GPU

RAM

Serwisy w tle

Wątek UI

Systrace

Systrace

Systrace

Systrace

TraceView @Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

Debug.startMethodTracing();

}

@Override

public void onStop() {

super.onStop();

Debug.stopMethodTracing();

}

TraceView

TraceView

HierarchyViewer https://github.com/romainguy/ViewServer/public class MyActivity extends Activity {

public void onCreate(Bundle savedInstanceState ) {

super.onCreate(savedInstanceState);

// Set content view, etc.

ViewServer.get(this).addWindow(this);

}

public void onDestroy() {

super.onDestroy();

ViewServer.get(this).removeWindow(this);

}

public void onResume() {

super.onResume();

ViewServer.get(this).setFocusedWindow(this);

}

}

HierarchyViewer

HierarchyViewer

Tracer for OpenGL ES

Tracer for OpenGL ES

Tracer for OpenGL ES

Tracer for OpenGL ES

Developer options > Debug GPU overdraw

Developer options > Debug GPU overdraw

Developer options > Debug GPU overdraw

Allocation Tracker

StrictModepublic void onCreate() {

if (DEVELOPER_MODE) {

StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()

.detectDiskReads()

.detectDiskWrites()

.detectNetwork()

.penaltyLog() // or .penaltyDeath()

.build());

}

super.onCreate();

}

$ adb shell dumpsys meminfo com.package** MEMINFO in pid 9292 [pl.przepisy] ** Pss Private Private Swapped Heap Heap Heap Total Dirty Clean Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ ------ Native Heap 9382 9356 0 0 16844 14427 148 Dalvik Heap 7963 7420 0 0 15564 15524 40 Dalvik Other 2076 1916 0 0 [...] Graphics 17696 17696 0 0 [...] TOTAL 48947 42776 2088 0 32408 29951 188 Objects Views: 100 ViewRootImpl: 2 AppContexts: 5 Activities: 1 Assets: 2 AssetManagers: 2 Local Binders: 15 Proxy Binders: 24 Death Recipients: 0 OpenSSL Sockets: 1

$ adb shell dumpsys procstats com.package[...]

* pl.przepisy / u0a85: * pl.przepisy / u0a85: TOTAL: 31% ( 39MB-47MB-87MB/36MB-43MB-72MB over 22) Top: 31% ( 39MB-47MB-87MB/36MB-43MB-72MB over 22) (Cached): 3.3% (45MB-56MB-67MB/40MB-48MB-56MB over 2) * pl.przepisy.RequestService: Process: pl.przepisy Running count 12 / time 0.49% Started count 6 / time 0.48% Executing count 13 / time 0.02%

Developer options > Process Stats

Chrome remote debugging

WebView remote debugging (4.4+)

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

if ( 0 != ( getApplcationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE ) ) {

WebView.setWebContentsDebuggingEnabled(true);

}

}

Dziękuję!Q&A?

google.com/+Wojtek Kaliciński