With the growing reliance on smartphones, optimizing the energy efficiency of mobile applications has become increasingly important due to the limited capacity of device batteries. Android, being the dominant mobile operating system, is particularly prone to energy inefficiencies caused by improper handling of power-intensive components.This paper introduces a machine learning-driven approach to identify energy inefficiencies in Android apps, with a focus on wake lock mismanagement and improper resource handling. The model is trained on a dataset composed of static features extracted from APKs, which reflect behavioral indicators such as the invocation of power-sensitive APIs, access to permissions, and usage of application components.
Since direct energy leak annotations are not typically available in such datasets, proxy labels were applied based on observable behavior patterns, categorizing applications into Normal, Wake Lock Leak, and Resource Leak classes. To improve model performance on imbalanced data, the Synthetic Minority Oversampling Technique (SMOTE) was used. A Light Gradient Boosting Machine (LightGBM) classifier was trained and fine-tuned using RandomizedSearchCV, achieving a classification accuracy of 99%. The results indicate strong generalization and high performance across all categories, demonstrating the effectiveness of the proposed approach in identifying energy-related issues in Android apps.
Introduction
Android dominates the global smartphone market with over 70% usage, supported by its open-source architecture and broad app ecosystem. Despite advances in app functionality, energy efficiency remains a neglected aspect, leading to battery drain issues. This is largely due to Android’s complex, event-driven app lifecycle, which can cause developers to mismanage system resources like wake locks and sensors, resulting in energy leaks.
A study of popular apps revealed widespread energy inefficiencies, with many users complaining about battery drain despite good app ratings. The main causes of energy inefficiency are wake lock mismanagement—where apps keep the CPU awake unnecessarily—and resource leaks from failing to release resources like GPS or file handles. These issues stem from poor coding practices ("code smells") and the challenge of handling Android’s asynchronous events.
Research efforts have focused on detecting these leaks using static analysis (examining app code) and dynamic analysis (monitoring app behavior during runtime), with hybrid and machine learning approaches emerging to improve detection accuracy. Several tools and frameworks have been developed to identify energy bugs and suggest fixes.
The text proposes a machine learning method using static features from Android APKs to detect energy leaks. It uses a proxy dataset originally for malware detection, leveraging overlapping behaviors linked to energy inefficiencies. The workflow involves proxy labeling, data preprocessing, addressing class imbalance with SMOTE, training a LightGBM classifier, and deploying the model via a web interface. This system aids developers in identifying wake lock and resource leaks to improve app energy efficiency.
Conclusion
We present a machine learning-based framework for detecting energy inefficiencies—specifically, wake lock leaks and resource leaks—in Android applications using a proxy-labeled dataset derived from static analysis of malware samples. The dataset comprises key indicators such as API calls, permission requests, and component usage patterns associated with power consumption behavior. Proxy labels were heuristically assigned based on known energy misuse patterns to facilitate supervised learning in the absence of ground truth annotations. Leveraging LightGBM, tuned via RandomizedSearchCV and enhanced with SMOTE to address class imbalance, the proposed model achieved a classification accuracy of 99%. It effectively distinguishes between Normal, Wake Lock Leak, and Resource Leak classes, offering actionable insights into energy-related issues in mobile applications. A Flask-based web interface was developed to ensure accessibility and ease of integration into development workflows. This tool empowers developers to proactively detect and mitigate energy inefficiencies during the software development lifecycle, contributing to improved battery performance and user experience. Future work may include expanding the feature set, incorporating real-time behavioral analysis, and detecting code smells that contribute to energy leaks.
References
[1] Pathak, A., Jindal, A., Hu, Y. C., & Midkiff, S. P. (2012). What is keeping my phone awake?: Characterizing and detecting no-sleep energy bugs in smartphone apps. In Proceedings of the 10th International Conference on Mobile Systems, Applications, and Services (MobiSys \'12), Lake District, UK. ACM. https://dl.acm.org/doi/10.1145/2307636.2307661
[2] Liu, Y., Xu, C., Cheung, S. C., & Terragni, V. (2016). Understanding and detecting wake lock misuses for Android applications. In Proceedings of the 2016 ACM SIGPLAN International Conference on Software Language Engineering (SLE \'16). ACM. https://dl.acm.org/doi/10.1145/2950290.2950297
[3] Wang, J., Liu, Y., Xu, C., Ma, X., & Lu, J. (2016). E-GreenDroid: Effective energy inefficiency analysis for Android applications. In Proceedings of Internetware \'16, Beijing, China. ACM. https://dl.acm.org/doi/10.1145/2993717.2993720
[4] Liu, Y., Wang, J., Xu, C., & Ma, X. (2017). NavyDroid: Detecting energy inefficiency problems for smartphone applications. In Proceedings of Internetware 2017, Shanghai, China. ACM.https://dl.acm.org/doi/10.1145/3131704.3131705
[5] Xu, Z., Wen, C., & Qin, S. (2018). State-taint analysis for detecting resource bugs. Science of Computer Programming, 162, 93-109. Elsevier. https://doi.org/10.1016/j.scico.2017.06.010
[6] Zhu, C., Zhu, Z., Xie, Y., Jiang, W., & Zhang, G. (2019). Evaluation of machine learning approaches for Android energy bug detection with revision commits. IEEE Access, 7, 85241–85252. https://doi.org/10.1109/ACCESS.2019.2924953
[7] Khan, M. U., Lee, S. U., Abbas, S., Abbas, A., & Bashir, A. K. (2021). Detecting wake lock leaks in Android apps using machine learning. IEEE Access, 9. https://doi.org/10.1109/ACCESS.2021.3110244
[8] Banerjee, A., & Roychoudhury, A. (2015). EnergyPatch: Repairing resource leaks to improve energy efficiency of Android apps. In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering (FSE), 37-49. https://doi.org/10.1145/2786805.2786827
[9] Palomba, F., Di Nucci, D., Panichella, A., Zaidman, A., & De Lucia, A. (2019). On the impact of code smells on the energy consumption of mobile applications. Information & Software Technology, 105(105), 43–55.https://doi.org/10.1016/J.INFSOF.2018.08.004.
[10] Wu, T., Liu, J., Xu, Z., Guo, C., Zhang, Y., Yan, J., & Zhang, J. (2016). Light-weight, inter-procedural, and callback-aware resource leak detection for Android apps. IEEE Transactions on Software Engineering. https://doi.org/10.1109/TSE.2016.2547385
[11] Arnatovich, Y. L., Wang, L., Ngo, N. M., & Soh, C. (2018). A comparison of Android reverse engineering tools via program behaviors validation based on intermediate languages transformation. IEEE Access, 6. https://doi.org/10.1109/ACCESS.2018.2808340
[12] Abbasi, A. M., Al-Tekreeti, M., Naik, K., Nayak, A., Srivastava, P., & Zaman, M. (2018). Characterization and detection of tail energy bugs in smartphones. IEEE Access, 6. https://doi.org/10.1109/ACCESS.2018.2877395
[13] Jiang, H., Yang, H., Qin, S., Su, Z., Zhang, J., & Yan, J. (2017). Detecting energy bugs in Android apps using static analysis. In Proceedings of the IEEE International Conference. https://doi.org/10.1007/978-3-319-68690-5_12
[14] Pereira, R. B., Ferreira, J. F., Mendes, A., & Abreu, R. (2022). Extending EcoAndroid with Automated Detection of Resource Leaks. International Conference on Mobile Software Engineering and Systems, 17–27. https://doi.org/10.1145/3524613.3527815
[15] Campelo, F. P., Sousa, M. C. B. de O., & Nascimento, C. L. (2023). E-APK: Energy pattern detection in decompiled android applications. Journal of Computer Languages, 76, 101220. https://doi.org/10.1016/j.cola.2023.101220
[16] Khan, M. U., Abbas, S., Lee, S. U.-J., & Abbas, A. (2020). Energy-leaks in Android application development: Perspective and challenges. Journal of Theoretical and Applied Information Technology, 98(22), 2005–ongoing.
[17] Liu, Y., Xu, C., Cheung, S.-C., & Lu, J. (2014). GreenDroid: Automated Diagnosis of Energy Inefficiency for Smartphone Applications. IEEE Transactions on Software Engineering, 40(9), 911–940. https://doi.org/10.1109/TSE.2014.2323982
[18] H. Ahmed et al., \"Evolution of Kotlin Apps in terms of Energy Consumption: An Exploratory Study,\" 2023 International Conference on ICT for Sustainability (ICT4S), Rennes, France, 2023, pp. 46-56, doi: 10.1109/ICT4S58814.2023.00014.
[19] Groza, C., Dumitru-Cristian, A., Marcu, M., & Bogdan, R. (2024). A Developer-Oriented Framework for assessing power consumption in mobile Applications: Android Energy Smells case Study. Sensors, 24(19), 6469. https://doi.org/10.3390/s24196469
[20] Fatima, I., Anwar, H., Pfahl, D., Qamar, U., College of Electrical and Mechanical Engineering, National University of Sciences and Technology, & Institute of Computer Science, University of Tartu. (2020). Detection and correction of Android-specific code smells and energy bugs: An Android Lint extension. QuASoQ 2020: 8th International Workshop on Quantitative Approaches to Software Quality, 71
[21] Sahin, C. (2024). Do popular apps have issues regarding energy efficiency? PeerJ, 10, e1891. https://doi.org/10.7717/peerj-cs.1891
[22] Li, X., Chen, J., Liu, Y., Wu, K., & Gallagher, J. J. (2022). Combatting Energy Issues for Mobile Applications. ACM Transactions on Software Engineering and Methodology, 32(1), 1–44. https://doi.org/10.1145/3527851
[23] Bhatt, B. N., & Furia, C. A. (2020). Automated Repair of Resource Leaks in Android Applications. arXiv: Software Engineering. https://doi.org/10.1016/j.jss.2022.111417
[24] Liu, Y., Wei, L., Xu, C., & Cheung, S.-C. (2016). DroidLeaks: Benchmarking Resource Leak Bugs for Android Applications. arXiv: Software Engineering. https://dblp.uni-trier.de/db/journals/corr/corr1611.html#LiuWXC16
[25] https://github.com/rcgroot/opengpstracker/blob/8ac7905a5ac78520c63adb864eb0765eca08cc56/application/src/nl/sogeti/android/gpstracker/logger/GPSLoggerService.java
[26] Yerima, Suleiman (2018). Android malware dataset for machine learning 2. figshare. Dataset. https://doi.org/10.6084/m9.figshare.5854653.v1
[27] Alkasassbeh, Mouhammd & Abbadi, Mohammad & Al-Bustanji, Ahmed. (2020). LightGBM Algorithm for Malware Detection. DOI:10.1007/978-3-030-52243-8_28.