<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Detection and Correction of Android-specific Code Smells and Energy Bugs: An Android Lint Extension</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Ifat Fatima</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Hina Anwar</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Dietmar Pfahl</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Usman Qamar</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>College of Electrical and Mechanical Engineering, National University of Sciences and Technology</institution>
          ,
          <addr-line>Islamabad</addr-line>
          ,
          <country country="PK">Pakistan</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Institute of Computer Science, University of Tartu</institution>
          ,
          <addr-line>Tartu</addr-line>
          ,
          <country country="EE">Estonia</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2020</year>
      </pub-date>
      <fpage>71</fpage>
      <lpage>78</lpage>
      <abstract>
        <p>Context: While Android applications sufer from code smells and energy drain issues there is still a lack of tools that help developers improve energy consumption and maintainability of Android applications. Objective: Our research aims to provide tool support to Android developers helping them to create greener and more maintainable applications by eliminating Android-specific code smells/energy bugs. The proposed tool support integrates routine code smell detection with energy bug detection so that developers can do both at the same time. Method: We extend 'Android Lint' (AL) with custom rules to detect and correct 12 code smells (nine are new and three are improved) and three energy bugs (two are new and one is improved). In addition, for the improved and newly introduced code smells, we compared the performance of our tool with the open version of the 'PAPRIKA' tool. Result: We evaluated our tool on nine open-source Android applications. Our tool detects the specified code smells and energy bugs with an average precision, average recall and F1 score of 0.93, 0.96, and 0.94, respectively. It accurately corrects 84% of selected code smells and energy bugs. The performance of the new and improved code smell detection is better than that achieved by 'PAPRIKA'. Conclusion: Our tool is a useful extension to the existing 'AL' tool with better performance than 'PAPRIKA'.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Green Software Development</kwd>
        <kwd>Android</kwd>
        <kwd>Energy Optimization</kwd>
        <kwd>Code Smell</kwd>
        <kwd>Energy Bug</kwd>
        <kwd>Android Lint</kwd>
        <kwd>Detection</kwd>
        <kwd>Refactoring</kwd>
        <kwd>Static Analysis</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>4) provide an interface consistent with the Android applications. They detected energy bugs like
CamStudio IDE. era Leak, Memory leak, Multimedia Leak, sensor</p>
      <p>The ’extended Android Lint’ (xAL) tool is evalu- Leak, and layout defects.
ated on open-source Android applications to detect Olivier Le Goaër [14] presented an automated tool
and correct code smells and energy bugs. The cur- based on ‘AL’ which detected 11 energy greedy
Anrent evaluation has resulted in average precision, droid patterns such as Draw Allocation, Wakelock,
average recall and F1 score of 0.93, 0.96, and 0.94, Recycle, Obsolete Layout Parameter, HashMap
Usrespectively. Whereas, 84% of the suggested correc- age, Member Ignoring Method, Excessive Method
tions applied to the applications under test, resulted Calls and some Resource Leaks. The tool
‘Auin the smooth functioning of applications. However, toRefactor’ was used for refactoring and the impact
results cannot be generalized based on these statis- of those refactoring on energy consumption of
opentics due to the small scale of the evaluation setup. source Android applications was measured.
Our tool also provides better code smell/energy bug The ‘E-Debitum’ [15] tool (based on ‘SonarQube’)
coverage, and usability compared to ‘PAPRIKA’ detected six energy code smells and calculated their
tool. energy debt.</p>
      <p>
        Section 2 provides related work. Section 3 con- Comprehensive coverage of Android-specific code
tains the tool design and implementation details. smells and energy bugs within one single tool is
Section 4 presents the evaluation plan and results. missing in existing tools. In the tools mentioned
Section 5 discusses threats to validity. Section 6 above, most commonly detected code smells were
concludes the study. Member Ignoring Method, Internal Getter and
Setter methods whereas most commonly detected
energy bugs were Wakelock Bug and Resource Leaks.
2. Related Work Existing tools have low usability due to lack of
Android Studio IDE integration. Tools in studies
There are several publications in which Android [
        <xref ref-type="bibr" rid="ref15">9, 8, 13</xref>
        ] provided a command line interface while
application analysis tools have been presented that in the study [11] integration with Eclipse IDE was
detect or correct Android-specific code smells and provided instead of Android Studio (which is the
energy bugs. The aim of this study is to provide oficial IDE for Android development [
        <xref ref-type="bibr" rid="ref14">7</xref>
        ]). Tools
