Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
#mobilization2016
THE 2016 ANDROID
DEVELOPER TOOLBOX
@Nilhcem
#mobilization2016
THE 2016 ANDROID
DEVELOPER TOOLBOX
"Use the right tools for the right job"
(with the Android Plugin for Gradle)
BUILD VARIANTS
U+2020
https://github.com/JakeWharton/u2020
DEBUG SCREEN
Example from Google iosched
INTERNAL SETTINGS APP
Similar to U+2020 Sample app
Display build / device information
Change endpoint (restart process wit...
MOBILIZATION 2016 APPLICATION
https://github.com/Nilhcem/mobilization-2016
MEASURING TOOLS
ANDROID STUDIO
(Android Monitor tab)
DETECT MEMORY LEAKS
LEAK CANARY
https://github.com/square/leakcanary
FRAME RATE
build.gradle:
MyApplication.java:
https://github.com/wasabeef/Takt
compile 'jp.wasabeef:takt:1.0.3'
public clas...
HUGO
https://github.com/JakeWharton/hugo
Prefix classes/methods with:
@DebugLog
Result:
MobilizationApp V ⇢ onCreate()
V ⇢...
PIDCAT
https://github.com/JakeWharton/pidcat
$ pidcat com.nilhcem.mobilization
ANDROIDDEVMETRICS
build.gradle:
MyApplication.java:
https://github.com/frogermcs/AndroidDevMetrics
apply plugin: 'com.frog...
CODE STATIC ANALYSIS TOOLS
Lint
Error Prone (Google)
Infer (Facebook)
SONARQUBE
Dockerfile:
FROM java:8
MAINTAINER Nilhcem
RUN DEBIAN_FRONTEND=noninteractive apt update
RUN DEBIAN_FRONTEND=non...
SONARQUBE GRADLE CONFIGURATION
build.gradle:
apply plugin: 'org.sonarqube'
sonarqube {
properties {
def appProject = proje...
TESTING TOOLS
MOCK SERVER
NODEJS + EXPRESS
/* Setup */
var fs = require('fs');
var express = require('express');
var app = express();
app.set('port'...
NODEJS + EXPRESS
Slow service
sleep(2000);
function sleep(durationMillis) {
var now = new Date().getTime();
while (new Dat...
EXAMPLE
Then, go to:
https://github.com/Nilhcem/mobilization-2016
/tree/master/mockserver
$ npm install
$ npm start
http:/...
HOSTS EDITOR
https://play.google.com/store/apps/details?id=com.nilhcem.hostseditor
HTTP DEBUGGING
HTTP DEBUGGING
mitmproxy
Fiddler
Charles proxy
CHARLES PROXY
Simulate a slow connection
Repeat queries
Check the responses
Add some breakpoints to:
Cancel an HTTP(s) cal...
ANDROID STATE
RESTORING
DON'T KEEP ACTIVITIES
FILL RAM
https://play.google.com/store/apps/details?id=com.tspoon.androidtoolbelt
ANDROID DEVICE MONITOR - STOP PROCESS
ANALYZING TOOLS
DEVELOPER OPTIONS
UIAUTOMATORVIEWER
ANIMATIONS
Developer options -> Animation scale
ANIMATIONS
Make a screencast (API 19+):
VLC :
$ adb shell screenrecord /sdcard/demo.mp4
$ adb pull /sdcard/demo.mp4
Press ...
APKTOOL + DEX2JAR + JD-GUI
http://ibotpeaches.github.io/Apktool
https://github.com/pxb1988/dex2jar
http://jd.benow.ca
JADX
https://github.com/skylot/jadx
ANDROID STUDIO
(Build > Analyze APK)
STETHO
STETHO - UI
STETHO - NETWORK
STETHO
DUMPAPP
STETHO - DUMPAPP
SOME MORE DUMPAPP EXAMPLES
$ dumpapp accessToken invalidate
$ dumpapp accessToken show
fce1235425dcdeadbeef8cafebabe42
$ d...
STETHO - CUSTOM PLUGIN
http://code.tutsplus.com/tutorials/debugging-android-apps-with-facebooks-stetho--cms-24205
class Ap...
STETHO - CUSTOM PLUGIN
STETHO - DUMPAPP (EXAMPLE)
(ActivityProvider in a dependency graph in debug)
@Singleton
public class ActivityProvider impl...
STETHO - DUMPAPP (EXAMPLE)
AppDumperPlugin.java
private void displayCurrentSessionData(PrintStream writer) {
Activity acti...
$#*!,
I FORGOT THESE TOOLS!
ADB + SHELL
# Open a deep linking intent
adb shell am start -a android.intent.action.VIEW -d "scheme://app/deep/linking"
#...
POSTMAN
https://www.getpostman.com/
LOCKITO
https://play.google.com/store/apps/details?id=fr.dvilleneuve.lockito
ACCESSIBILITY SCANNER
https://play.google.com/store/apps/details?id=com.google.android.apps.accessibility.auditor
VYSOR
http://www.vysor.io
AS A CONCLUSION...
CHOOSE ACCORDING
TO YOUR NEEDS AND
TASTES
THE 2016 ANDROID
DEVELOPER TOOLBOX
(EXAMPLE OF AN)
ANDROID DEVELOPER
TOOLBOX
https://twitter.com/Nilhcem
https://github.com/Nilhcem/mobilization-2016
http://www.slideshare.net/Nilhcem/the-2016-androi...
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
Prochain SlideShare
Chargement dans…5
×

The 2016 Android Developer Toolbox [MOBILIZATION]

383 vues

Publié le

Slides for the 2016 Android Developer Toolbox talk at mobilization 2016

Publié dans : Technologie

The 2016 Android Developer Toolbox [MOBILIZATION]

  1. 1. #mobilization2016 THE 2016 ANDROID DEVELOPER TOOLBOX
  2. 2. @Nilhcem
  3. 3. #mobilization2016
  4. 4. THE 2016 ANDROID DEVELOPER TOOLBOX
  5. 5. "Use the right tools for the right job"
  6. 6. (with the Android Plugin for Gradle)
  7. 7. BUILD VARIANTS
  8. 8. U+2020 https://github.com/JakeWharton/u2020
  9. 9. DEBUG SCREEN Example from Google iosched
  10. 10. INTERNAL SETTINGS APP Similar to U+2020 Sample app Display build / device information Change endpoint (restart process with ) Show logs ( ) Allow easy bug report capturing ( ) Enable/Disable Takt / Stetho / Scalpel / Madge... JakeWharton/ProcessPhoenix pedrovgs/Lynx mattprecious/telescope
  11. 11. MOBILIZATION 2016 APPLICATION https://github.com/Nilhcem/mobilization-2016
  12. 12. MEASURING TOOLS
  13. 13. ANDROID STUDIO (Android Monitor tab)
  14. 14. DETECT MEMORY LEAKS
  15. 15. LEAK CANARY https://github.com/square/leakcanary
  16. 16. FRAME RATE build.gradle: MyApplication.java: https://github.com/wasabeef/Takt compile 'jp.wasabeef:takt:1.0.3' public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); Takt.stock(this).play(); } }
  17. 17. HUGO https://github.com/JakeWharton/hugo Prefix classes/methods with: @DebugLog Result: MobilizationApp V ⇢ onCreate() V ⇢ initGraph() V ⇠ initGraph [13ms] V ⇢ initLogger() V ⇠ initLogger [1ms] V ⇠ onCreate [73ms]
  18. 18. PIDCAT https://github.com/JakeWharton/pidcat $ pidcat com.nilhcem.mobilization
  19. 19. ANDROIDDEVMETRICS build.gradle: MyApplication.java: https://github.com/frogermcs/AndroidDevMetrics apply plugin: 'com.frogermcs.androiddevmetrics' public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); AndroidDevMetrics.initWith(this); } }
  20. 20. CODE STATIC ANALYSIS TOOLS Lint Error Prone (Google) Infer (Facebook)
  21. 21. SONARQUBE Dockerfile: FROM java:8 MAINTAINER Nilhcem RUN DEBIAN_FRONTEND=noninteractive apt update RUN DEBIAN_FRONTEND=noninteractive apt install -y wget unzip RUN wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.1.zip RUN unzip -qq sonarqube-6.1.zip -d /opt/ RUN rm sonarqube-6.1.zip EXPOSE 9000 CMD ["/opt/sonarqube-6.1/bin/linux-x86-64/sonar.sh", "console"] Then launch: $ docker build -t nilhcem/sonarqube . $ docker run -p 9000:9000 -d nilhcem/sonarqube
  22. 22. SONARQUBE GRADLE CONFIGURATION build.gradle: apply plugin: 'org.sonarqube' sonarqube { properties { def appProject = project(':app') def appProjectBuildDir = appProject.buildDir property 'sonar.projectKey', 'mobilization' property 'sonar.projectName', 'Mobilization 2016' property 'sonar.projectVersion', appProject.android.defaultConfig.versionName property 'sonar.host.url', 'http://localhost:9000' property 'sonar.sources', 'src' property 'sonar.sourceEncoding', 'UTF-8' property 'sonar.java.binaries', 'build/intermediates/classes/production/debug' property 'sonar.java.test.binaries', 'build/intermediates/classes/test/production/debug' property 'sonar.exclusions', 'src/test/java/**' property 'sonar.core.codeCoveragePlugin', 'jacoco' property 'sonar.jacoco.reportPath', "$appProjectBuildDir/jacoco/testProductionDebugUnitTest.exec" property 'sonar.junit.reportsPath', "$appProjectBuildDir/test-results/testProductionDebugUnitTest/productionDebug" } } Then launch: ./gradlew :app:assembleProductionDebug :app:testProductionDebugUnitTest :app:sonarqube
  23. 23. TESTING TOOLS
  24. 24. MOCK SERVER
  25. 25. NODEJS + EXPRESS /* Setup */ var fs = require('fs'); var express = require('express'); var app = express(); app.set('port', process.env.PORT || 8080); var port = app.get('port'); /* Speakers list */ app.get('/speakers', function(req, res) { res.type('application/json; charset=utf8'); res.status(200).send(fs.readFileSync('data/speakers.json', 'utf8')); }); /* Other web services */ // ... /* Starting the server */ app.listen(port, function () { console.log('Express server listening on port ' + port); });
  26. 26. NODEJS + EXPRESS Slow service sleep(2000); function sleep(durationMillis) { var now = new Date().getTime(); while (new Date().getTime() < now + durationMillis) { // do nothing } } // Please do not take pictures of this slide, // This is not something I am proud of
  27. 27. EXAMPLE Then, go to: https://github.com/Nilhcem/mobilization-2016 /tree/master/mockserver $ npm install $ npm start http://localhost:8990/
  28. 28. HOSTS EDITOR https://play.google.com/store/apps/details?id=com.nilhcem.hostseditor
  29. 29. HTTP DEBUGGING
  30. 30. HTTP DEBUGGING mitmproxy Fiddler Charles proxy
  31. 31. CHARLES PROXY Simulate a slow connection Repeat queries Check the responses Add some breakpoints to: Cancel an HTTP(s) call Edit a request Edit a response
  32. 32. ANDROID STATE RESTORING
  33. 33. DON'T KEEP ACTIVITIES
  34. 34. FILL RAM https://play.google.com/store/apps/details?id=com.tspoon.androidtoolbelt
  35. 35. ANDROID DEVICE MONITOR - STOP PROCESS
  36. 36. ANALYZING TOOLS
  37. 37. DEVELOPER OPTIONS
  38. 38. UIAUTOMATORVIEWER
  39. 39. ANIMATIONS Developer options -> Animation scale
  40. 40. ANIMATIONS Make a screencast (API 19+): VLC : $ adb shell screenrecord /sdcard/demo.mp4 $ adb pull /sdcard/demo.mp4 Press the keyboard 'E' key to see frames one by one
  41. 41. APKTOOL + DEX2JAR + JD-GUI http://ibotpeaches.github.io/Apktool https://github.com/pxb1988/dex2jar http://jd.benow.ca
  42. 42. JADX https://github.com/skylot/jadx
  43. 43. ANDROID STUDIO (Build > Analyze APK)
  44. 44. STETHO
  45. 45. STETHO - UI
  46. 46. STETHO - NETWORK
  47. 47. STETHO DUMPAPP
  48. 48. STETHO - DUMPAPP
  49. 49. SOME MORE DUMPAPP EXAMPLES $ dumpapp accessToken invalidate $ dumpapp accessToken show fce1235425dcdeadbeef8cafebabe42 $ dumpapp clipboard get Hello $ dumpapp clipboard set "Text to copy" $ dumpapp onTrimMemory $ dumpapp openIntent scheme://open/speaker/3 $ dumpapp gcmToken uHyMKnEQ:APA91bEHZ6afFLQQMzKgSDjp5y_0397usitPqj_Bp02 $ dumpapp geolocData Location[fused 22.5430883,114.1043205 acc=21 et=+21m5s492ms] $ dumpapp runningServices com.example.LocationService
  50. 50. STETHO - CUSTOM PLUGIN http://code.tutsplus.com/tutorials/debugging-android-apps-with-facebooks-stetho--cms-24205 class AppDumperPlugin implements DumperPlugin { @Override public String getName() { return "my_plugin_name"; } @Override public void dump(DumperContext dumpContext) throws DumpException { PrintStream writer = dumperContext.getStdout(); String commandName = (args.isEmpty()) ? "" : args.remove(0); if (commandName.equals("test")) { out.println("Hello, World!"); } } }
  51. 51. STETHO - CUSTOM PLUGIN
  52. 52. STETHO - DUMPAPP (EXAMPLE) (ActivityProvider in a dependency graph in debug) @Singleton public class ActivityProvider implements Application.ActivityLifecycleCallbacks { private Activity currentActivity; @Inject public ActivityProvider(Application app) { app.registerActivityLifecycleCallbacks(this); } public Activity getCurrentActivity() { return currentActivity; } @Override public void onActivityResumed(Activity activity) { currentActivity = activity; } @Override public void onActivityPaused(Activity activity) { currentActivity = null; } }
  53. 53. STETHO - DUMPAPP (EXAMPLE) AppDumperPlugin.java private void displayCurrentSessionData(PrintStream writer) { Activity activity = activityProvider.getCurrentActivity(); if (activity instanceof SessionDetailsActivity) { try { // Use reflection to access private "session" field Field field = SessionDetailsActivity.class.getDeclaredField("session"); field.setAccessible(true); Session session = (Session) field.get(activity); writer.println(new GsonBuilder().setPrettyPrinting().create().toJson(session)); } catch (Exception e) { writer.println(e.getMessage()); } } }
  54. 54. $#*!, I FORGOT THESE TOOLS!
  55. 55. ADB + SHELL # Open a deep linking intent adb shell am start -a android.intent.action.VIEW -d "scheme://app/deep/linking" # List running services adb shell dumpsys activity services # Get the path of an install application adb shell pm path app.package.name # Clear app data adb shell pm clean app.package.name # Take a screenshot adb shell screencap -p | perl -pe '''s/x0Dx0A/x0A/g''' > screen.png # Paste text from your computer clipboard to your android device pbpaste | sed "s/%/%%/g" | sed "s/ /%s/g" | xargs adb shell input text
  56. 56. POSTMAN https://www.getpostman.com/
  57. 57. LOCKITO https://play.google.com/store/apps/details?id=fr.dvilleneuve.lockito
  58. 58. ACCESSIBILITY SCANNER https://play.google.com/store/apps/details?id=com.google.android.apps.accessibility.auditor
  59. 59. VYSOR http://www.vysor.io
  60. 60. AS A CONCLUSION...
  61. 61. CHOOSE ACCORDING TO YOUR NEEDS AND TASTES
  62. 62. THE 2016 ANDROID DEVELOPER TOOLBOX
  63. 63. (EXAMPLE OF AN) ANDROID DEVELOPER TOOLBOX
  64. 64. https://twitter.com/Nilhcem https://github.com/Nilhcem/mobilization-2016 http://www.slideshare.net/Nilhcem/the-2016-android-developer-toolbox-mobilization MASTER YOUR TOOLS TO BUILD BETTER APPS

×