droidconuk 2013 : beef up android apps with java tools

36
USING JAVA TOOLS BEEF UP ANDROID APPS Stéphane Nicolas & Jérôme Van Der Linden

Upload: jeromevdl

Post on 06-May-2015

413 views

Category:

Technology


0 download

DESCRIPTION

Our presentation at Droidcon London 2013 : Beef up Android Apps with Java Tools : how to take advantage of 17 years of experience in Java for Android.

TRANSCRIPT

Page 1: DroidconUK 2013 : Beef up android apps with java tools

USING JAVA TOOLS�BEEF UP ANDROID APPS�

Stéphane Nicolas & Jérôme Van Der Linden

Page 2: DroidconUK 2013 : Beef up android apps with java tools

Jerome Van Der Linden�

android-­‐holo-­‐colors.com  

2  

@jeromevdl   +jerome  van  der  linden  jeromevdl  

Page 3: DroidconUK 2013 : Beef up android apps with java tools

Stéphane Nicolas�

BoundBox  

And  others  :  RoboDemo,  Quality  Analysis  Tools  for  Android,  android-­‐maven-­‐plugin,  …  

3  

+stephane  nicolas  snicolas  stephanenicolas  

Page 4: DroidconUK 2013 : Beef up android apps with java tools

4  

Page 5: DroidconUK 2013 : Beef up android apps with java tools

JAVA ENVIRONMENT�

ONCE UPON A TIME �15  

Page 6: DroidconUK 2013 : Beef up android apps with java tools

6  

4  

Page 7: DroidconUK 2013 : Beef up android apps with java tools

Everything is testable ��

Everything is measurable ��

Everything is integrated���

No excuses to have poor apps ! �

7  

Page 8: DroidconUK 2013 : Beef up android apps with java tools

Great ! �

8  

Page 9: DroidconUK 2013 : Beef up android apps with java tools

And me ?! �

9  

Page 10: DroidconUK 2013 : Beef up android apps with java tools

2 WTF ?! �

ANDROID IS JAVA ! �

10  

Page 11: DroidconUK 2013 : Beef up android apps with java tools

Almost YES… �

… a story of �Virtual Machine �

So what … ?�

11  

Page 12: DroidconUK 2013 : Beef up android apps with java tools

12  

3  

Page 13: DroidconUK 2013 : Beef up android apps with java tools

Oh Yeah ! �

Page 14: DroidconUK 2013 : Beef up android apps with java tools

(almost) Everything is testable ��

(almost) Everything is measurable ��

BUT��

Everything is NOT integrated������

14  

Page 15: DroidconUK 2013 : Beef up android apps with java tools

Quality Tools for Android��

http://goo.gl/zGFvda�

15  

Page 16: DroidconUK 2013 : Beef up android apps with java tools

3 Quality Tools Android �

Ant�

16  

Page 17: DroidconUK 2013 : Beef up android apps with java tools
Page 18: DroidconUK 2013 : Beef up android apps with java tools

4 Quality Tools Android �

Maven �

18  

Page 19: DroidconUK 2013 : Beef up android apps with java tools

<plugin> ! <groupId>com.jayway.maven.plugins.android.generation2</groupId>"! <artifactId>android-maven-plugin</artifactId> ! <version>3.6.1</version> !</plugin> !

The magical� plugin�

19  

Page 20: DroidconUK 2013 : Beef up android apps with java tools

The ultimate � profile �

# run junit, robotium, robolectric tests and get code coverage!> mvn clean install –P jacoco!

20  

Page 21: DroidconUK 2013 : Beef up android apps with java tools

Maven Profiles

Junit  +  Robo,um Robolectric UIAutomator Code  

coverage

Quality  checks  

(Checkstyle  +  findbugs  +  PMD  +  lint)

Sonar

standard

emma

cobertura

ui  automator

spoon

jacoco

21  

x2  

Page 22: DroidconUK 2013 : Beef up android apps with java tools

22  

hOps://github.com/SonarCommunity/sonar-­‐android  

# analyse code (pmd, checkstyle, findbugs, lint) and report in sonar !> mvn sonar:sonar –P jacoco!

Android Lint �Sonar plugin�

Page 23: DroidconUK 2013 : Beef up android apps with java tools