a solution at the development stage hence we look compatible with Android Studio [14, 16], were not
into only those tools that perform static analysis, open source. Tools in studies [9, 13, 12, 11, 16]
with the aim to optimize applications in terms of did not refactor applications while tools in studies
their energy consumption. [
        <xref ref-type="bibr" rid="ref15">8, 15</xref>
        ] provided completely automated refactoring
      </p>
      <p>
        The ‘HOT-PEPPER’ toolkit [
        <xref ref-type="bibr" rid="ref15">8</xref>
        ] (based on ‘PA- hence reducing the control of the developer during
PRIKA’ tool [9]) detected and refactored a set of refactoring process.
      </p>
      <p>Android-specific code smells and produced a
corrected version of the APK without developer
intervention. 3. Design</p>
      <p>‘Statedroid’ tool [10] performed a taint-like
analysis using specified resource protocols to detect en- In this section, we describe how we selected the
ergy leaks caused by Wakelock Bugs and Resource baseline tool for extension and how we enhanced it.
Leaks.</p>
      <p>In [11], the authors used a combination of ‘Eclipse 3.1. Baseline Tool Selection
Refactoring API’, ‘PMD’, and ‘AL’ to build a tool
that optimizes Android applications for CPU usage. The aim of this study is to create a tool that
covTheir rule set covered only a limited number of ers the limitations of previously developed tools in
Android code smells. However, the tool ofered terms of providing a comprehensive coverage of the
developers the flexibility to add their own rules. Android code smells and energy bugs and solving</p>
      <p>The ‘aDOCTOR’ tool [12] detected 15 code smells the usability issues such as IDE integration,
flexcausing energy drains by traversing the abstract ibility and ease of use for developer, open source
syntax tree. The code smells were removed manually availability etc. Based on this objective, we set the
by authors and correlated to energy consumption. following criteria for selecting a tool for an
extenEnergy estimation was done using ‘PETrA’. The sion:
‘aDOCTOR’ tool has a precision and recall of 98%.</p>
      <p>Jiang et al.[13] used ‘SAAF’ for resource leak anal- • The tool should be open source or provide
ysis and ‘AL’ for layout defect analysis in Android the ability to extend or customize it to add
rules for detection and refactoring of code
smells/energy bugs.
• The tool should be able to perform static</p>
      <p>analysis.
• The tool should be integrate-able with
Android studio IDE as it is the oficial IDE for</p>
      <p>
        Android development [
        <xref ref-type="bibr" rid="ref14">7</xref>
        ].
• The tool should provide an inline warning
on code smell/energy bug detection inside
      </p>
      <p>Android Studio code editor.
• The tool should provide a mechanism to list
detected code smells/energy bugs along with
their description.
Criteria AL PMD SB SL SQ ST
Open Source ✓ ✓ ✓ ✓ ✓ ✓
Customization API ✓ ✓ X ✓ ✓ X
Source Code Analysis ✓ ✓ X ✓ X X
Byte Code Analysis ✓ X ✓ X ✓ ✓
Android Studio Integration ✓ ✓ ✓ ✓ ✓ X
Inline issue warning/hint ✓ X X ✓ ✓ X
List of detected code smells/energy bugs ✓ ✓ ✓ ✓ ✓ ✓
Allows adding refactoring rules ✓ X X X X X</p>
      <p>AL = Android Lint, SB = SpotBugs,SL= SonarLint, SQ = SonarQube, ST= SOOT</p>
      <p>
        The above criteria were applied on industry- not find any evidence in the literature about the
standard tools such as ‘AL1’ (AL), ‘PMD’, ‘Spot- energy impact of the issues already covered by the
Bugs2’ (SB), ‘SonarLint3’ (SL), ‘SonarQube4’ (SQ), above shortlisted tools, therefore, we only compared
and ‘SOOT5’ (ST) (see Table 1). A similar tool, them for the coverage of 25 Android-specific code
‘FindBugs’, was not considered as its successor is smells and nine energy bugs listed in [
        <xref ref-type="bibr" rid="ref8">1</xref>
        ].
‘SpotBugs’. ‘Eclipse refactoring engine’ was also ex- In Tables 2 and 3, ‘*’ represents that the code
cluded as it is not integratable with Android Studio. smell/energy bug is detected but based on the
defiTools that perform static analysis but focus on code nition of code smell/energy bug8 the detection
covstyling such as ‘CheckStyle’ were excluded. We also erage has room for improvement. ✓represents that
considered detection and optimization tools identi- code smell/energy bug is detected, × represents that
ifed in our previous work [
        <xref ref-type="bibr" rid="ref8">1</xref>
        ]. Even though many of code smell/energy bug is not covered by the tool yet.
