Skip to content

olegoaer/Green-Android-Lint

Repository files navigation

Here is an extension for Android Studio to help writing greener code. I wrote it in 2019 and now make it publicly available. It implements 12 checks and some quick fix thereof, based on a fast-evolving catalog of android-specific energy code smells (expressed in Java but works for Kotlin).

This proof of concept has evolved into ecoCode Mobile, based on SonarQube. Feel free to take a look at this new exciting project 🔥

💾 Installation

  • Download greenchecks.jar (tested for Android Lint version 26.3.2)
  • Move the file into your ~/.android/lint directory. Create it if needed
  • Restart Android Studio

🔍 Inspections

  • Open any Android project
  • Select Analyse>Inspect code from the top menu
  • Select your app Module only
  • Focus on the new Greenness category reporting

alt text

✍️ Contribute

In 2019 I waded in the undocumented waters of the Android Lint API but since 2021, there exist a documentation: http://googlesamples.github.io/android-custom-lint-rules/api-guide.html

For more information about recent changes in Android Lint and how to write custom Lint rules, please see the following links:

🔗 How to cite this work?

@inproceedings{legoaer:hal-03252141,
  TITLE = {{Enforcing Green Code with Android Lint}},
  AUTHOR = {Le Goaer, Olivier},
  BOOKTITLE = {{ASEW '20: 35th IEEE/ACM International Conference on Automated Software Engineering Workshops}},
  ADDRESS = {Melbourne, Australia},
  PUBLISHER = {{ACM}},
  PAGES = {85-90},
  YEAR = {2021},
  MONTH = Sep,
  DOI = {10.1145/3417113.3422188},
  KEYWORDS = {green ; battery ; energy ; bugs ; lint ; smells ; Android},
}