Más contenido relacionado Más de ZeroTurnaround (20) RebelLabs Android Report 2015: the platform, the best development practices, the tooling1. All rights reserved. 2015 © ZeroTurnaround Inc.
THE OS THAT POWERS 10^10 DEVICES
AND A SOFTWARE DEVELOPMENT PLATFORM!
ANDROID: THE PLATFORM,
THE FRAMEWORK, AND THE
WAY OF LIFE
As long as you’re close
to a power outlet
2. All rights reserved. 2015 © ZeroTurnaround Inc.
PREFACE
PART 1: THE ANDROID ECOSYSTEM
Where do we begin?
PART 2 : APPLICATION DESIGN AND ARCHITECTURE
Proper Code Patterns
Parallelization model
PART 3: PROPER INFRASTRUCTURE
Testing Android Applications
Proper Tooling for Android Development
Static Code Analysis Tools
SUMMARY: FINAL WORDS & COMIC
TABLE OF CONTENTS
Live Android Development
REPORT SPONSORED BY:
1
4
5
13
14
28
33
34
38
47
51
3. All rights reserved. 2015 © ZeroTurnaround Inc.
Deciding which versions you need to support is of course an important
business decision. Every device you decide not to support is a potential
revenue loss for your business. More importantly, baking in the
compatibility with older devices at a later time takes much more work than
supporting them from day one. This convenient Google dashboard shows
that around 60% of devices run Android 4.4 or newer. These are all
fairly recent versions that have support for the ART runtime and a
number of other important features.
You can find the supported functionality changelog over at
android.developer.com. This will help you decide if you want to target
the early adopters or the slower updating masses.
The next thing to think about is what kind of devices you want to target.
The range of big-kid-toys that support Android is growing every month:
phones, tablets, watches, cars, TV, toys, even fridges. Soon anything with
a microchip will feature some sort of Android support, maybe even you!
While supporting the latest trends in hardware can make your application
look hip, it requires heavy lifting on the development side.
For example, you need to approach the app design differently. The UX (user
experience) will drive the UI (user interface) which in turn will drive the
code and the architecture for your project. You will have to test your code
on additional platforms, exploding the test-matrices and your continuous
integration environments. You truly need to consider whether you need this
complexity in your project — before you start writing your code.
4. All rights reserved. 2015 © ZeroTurnaround Inc.
The Activity or Fragment sends Actions to the central Dispatcher. This will in turn redirect the Action to the right Store
and process it (Stores are in charge of keeping the state of a given domain concept). In some cases, this might trigger
other Actions in the shape of changes — that will cause the View to get updated.
5. All rights reserved. 2015 © ZeroTurnaround Inc.
Application Activity Service Contentprovider BroadcastReceiver
Show a Dialog
Start an Activity
Layout Inflation
Start a Service
Bind to a Service
Send a Broadcast
Register BroadcastReceiver
Load Resource Values
1 1
2 2
1
2
1
2
3
While we are talking about references to activities, let’s take a look at contexts.
Did you leave room for a final tattoo? If you did, this is a great candidate to fill that spot,
from a Contexts blog post by Dave Smith:
1. An application CAN start an Activity from here, but it requires that a new task be created. This may fit specific use cases, but can create non-standard back stack
behaviors in your application and is generally not recommended or considered good practice.
2. This is legal, but inflation will be done with the default theme for the system on which you are running, not what’s defined in your application.
3. Allowed if the receiver is null, which is used for obtaining the current value of a sticky broadcast, on Android 4.2 and above.
6. All rights reserved. 2015 © ZeroTurnaround Inc.
The build tool is pretty much the most used tool for any project
on any platform, perhaps closely following the IDE. Without it,
your code is just a bunch of files wondering how they can make a
difference. I am sure you have used Maven before and you clearly
realize the importance of a high quality build tool for your project.
You also realize that your project should use state-of-the-art tools
available on the market, as long as they provide value to you.
7. All rights reserved. 2015 © ZeroTurnaround Inc.
Another magnificent productivity enhancement that you should
try is JRebel for Android. Yep, this one has been developed by the
super-human brains at ZeroTurnaround!
8. All rights reserved. 2015 © ZeroTurnaround Inc.
Genymotion emulator
Another way to speed up your development process is to change
the target runtime of your application. Most Android developers
run their application on real, physical devices rather than using an
emulator. This is done because the emulator can be intolerably
slow. While it is slower than usual runtime, the real pain comes
from the startup time — which is as slow as an asthmatic sloth.
9. All rights reserved. 2015 © ZeroTurnaround Inc.
Android Studio is based on the Intellij IDEA Community edition,
the fully open source IDE that powers the famous Intellij IDEA
Ultimate Edition IDE by JetBrains.
The IDE is your command center, your fighter jet cockpit, your
ninja training facility. You get it, it is important. Hopefully you are
using Android Studio already. If you have a Java background and
used Eclipse rather than IDEA you might find the migration to
Android Studio problematic.
However, we have published a great report on migrating from
Eclipse to Intellij IDEA, which highlights the concepts that IDEA
and Android Studio use. The report helps you to navigate the
important menus, preferences, plugins and so on.
IDEs like any software tend to improve and get better, faster, and
more intelligent. So keep updating yours, learn the shortcuts and
productivity tips, stay alert for the new cool plugins that might
simplify your life.
10. All rights reserved. 2015 © ZeroTurnaround Inc.
The Android Lint team describe their tool on their website as “a static code
analysis tool that checks your Android project source files for potential bugs
and optimization improvements for correctness, security, performance,
usability, accessibility, and internationalization.”
Android Lint is a default package in the Android SDK. This means that you
do not have to install any additional components to your workstation to
make use of it.
Lint is configured with a small XML file, allowing you to customize
parameters like the severity levels for each type of the problem and
much more.
To run the Lint checks on the project, navigate to the project home directory
and run the lint command. This will find issues in many different aspects of
code quality, including correctness, usability, performance, accessibility and
obsolete dependencies.
Android Lint
12. All rights reserved. 2015 © ZeroTurnaround Inc.
Report Authors:
Isra Boza Rodriguez (@IsraKaos), Oleg Shelajev (@shelajev)
Report Contributors:
Simon Maple (@sjmaple), Mart Redi (@martredi)
Report Designer: Ladislava Bohacova(@ladislava)
Contact us
Estonia
Ülikooli 2, 4th floor
Tartu, Estonia, 51003
Phone: +372 653 6099
Twitter: @RebelLabs
Web: http://zeroturnaround.com/rebellabs
Email: labs@zeroturnaround.com
USA
399 Boylston Street,
Suite 300, Boston,
MA, USA, 02116
Phone: 1 (857) 277-1199
Czech Republic
Jankovcova 1037/49
Building C, 5th floor,
170 00 Prague 7, Czech Republic
Phone: +420 227 020 130