these tools were built on top of open-source static From Tables 2 and 3, we can see that ‘AL’ already
analysis tools such as ‘SOOT’, ‘SPARK’, ’SAAF’, covers 13 code smells and six energy bugs.
There‘ASM’, ‘PMD’, and ‘Lint’, we did not select them fore, an efort towards improvement in the small
for an extension because they were not designed to number of undetected code smells/energy bugs will
be integrated with Android Studio IDE. The tools result in a single tool with maximum coverage. In
using dynamic analysis were also excluded as they addition, ‘AL’ provides ofline documentation for
require the application to be built every time. Long rules and allows the developer to choose whether
average build time for Android applications is a to correct a specific code smell/energy bug or not.
known and significant issue among the development Based on the above data, ‘AL’ is a feasible tool for
community6. Table 1 shows a comparison of tools an extension.
in terms of selection criteria. After this
comparison, ‘SpotBugs’, ‘SonarQube’, and ‘SOOT’ were 3.2. Android Lint Extension
excluded as they built the application every time a
code smell/energy bug needs to be detected. In this section, we explain the ‘AL’ API and
im
      </p>
      <p>Next, we compared the three shortlisted tools: pLlienmt’e(nxtAatLio)ntodoelt.ails of our new ’extended Android
‘AL’, ‘PMD’, and ‘SL’ for Android-specific code
smell and energy bug coverage (See Table 2 and API Overview. ‘AL’ provides an embedding API
3). ‘AL’, ‘PMD’, and ‘SonarLint’ can cover many that allows adding custom rules. In order to
crediferent types of issues in code (code smell, bug ate custom rules, the ‘AL’ embedding API
proor error is referred to as ‘issue’ in these tools). For
example, ‘AL’ can detect 261 diferent types of 8https://figshare.com/s/84ae49a21551e6302d41
Android-specific issues 7. Majority of these issues are
related to syntax and styling of the code. We could
1http://tools.android.com/tips/lint-custom-rules
2https://spotbugs.github.io/
3https://www.sonarlint.org/features/
4https://docs.sonarqube.org/latest/extend
5https://github.com/Sable/soot/
6https://developer.android.com/studio/build/optimizeyour-build
7http://tools.android.com/lint/overview
vides many class APIs. In the ‘AL’ API, each code
smell/energy bug has the following properties: Id,
summary, explanation, category, severity, priority,
and additional links9. This information is shown
to the developer when a code smell/energy bug is
detected. Each code smell/energy bug is registered
in an issue registry class and is detected by a
detector class. The functionalities of detector class
used by our implementation are given in additional
material10. Fig. 1 gives an overview of the ‘AL’
API (version 26.5.2 is used for the implementation
of detectors). The complexity calculation for the
code smells HAA, HSS and HBR are done using
‘Metrics Reloaded’ plugin for Android Studio11.</p>
      <p>Inclusion of New Code Smells/Energy Bugs. For
all undetected and partially covered code smells/
energy bugs (see Table 2 and 3), detection and
refactoring rules are defined based on the definitions bugs. Table 5 shows Android code smells/energy
provided in additional materials and Android devel- bugs that are partially covered by the original ‘AL’
opment best practice guides12 provided by Google. tool and the improvements we implemented in our
Table 4 shows a list of Android code smells and new ’xAL’ tool for each of them. Pseudo-code for
energy bugs that are implemented in our ’extended implemented code smells and energy bugs are given
Android Lint’ (xAL) tool. In ’Implementation’ col- in additional material13. For most of the detected
umn ’novel’ refer to code smells/energy bugs that code smells/energy bugs we ofer corrections. In
are not already present in the ‘AL’ tool. ’Improve- cases where we do not provide corrections to the
ment’ refers to code smells /energy bugs that are developer, a warning is issued. Each implemented
partially covered by the ‘AL’ tool and can be im- code smell/energy bug is tested on sample classes
proved by inclusion of additional APIs/conditions which contains possible variations in which a
sein our new ’xAL’ tool. The last column of Table 4 lected code smell/energy bug can be present in the
shows whether a correction is suggested by ’xAL’ code. In addition, we provide a description for each
for the detected Android code smells and energy of the detected code smell/energy bug, with the
aim to help developers in refactoring. We made
our tool open-source 16. The ’xAL’ tool is compiled
9http://tools.android.com/tips/lint-custom-rules
10https://figshare.com/s/84ae49a21551e6302d41.
11https://github.com/BasLeijdekkers/MetricsReloaded
12https://developer.android.com/topic/performance
13https://figshare.com/s/84ae49a21551e6302d41
16https://figshare.com/s/63c5b3e957f390432edf
CS/ API/Class already detected by API/Class detected by ’xAL’ tool as
imEB ‘AL’ tool provement
LT Detects thread class leak only. Detection of classes like
an(CS) droid.os.Handler and java.lang.Runnable</p>
      <p>that can lead to a thread leak14.</p>
      <p>BFU Detects bitmap duplication, cre- Detection of Bitmap using
