Acra

25
1 ZID Sonia – 26/12/2013 Application Crash Report for Android

description

Présentation élaborée par Mlle. Sonia dans le cadre des sessions de Lightning Talks à l'Orange Developer Center.

Transcript of Acra

Page 1: Acra

1ZID Sonia – 26/12/2013

Application Crash Report for Android

Page 2: Acra

2

Plan de présentation

● Oui il vous faut un outil de rapports d'erreur● ACRA : Application crash reports for Android● Top applications qui utilisent ACRA● Simple à intégrer● Les solutions de stockage et analyse● Acralyser

Page 3: Acra

3

Oui il vous faut un outil de rapport d'erreur

● Votre application va planter. C'est sûr, oui je suis sûr.

● Vos tests se sont jamais suffisants

● Vous ne pourrez jamais tester sur TOUS les devices et versions d'Android.

Page 4: Acra

4

Oui il vous faut un outil de rapport d'erreur

Connaitre les défauts au plus tot pour les corriger au plus vite

N'est ce pas !

Page 5: Acra

5

Oui il vous faut un outil de rapport d'erreur

Oui mais Google fournit déjà des rapports d'erreur !

MAIS...● Les données sont limités● Dépendant du Play Store● Et pour les applications d'entreprise ?

Page 6: Acra

6

Application Crash Report for Android

Idée initiale● Tout développeur devrait recevoir des rapports

d'erreur

● Impact minimal sur l'application

● Utilisation de Google Docs pour les rapports d'erreur.

Page 7: Acra

7

Application Crash Report for Android

Principe : UncaughtExceptionHandler

→ appelé par toute exception non intercepté

Installation : ajout d'une simple annotation sur l'instance Application Principale

Compatibilité : avec toutes versions d'Android mais sait collecter des données avec les API les plus récents.

Page 8: Acra

8

Application Crash Report for Android● Interaction utilisateur

- Toast, Notification, Dialog, rapports silencieux

● Rapports très détaillés sur le crash, le device avec lequel l'application s'est arrété,...

● On peut ajouter nos propres traces de débogage pour les rapports.

● S'il y a pas de couverture réseau, les rapports sont conservés et envoyés plus tard.

● On peut envoyer des rapports meme si l'application ne plante pas.

Page 9: Acra

9

Top applications qui utilisent ACRA

Page 10: Acra

10

Simple à intégrer

Crash Reports in a Google Docs spreadsheet● Get http://acra.googlecode.com/files/acra-3.1.2.2.zip and open the

archive● Login to your Google Docs account● Import the CrashReports-template.csv contained in the archive (acra-

3.1.2.2/CrashReport/doc), with conversion enabled● Open the imported document● Rename it as you like● In the menu, click on Forms / Create form● Add anything in the form description just to enable the Save button● If you are using a private Google Apps domain, make sure to uncheck

the option "Require yourdomain.com sign-in to view this form."

Page 11: Acra

11

Simple à intégrer

● Save the form● Copy the formkey displayed in the link at the bottom of the form

creation page● Open your Eclipse project● Create a lib folder● Add the acra-3.1.2.2.jar from the archive (acra-

3.1.2.2/CrashReport/build) in the lib folder● Right-click on the jar file / add to build path● Create a new class in your package root● Give it a name like: MyApplication, make it extend

android.app.Application● Above the declaration of the MyApplication class, add the

@ReportsCrashes annotation with your Google Docs form Id as a parameter

Page 12: Acra

12

Simple à intégrer

package com.example.test

import org.acra.ACRA;import org.acra.ReportField;import org.acra.ReportingInteractionMode;import org.acra.annotation.ReportsCrashes;

import android.app.Application;

@ReportsCrashes (formKey = "dGVacG0ydVHnaNHjRjVTUTEtb3FPWGc6MQ",, customReportContent = {ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME,ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL,ReportField.CUSTOM_DATA, ReportField.STACK_TRACE }, mode = ReportingInteractionMode.TOAST,resToastText = R.string.crash_toast_text)