Not an archetype �(see akquinet : http://goo.gl/O46LIw) �

�Only samples �

�Do not use everything ! �

�Pick up what you need ! �

23  

Page 24: DroidconUK 2013 : Beef up android apps with java tools

Return of �real life experience �

Maven  Jenkins  Sonar  (PMD,  checkstyle,  findbugs,  lint)  Junit  (Instrumenta[onTestCase)  

~  100  screens  (phone  +  tablet)  ~  5  developers  during  only  5  months  ~  60k  loc  (java),  15k  loc  (xml)  ~  400  unit  tests  :  not  an  excep[onal  coverage  (~  30%)  Built  on  each  commit  on  Jenkins  +  Genymo[on  0  lint,  pmd,  findbugs,  checkstyle  viola[ons  1  sonar  report  generated  each  night  with  those  metrics    è  An  happy  customer  J  

24  

Page 25: DroidconUK 2013 : Beef up android apps with java tools

A  laborious  development  environment  :  eclipse  +  maven  +  m2eclipse  +  android  m2e  connector  è Many  hours  lost  è  Use  IntelliJ  !    

A  laborious  execu[on  environment  :  emulator  è  Too  slow  è  Use  Genymo[on  (or  at  least  a  device)  !    Not  enough  tests  :  è Instrumenta[onTestCase  are  too  heavy/slow  for  Unit  Tes[ng    è Use  Robolectric  and/or  think  about  MV*  paOern  è  Keep  Instrumenta[onTestCase  for  Android  specific  (Ac[vity,  Services,  …)    

Lessons � learned�

25  

Page 26: DroidconUK 2013 : Beef up android apps with java tools

A  robust  development  environment  :  eclipse  +  maven  +  m2eclipse  +  android  m2e  connector  è  s[ll  some  problem  with  eclipse  and  maven  integra[on    About  tests  è Instrumenta[onTestCase  are  fast  enough  with  GenyMo[on  è  Robolectric  can’t  give  you  enough  confidence      

Lessons � learned�

26  

Page 27: DroidconUK 2013 : Beef up android apps with java tools

5 Quality Tools Android �

Gradle �

27  

Page 28: DroidconUK 2013 : Beef up android apps with java tools

Lint ��

UIAutomator��

Monkey & Monkey Runner ��

Robolectric ��

PMD, checkstyle, findbugs ��

Emma, Cobertura, Jacoco �

28  

Before    V  0.6  

Page 29: DroidconUK 2013 : Beef up android apps with java tools

Joke ?! �

Page 30: DroidconUK 2013 : Beef up android apps with java tools

Lint ��

UIAutomator��

Monkey & Monkey Runner ��

Robolectric ��

PMD, checkstyle, findbugs ��

Emma, Cobertura, Jacoco �

30  

V  0.6.+  

Page 31: DroidconUK 2013 : Beef up android apps with java tools

31  

Quality �the gradle way�# run junit, robotium, robolectric tests !# AND Chekstyle + PMD + Findbugs + Classycle !> gradle check!# report in sonar !> gradle sonarRunner!

Page 32: DroidconUK 2013 : Beef up android apps with java tools

6 Conclusion�

Android is filling the gap�

32  

Page 33: DroidconUK 2013 : Beef up android apps with java tools

33  

Feature Gradle Maven

Application Variants & Manifest merging ?

Standard  tests  &  Robo,um

Code  Coverage  

Robolectric

UI  automator  /  Monkey  /  Monkey  Runner

PMD  /  CheckStyle  /  FindBgugs  /  Classycle  /  Lint

Sonar  &  Project  Sites

Gradle0.6.1 VS Maven3.6.1�

Page 34: DroidconUK 2013 : Beef up android apps with java tools

34  Android offers ��

lots of quality tools ��

lots of testing methods ��

rapid testing��

Everything gets easier to use�

�Build rock solid apps �

Page 35: DroidconUK 2013 : Beef up android apps with java tools

Thank You ! �

Any Question ?� Stéphane Nicolas & Jérôme Van Der Linden

35  

@jeromevdl   +jerome  van  der  linden  jeromevdl  

+stephane  nicolas  snicolas  stephanenicolas  

Page 36: DroidconUK 2013 : Beef up android apps with java tools

Quality Tools for Android��

http://goo.gl/zGFvda�

36