(CS) ation in onDraw() and usability Bitmap.create(params. . . )15.</p>
      <p>issues.</p>
      <p>ERB Detects creation of objects dur- Detection of heavy APIs (of type:
(CS) ing DrawAllocation which can Android .location, android.media,
anbe performed by lazy initializa- droid.database, android.hardware) that
tion should be initialized in lazy fashion1.</p>
      <p>RL Detects resources such as IO, Detection of resources like Camera, Media
(EB) JDBC, static fields, wifi man- Player etc. [? ]</p>
      <p>ager, StringBufer etc.</p>
      <p>CS =Code Smell, EB =Energy Bug, LTLeaking Thread, BFU= Bitmap Format Usage,
ERB=Early Resource Binding, RL=Resource Leak
4.2. Evaluation Results</p>
      <sec id="sec-1-1">
        <title>This section presents the results of testing the tool on open source projects and compares its coverage with PAPRIKA tool.</title>
        <p>4.2.1. Evaluation on Open Source Apps
The tool was tested on the nine applications selected
from the F-Droid repository. Table 6 shows the
results of the evaluation on open source applications.
as a Jar file. The Jar file is placed in the .an- It lists the application name against the code smells
droid/lint folder of the Android Studio installation, detected in it, true positives (TP), false positives
typically located in USER-HOME. Android Studio (FP), false negatives (FN), precision (P), recall (R),
is restarted for new detectors to take efect. Ap- total corrections available (TCA) and total applied
plications can be analyzed for Android code smells correction (TAC) .
and energy bugs in two ways17, i.e., in-line analysis Some of the code smells/energy bugs (such as
and whole-application analysis. ’Early Resource Binding’ (ERB), ’Heavy Async Task’
(HAT) and ’Heavy Broadcast Receiver’ (HBR)) did
not appear in any of the applications under test.
4. Evaluation In the case of application ‘Kolabnotes’ two false
negatives were detected, i.e. two instances of code
4.1. Evaluation Plan smell ’Lifetime Containment’ (LC) code smell. A
We evaluated the ’xAL’ tool in two steps. First, possible reason could be declarations of interfaces in
we evaluated the tool on a selection of open source non-lifecycle classes, which were not included in the
apps, then we compared the tool’s performance to LC code smell definition. In the case of application
that of the ‘PAPRIKA’ tool. ‘Sound Recorder’ two false negatives were detected,</p>
        <p>Evaluation on Open Source Apps. The evaluation i.e. two instances of code smells ’No Low
Memincludes testing on nine real-world applications18 ory Resolver’ (NLMR). A possible reason could be
chosen from the F-Droid19 repository. The appli- that the class used by this application is deprecated,
cations were chosen if the source code was in Java hence not covered by the implementation of our
and the number of line of code was less than 30,000 ’xAL’ tool. In the case of applications ‘Kolabnotes’
(for ease of manual verification). We checked that and ‘Camera Roll’ one false positive (i.e., one
ineach application can be compiled and executed on stance of the ’Data Transmission without
Compresa device without errors. sion’ (DTWC) code smell) was detected for each
ap</p>
        <p>Comparison with ‘PAPRIKA’. We considered plication. In the case of application ‘Calorie Scope’