public class MyApplication extends Application {

@Overridepublic void onCreate() {// TODO Auto-generated method stubsuper.onCreate();ACRA.init(this);}

}

Page 13: Acra

13

Simple à intégrer● APP_VERSION_CODE=1● APP_VERSION_NAME=1.0● ANDROID_VERSION=4.4.2● PHONE_MODEL=Nexus 4● CUSTOM_DATA=● STACK_TRACE=java.lang.NumberFormatException: Invalid int: ""● at java.lang.Integer.invalidInt(Integer.java:137)● at java.lang.Integer.parseInt(Integer.java:358)● at java.lang.Integer.parseInt(Integer.java:331)● at

com.exemple.test.activity.ListAudioGuideExpositionActivity$23.onClick(ListAudioGuideExpositionActivity.java:578)

● at android.view.View.performClick(View.java:4438)● at android.view.View$PerformClick.run(View.java:18422)● at android.os.Handler.handleCallback(Handler.java:733)● at android.os.Handler.dispatchMessage(Handler.java:95)● at android.os.Looper.loop(Looper.java:136)● at android.app.ActivityThread.main(ActivityThread.java:5017)● at java.lang.reflect.Method.invokeNative(Native Method)● at java.lang.reflect.Method.invoke(Method.java:515)● at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)● at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)● at dalvik.system.NativeStart.main(Native Method)

mode = ReportingInteractionMode.TOAST

Page 14: Acra

14

Simple à intégrer

@ReportsCrashes(formKey="dGVacG0ydVHnaNHjRjVTUTEtb3FPWGc6MQ,mode = ReportingInteractionMode.Notification,resToastText = R.string.crash_toast_text)public class MyApplication extends Application {...

Page 15: Acra

15

Les solutions de stockage et analyse

Google Docs Forms● Pratique pour démarrer● Interface pas vraiment adaptée● Google a demandé l'arret de la soumission

des données via Forms.

Déconseillée

Page 16: Acra

16

Les solutions de stockage et analyse

Solutions commerciales/propriétaires

Page 17: Acra

17

Les solutions de stockage et analyse

Solutions commerciales/propriétaires

● Avantage

Interfaces soignées● Inconvénients

Peu de données

Persistance des données limités dans le temps

Tarification

SAAS → Les données sont chez un tiers et y resteront

Page 18: Acra

18

Les solutions de stockage et analyse

Autre solutions

● Un Script PHP de 10 lignes peut etre suffisant● Sentry - Python + MySQL/PgSQL

solutions installable sur votre infra

proposent un hébergement payant● Acralyzer

Page 19: Acra

19

Acralyser

Nouveau backend officiel pour ACRA

Pallier au retrait de la solution Google Forms● Création / suppression de rapports● Visualisation de TOUTES les données● Tri/Recherche

Solution FULL opensource● Pas de dépendance vis à vis d'un service● Facile à déployer "chez soi"

Robuste et Scalable

Page 20: Acra

20

Acralyser

Installation :

1 - réplication de 2 couchapps● http://get.acralyzer.com/distrib-acra-storage● http://get.acralyzer.com/distrib-acralyzer

2 - Création d'un utilisateur reporter● Depuis l'interface d'Acralyzer

3 - Configuration d'ACRA

Page 21: Acra

21

Acralyser

Fonctionnalités implémentées

- Dashboard:● rapports par mois/jour/heure/seconde● rapports par version Android/API/Applicative● rapports par device

- 10 derniers bugs et rapports :● version applicative● exception + classe / ligne● root exception + classe / ligne

Page 22: Acra

22

Acralyser

Fonctionnalités implémentées

- Bugs :● Etat résolu ou non● Champ commentaires● Liste des rapports● Liste des utilisateurs impactés

- Rapports :● Filtre par version application ou Android● Recherche textuelle

Page 23: Acra

23

Acralyser

Page 24: Acra

24

Références

● https://code.google.com/p/acra/wiki/ACRA3HowTo

● https://github.com/ACRA/acra

● https://plus.google.com/+Acralyzer/posts

● https://github.com/ACRA/acra/wiki/AdvancedUsage#contents

Page 25: Acra

25

Merci de votre attention