Skip to content

Latest commit

 

History

History
157 lines (94 loc) · 6.17 KB

android.md

File metadata and controls

157 lines (94 loc) · 6.17 KB

Android

  1. Platform Versions
  2. Development Tools
  3. User Interface
  4. Coding Conventions
  5. Best Practices
  6. .gitignore
  7. Test-Driven Development
  8. Preferred Libraries And Frameworks
  9. Location
  10. Dependency Management
  11. Project Environments
  12. Release Key
  13. Graphic Assets
  14. ProGuard
  15. Useful Links

Platform Versions

Min SDK Version

Support Android OS versions starting from 4.0 (Ice Cream Sandwich, API Level 14). Do not support older versions (2.2 Froyo, 2.3 Gingerbread, 3.x Honeycomb etc).

Target SDK Version

For new projects, use latest stable version of Android API (6.0.0 Marshmallow, API Level 23). Do not use beta versions or developer previews (e.g. API Level 20).

Development Tools

JDK

Use Java Development Kit (JDK) version 7.

IDE

Use latest stable Android Studio. Migrate old projects from Eclipse and IntelliJ IDEA.

Coding Conventions

Follow MLSDev Android Coding Conventions.

Use Android Studio for auto formatting.

Best Practices

  • Avoid anonymous classes usage
  • Use ContentProviders
  • Use SyncAdapters (more info here and here)
  • Prefer Services for long-running background tasks
  • Understand the difference between Loader and AsyncTask
  • Use Analyse->Inspect Code in Android Studio for static analysis of project code and XML at the end of each development cycle (Iteration, Spring, Milestone etc)

User Interface

Follow Android Design Principles, particularly the Style Guide.

Useful links:

.gitignore

Use IDE for default .gitignore file generation. Do not forget about OS temporary files (.DS_Store in Mac OS, Thumbs.db in Windows etc).

Test-Driven Development

Preferred Libraries And Frameworks

  • Use latest stable Retrofit to access RESTful web services
  • OkHttp for more flexible networking (for example, when the API is not RESTful)
  • GSON for JSON serialization and parsing
  • Glide or Picasso for image downloading, caching and displaying
  • Crashlytics for crash logs
  • Dagger 2 for Dependency Injection
  • RxJava for asynchronous programming
  • Java classes generator by JSON scheme or JSON example. Compatible with Gson and Jackson

Location

Prefer Google Play Services to LocationManager. More info can be found in this blog post.

Dependency Management

Never add third-party source code or libraries to project repository. Use Gradle and Maven.

Project Environments

Project should contains at least 2 Gradle tasks: Release and Debug.

Release task should include:

  • release build signing (see Release Key section)
  • positive Crashlytics flag
  • configuration for the stable API version

Debug task should include:

  • debug build signing
  • negative Crashlytics flag
  • configuration for the development (staging) API version

Release Key

  • Release key file can be stored in project tracker (JIRA, Redmine etc), password can be on Wiki page or some other private/secured place.
  • Generating Release key. Main information needed from client - company name and location.
  • Info on Jenkins setup

Graphic Assets

  • Require graphic designers to provide assets in all sizes (mdpi, hdpi, xhdpi, xxhdpi etc).
  • Prefer 9patch graphics.

More info: MLSDev Design Requirements

ProGuard

  • Use Proguard tool for improving security of your application. Proguard obfuscates your code by renaming classes, fields, and methods with semantically distorted names. The result apk file is more difficult to reverse engineer. It's important to use Proguard when your application should hide authorization protocol (e.g. client_id and client_secret of OAuth).
  • Proguard tool shrinks and optimize your code which can help you remain within 65k methods.

Warning

When working with legacy code it's important to know is ProGuard enabled or not. While you are making changes you should add appropriate rules into configuration file.

Warning

Whenever ProGuard runs, it outputs a mapping.txt file, which shows you the original class, method, and field names mapped to their obfuscated names. You must keep mapping.txt file for every release build, otherwise you will be unable to read stack trace of crash reports.

Useful Links