state of the art tools such as ‘PAPRIKA’, ‘aDOC- one false positive was detected, i.e., one instance of
TOR’, ‘SAAD’, ‘Chimer’ and ‘AL’ (implementation ’Resource Leak (RL) for a camera instance energy
by Goaër [14]) as possible comparison candidates. bug. In the case of application, ’CameraColorPicker’
’Chimer’ and the ’AL’ tool presented in [14] were ifve false positives (i.e. Lifetime Containment (LC)
not available in open source. We chose ‘PAPRIKA’ code smell (4 instances) and Resource Leak (RL)
as it had the largest number of overlapping code energy bug (1 instance)) were detected. In the
smells/energy bugs with our ’xAL’ tool. These case of application, ‘Privacy- Friendly Weather’ two
are Heavy Async Task (HAT), Heavy Broadcast false positives (i.e. two instances of Lifetime
Containment (LC) code smell) were detected. In the
17https://figshare.com/s/84ae49a21551e6302d41 (See case of code smell Lifetime Containment (LC), a
Tool Walk-through) possible reason for false positive could be that it
18https://figshare.com/s/84ae49a21551e6302d41 (See Ta- flags abstract classes as interfaces as well. In the
ble 1)
19https://f-droid.com 20https://github.com/GeofreyHecht/paprika
Table 6 Heavy Start Service (HSS), Heavy Broadcast
ReResults of evaluation on open source app using ‘xAL’ tool ceiver (HBR). For these smells, no false positives</p>
        <p>Detection Results were detected. ‘PAPRIKA’ did not detect any
inID App CS/EB Detected TP FP FN P R TCA TAC stance of the code smells/energy bugs Unused
Hard213 CKOaodllyoasrbsineeoyStceospe ILUUWCHH,RAAN,,,NLNMLBLMMFRU,RR,R,LHL,STVS,,BLSDCT,IWWCR, 111812 101 020 0.911 0.911 1673 1367 wInavraeliAdactceelweriathtioount (RUeHctA()I,WRRes)o, uwrhceichLecaokul(dRbLe) saenedn
54 CBaipmoelrAalaRromll UUNHHLMAA,,RHB,FSPSUD,,DDTTWWCC,, NIWLMR,RLC, 214 10 00 11 11 146 46 in T‘FaNbl’ec8olsuhmowns. a comparison of the code smells
de6 Sound Recorder UHA, PD 7 0 2 1 0.8 7 7 tected by both ’xAL’ and ‘PAPRIKA’. ✓represents
7 CameraColorPicker LUCH,AR,LBFU, NLMR, IWR, 12 5 0 0.7 1 17 12 that a code smell is detected in a test application, ×
8 WPreivaathcyer-Friendly UHA, LT, LC, NLMR 13 2 0 0.9 1 15 13 represents that a code smell was not detected in a
9 Reminders UHA, DTWC, NLMR 5 0 0 1 1 5 5 test application and empty cells show that the code
CS = Code Smell, EB = TEOneTrgAyLBug, TP = True Positive, F1P03= Fa1ls0e posi4tive,–FN =–False N9e0gative,7P3= smell was not present in a test application. Code
Precision, R= Recall, TCA = Total Corrections Available, TAC= Total Applied Corrections smell Heavy Async Task (HAT) was not present
in any of the test applications hence not detected
case of code smell Data Transmission without Com- by ‘PAPRIKA’ and our ’xAL’ tool. ’xAL’ was able
pression (DTWC), a possible reason could be that to detect almost all the code smell instances that
the ’xAL’ tool does not track instances that were were detected by ‘PAPRIKA’ tool. However, two
incompressed in another class. In the case of energy stances of ’No Low Memory Resolver’ (NLMR) code
bug Resource Leak (RL), a possible reason for false smells were missed in application ‘Sound Recorder’
positives could be that code smell/energy bug was (as they used a deprecated class API). The ’Heavy
handled pro-actively by the developer. For exam- Broadcast Receiver’ (HBR) code smell was also
ple, for Resource Leak (RL), if the camera instance missed by our tool as the value for an upper limit
was closed proactively by the developer in a method of computational complexity is set to five in
‘PAother than onStop(). In this case, check on onStop() PRIKA’ and ten (as per McConnel [17]) in our ’xAL’
method is no longer required. tool.</p>
        <p>Corrections were available for 66.3% of the de- ‘PAPRIKA’ detected seven instances of false
negtected Android code smells and energy bug in- atives for the code smells: Unused Hardware
Accelstances, out of which 84% of corrections were ap- eration (UHA) (5 instances) and Invalidate
withplied. 16% corrections were not applied, which out Rect (IWR) (1 instance) and energy bug
Reinclude false positives and instances of Public Data source Leak (RL) (1 instance). As compared to
(PD) code smell (correction of this code smell al- ‘PAPRIKA’, our tool was able to detect Invalidate
tered the functionality of the application under test). without Rect (IWR) code smell and Resource Leak
These numbers are dependent on the type of code (RL) energy bug in ‘CameraColorPicker’ test
applismell/energy bug and the frequency of its instances cation. Unused Hardware Acceleration (UHA) code
in the application. smell was also detected in all five applications by
our tool. Table 9 shows a compatibility comparison
between ‘PAPRIKA’ and ’xAL’ to gain a better
4.2.2. Comparison with PAPRIKA understanding of the support ofered by both tools
The ‘PAPRIKA’ tool did not work on applications as well as their limitations.
1 to 4 that had AndroidX21 dependencies. Due The average precision, recall and F1-score for our
to this inherent limitation of ‘PAPRIKA’, it was ’xAL’ were 0.93, 0.96 and 0.94, respectively. The
avonly tested on applications 5 to 9. Refactoring of erage precision, recall and F1-score for ‘PAPRIKA’
code smells/energy bugs was not applied in any test were 1.0, 0.74 and 0.85, respectively. Hence, our
application as the accessible version of ‘PAPRIKA’ ’xAL’ tool not only provides better Android code
tool does not ofer to refactor. smell/energy bug coverage but also improves upon</p>
        <p>Table 7 shows the results of the evaluation on the usability aspects of the tool in comparison to
open source applications using ‘PAPRIKA’. It lists ‘PAPRIKA’ tool.
the application name against the code smells
detected in it, true positives (TP), false positives (FP),
false negatives (FN), precision and recall. ‘PA- 5. Threats to Validity
PRIKA’ was able to detect three types of code Our ’xAL’ tool only performs static source code
smells namely: No Low Memory Resolver (NLMR), analysis of Android applications. Since static source
code analysis could be done during development
re21https://developer.android.com/jetpack/androidx</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>6. Conclusion</title>
      <sec id="sec-2-1">
        <title>We extended the tool ‘AL’ to detect and correct</title>
        <p>Android-specific code smells and energy bugs that
may lead to energy optimization in Android
applications. On top of the 261 issues already covered by
peatedly, the support provided by our tool could ‘AL’, our extended tool ’xAL’ provides coverage for
benefit developers. Implementation of a function- 12 Android-specific code smells (nine new and three
ality may vary based an application’s architec- improved) and three energy bugs (two new and one
ture/design and the coding style of a developer. improved). Moreover, ’xAL’ integrates directly in
Hence, our definitions of code smells/energy bugs Android Studio IDE and gives control to the
develmight not cover every scenario related to a particu- oper for refactoring code smell/energy bugs, which
lar code smell, leading to false positives and false was missing in other state of the art tools. We
negatives in the results. For example, we only con- evaluated ’xAL’ on nine open-source applications; it
sider lifecycle classes, i.e. Activity and Fragment detects code smells and energy bugs with an average
for lifecycle dependent issues like Resource Leak precision, average recall and F1 score of 0.93, 0.96,
and Leaking Thread. However, depending on the and 0.94 respectively. It accurately corrects 84%
application architecture, lifecycle dependent compo- of selected code smells and energy bugs. Our tool
nents might be called in non-lifecycle classes which ofers better code smell and energy bug detection
may go undetected. Moreover, some corrections coverage as compared to ‘PAPRIKA’. In the future,
for code smells, and energy bugs might clash with we aim to evaluate ’xAL’ on a large data set of
the functional requirements of the application. For applications, which will also help in analyzing the</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <article-title>correlation between the frequency of occurrences SANER (</article-title>
          <year>2017</year>
          )
          <fpage>115</fpage>
          -
          <lpage>126</lpage>
          . doi:
          <volume>10</volume>
          .1109/SANER.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <article-title>of code smells/energy bugs</article-title>
          , and impact on energy
          <year>2017</year>
          .
          <volume>7884614</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <article-title>consumption due to their refactoring</article-title>
          . [9]
          <string-name>
            <given-names>G.</given-names>
            <surname>Hecht</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Rouvoy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Moha</surname>
          </string-name>
          , L. Duchien, Detecting Antipatterns in Android Apps,
          <source>2nd ACM Int'l Conf. on Mobile Softw. Eng. and</source>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <surname>Acknowledgments Systems - MOBILESoft</surname>
          </string-name>
          (
          <year>2015</year>
          )
          <fpage>148</fpage>
          -
          <lpage>149</lpage>
          . doi:10.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <article-title>This work is supported by the Estonian Center of [10] 1Z1</article-title>
          .0X9u/,MoCb.iWleeSno, fSt..
          <source>Q20in1</source>
          ,
          <year>5S</year>
          .3ta8t.
          <article-title>e-taint analysis for</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <article-title>grant PRG887 funded by the Estonian Research Programming (</article-title>
          <year>2018</year>
          )
          <fpage>93</fpage>
          -
          <lpage>109</lpage>
          . doi:
          <volume>10</volume>
          .1016/j.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <surname>Council. scico.</surname>
          </string-name>
          <year>2017</year>
          .
          <volume>06</volume>
          .010. [11]
          <string-name>
            <given-names>V. N.</given-names>
            <surname>Huynh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Inuiguchi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Le</surname>
          </string-name>
          ,
          <string-name>
            <surname>B. N.</surname>
          </string-name>
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>I.</given-names>
            <surname>Fatima</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Anwar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Pfahl</surname>
          </string-name>
          , U. Qamar,
          <article-title>mization Techniques Using PMD and Android Tool Support for Green Android Development: Lint, LNCS (including subseries LNAI and A Systematic Mapping Study</article-title>
          ,
          <source>in: 5th Int. LNB) 9978 LNAI</source>
          (
          <year>2016</year>
          )
          <article-title>V-VI</article-title>
          .
          <source>doi:10.1007/ Conf.on Softw. Technologies - ICSOFT</source>
          ,
          <year>2020</year>
          ,
          <fpage>978</fpage>
          -3-
          <fpage>319</fpage>
          -49046-5. pp.
          <fpage>409</fpage>
          -
          <lpage>417</lpage>
          . [12]
          <string-name>
            <given-names>F.</given-names>
            <surname>Palomba</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. Di</given-names>
            <surname>Nucci</surname>
          </string-name>
          ,
          <string-name>
            <surname>A</surname>
          </string-name>
          . Panichella,
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>A.</given-names>
            <surname>Turner</surname>
          </string-name>
          ,
          <article-title>How many people have A</article-title>
          .
          <string-name>
            <surname>Zaidman</surname>
          </string-name>
          ,
          <string-name>
            <surname>A. De Lucia</surname>
          </string-name>
          ,
          <source>Lightweight desmarphones worldwide (Apr</source>
          <year>2020</year>
          ),
          <year>2020</year>
          .
          <article-title>tection of Android-specific code smells: The URL</article-title>
          : https://www.bankmycell.com/blog/ aDoctor project,
          <article-title>SANER 2017 - 24th IEEE how-many-phones-are-in-the-world</article-title>
          .
          <source>Int'l Conf. on Softw. Analysis</source>
          , Evolution, and
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>R.</given-names>
            <surname>Verdecchia</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. Aparicio</given-names>
            <surname>Saez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Procac- ReEng.</surname>
          </string-name>
          (
          <year>2017</year>
          )
          <fpage>487</fpage>
          -
          <lpage>491</lpage>
          . doi:
          <volume>10</volume>
          .1109/SANER. cianti, P. Lago,
          <source>Empirical Evaluation of the En- 2017.7884659. ergy Impact of Refactoring Code Smells</source>
          (
          <year>2018</year>
          ) [13]
          <string-name>
            <given-names>H.</given-names>
            <surname>Jiang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Yang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Qin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Su</surname>
          </string-name>
          , J. Zhang,
          <volume>345</volume>
          -
          <fpage>365</fpage>
          . doi:
          <volume>10</volume>
          .29007/dz83. J.
          <string-name>
            <surname>Yan</surname>
          </string-name>
          , Detecting Energy Bugs in Android
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>H.</given-names>
            <surname>Anwar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Pfahl</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. N.</given-names>
            <surname>Srirama</surname>
          </string-name>
          ,
          <article-title>Evaluating Apps Using Static Analysis, LNCS (including the Impact of Code Smell Refactoring on the subseries LNAI and LNB) 10610 LNCS (</article-title>
          <year>2017</year>
          )
          <article-title>Energy Consumption of Android Applications</article-title>
          ,
          <fpage>192</fpage>
          -
          <lpage>208</lpage>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>319</fpage>
          -68690-5_ in: 45th
          <source>Euromicro Conf.on Softw. Eng. and 12</source>
          .
          <string-name>
            <surname>Advanced</surname>
            <given-names>Applications</given-names>
          </string-name>
          , SEAA,
          <year>2019</year>
          , pp.
          <fpage>82</fpage>
          -
          <lpage>[</lpage>
          14]
          <string-name>
            <given-names>O. L.</given-names>
            <surname>Goaër</surname>
          </string-name>
          ,
          <article-title>Enforcing green code with an86</article-title>
          .
          <source>doi:10</source>
          .1109/SEAA.
          <year>2019</year>
          .
          <volume>00021</volume>
          . droid lint,
          <source>in: 34th IEEE/ACM Int. Conf. on</source>
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>A. V.</given-names>
            <surname>Rodríguez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Mateos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Zunino</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Automated</given-names>
            <surname>Softw</surname>
          </string-name>
          . Eng. Workshop - ASEW,
          <string-name>
            <given-names>M.</given-names>
            <surname>Longo</surname>
          </string-name>
          ,
          <article-title>An analysis of the efects of 2019</article-title>
          . doi:
          <volume>10</volume>
          .1109/ASEW.
          <year>2019</year>
          .
          <volume>00018</volume>
          .
          <article-title>bad smell-driven refactorings in mobile ap-</article-title>
          [15]
          <string-name>
            <given-names>D.</given-names>
            <surname>Maia</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Couto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Saraiva</surname>
          </string-name>
          , E-Debitum :
          <article-title>plications on battery usage</article-title>
          , in: Mod- Managing
          <string-name>
            <surname>Softw</surname>
          </string-name>
          . Energy
          <string-name>
            <surname>Debt</surname>
          </string-name>
          (
          <year>2020</year>
          )
          <fpage>162</fpage>
          -
          <lpage>169</lpage>
          . ern Softw. Eng. Methodologies for Mobile [16]
          <string-name>
            <given-names>M.</given-names>
            <surname>Couto</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Saraiva</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. P.</given-names>
            <surname>Fernandes</surname>
          </string-name>
          , Enand Cloud Environments,
          <year>2016</year>
          . doi:
          <volume>10</volume>
          .4018/ ergy Refactorings for Android in
          <source>the Large 978-1-4666-9916-8.ch009. and in the Wild</source>
          (
          <year>2020</year>
          )
          <fpage>217</fpage>
          -
          <lpage>228</lpage>
          . doi:
          <volume>10</volume>
          .1109/
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>C.</given-names>
            <surname>Sahin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Pollock</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Clause</surname>
          </string-name>
          ,
          <source>How do code saner48275</source>
          .
          <year>2020</year>
          .
          <volume>9054858</volume>
          .
          <article-title>refactorings afect energy usage?</article-title>
          ,
          <string-name>
            <surname>Int'l</surname>
            Sym- [17]
            <given-names>S. McConnell</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Code Complete</surname>
          </string-name>
          :
          <article-title>A Practical posium on Empirical Softw</article-title>
          .
          <source>Eng. and Mea- Handbook of Softw. Construction</source>
          <volume>9</volume>
          (
          <year>2011</year>
          ). surement - ESEM (
          <year>2014</year>
          )
          <fpage>1</fpage>
          -
          <lpage>10</lpage>
          . doi:
          <volume>10</volume>
          .1145/ 2652524.2652538.
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>S.</given-names>
            <surname>Habchi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Rouvoy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Moha</surname>
          </string-name>
          ,
          <article-title>On the survival of android code smells in the wild</article-title>
          ,
          <source>Proceedings - 2019 IEEE/ACM 6th Int'l Conf. on Mobile Softw. Eng. and Systems</source>
          ,
          <string-name>
            <surname>MOBILESoft</surname>
          </string-name>
          <year>2019</year>
          (
          <year>2019</year>
          )
          <fpage>87</fpage>
          -
          <lpage>98</lpage>
          . doi:
          <volume>10</volume>
          .1109/MOBILESoft.
          <year>2019</year>
          .
          <volume>00022</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>A.</given-names>
            <surname>Carette</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. A. A.</given-names>
            <surname>Younes</surname>
          </string-name>
          , G. Hecht,
          <string-name>
            <given-names>N.</given-names>
            <surname>Moha</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Rouvoy</surname>
          </string-name>
          ,
          <article-title>Investigating the energy impact of Android smells</article-title>
          ,
          <source>24th IEEE Int'l Conf. on Softw. Analysis</source>
          , Evolution, and
          <string-name>
            <surname>ReEng</surname>
          </string-name>
          . -
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>