title: How to Configure AspectJ in Android Studio
body: <p><strong>I am trying to configure AspectJ in Android Studio</strong>. <br>But after all trial and error its not working ! Surprisingly I am able to make it work with Eclipse Kepler version <br><br> <strong>The steps I followed for Android Studio</strong><br></p>
  
  <ol>
  <li>Created sample <code>Android</code> Project</li>
  <li>File > Settings > searched for <code>AspectJ</code> in Plugin section<a href="https://i.stack.imgur.com/KREfl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KREfl.png" alt="Plugin for AspectJ"></a></li>
  <li>Assuming nothing more to be done in Studio , except configuration of build.gradle files</li>
  <li>Added <code>compile 'org.aspectj:aspectjrt:1.8.1'</code> to the to the build.gradle (Module:app)</li>
  <li>Created <code>Analytics_onBackPressed.aj</code>  for <strong>back button press detection</strong></li>
  <li>Created <code>Analytics_OnClick.aj</code> for <strong>click events detection</strong></li>
  <li>Created <code>Analytics_onCreate.aj</code> for <strong>components oncreate event detection</strong></li>
  <li>Created necessary dependency classes which the above mentioned <code>*.aj</code> classes will internally call</li>
  <li>Added required permissions in Manifest</li>
  <li>Running the project is not detecting any of the events (button click, oncreate or back button click)</li>
  <li>Followed these links <a href="https://stackoverflow.com/questions/28546803/is-it-possible-to-integrate-dagger-and-aspectj-in-an-android-studio-project">ReferenceLinkOne</a> , <a href="https://www.jetbrains.com/help/idea/2016.1/creating-a-library-for-aspectjrt-jar.html" rel="noreferrer">ReferenceLinkTwo</a> and <a href="https://www.jetbrains.com/help/idea/2016.1/enabling-aspectj-support-plugins.html" rel="noreferrer">ReferenceLinkThree</a></li>
  </ol>
  
  <blockquote>
    <p><strong>My Question is what is more required to make AspectJ working with Android Studio</strong></p>
  </blockquote>
  
  <p><br>
  <strong>Steps followed in Eclipse and got AspectJ working</strong><br></p>
  
  <ol>
  <li>Downloaded <code>Eclipse</code> Kepler version</li>
  <li>Through Install New Software option searched for <a href="http://download.eclipse.org/tools/ajdt/43/update" rel="noreferrer">http://download.eclipse.org/tools/ajdt/43/update</a></li>
  <li>Installed <code>AspectJ Development Tools (Required)</code> . </li>
  <li>Created sample android project</li>
  <li>Created <code>Analytics_onBackPressed.aj</code>  for <strong>back button press detection</strong></li>
  <li>Created <code>Analytics_OnClick.aj</code> for <strong>click events detection</strong></li>
  <li>Created <code>Analytics_onCreate.aj</code> for <strong>components oncreate event detection</strong></li>
  <li>Added required permissions in Manifest File</li>
  <li>Right clicked in project and converted project to AspectJ by the following
  <a href="https://i.stack.imgur.com/gzcrU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gzcrU.png" alt="Converted project to AspectJ"></a></li>
  <li>Configured Java build path with AspectJ runtime library</li>
  <li>Now while running the project, I am able to detect components oncreate, back button press
  <br></li>
  </ol>
  
  <p><strong>Environment Used</strong></p>
  
  <blockquote>
    <p>Android Studio : 2.1.2</p>
    
    <p>JRE : 1.8.0</p>
    
    <p>Windows 7 Enterprise</p>
  </blockquote>
  
  <p>Any help is highly appreciated!</p>
  
  <hr>
  
  <p><strong>EDIT : 1 , From the output , still AspectJ is not properly configured</strong> </p>
  
  <p>As per <a href="http://intellij.expertsystems.se/aspectj.html" rel="noreferrer">this link</a> , I created jar file from eclipse including <code>*.aj</code> files and corresponding dependency. Excluded <code>AndroidManifest.xml</code> while creating <code>jar file</code> and created <code>jar</code></p>
  
  <p>Created Project in Android Studio. Placed this *.jar file in libs file. <code>(apps&gt; libs)</code>. I have enabled AspectJ waving as shown below<br><br>
  <a href="https://i.stack.imgur.com/clmjK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/clmjK.png" alt="Enabled AspectJ waving"></a><br><br>
  Now searched the properties for AspectJ and enabled <br>
  <a href="https://i.stack.imgur.com/30sMB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/30sMB.png" alt="enter image description here"></a>
  <br>
  Now running the project, should be creating logs I had put in <code>*.aj</code> files  which is in plugin . Unfortunately these logs are not printed in Android Studio logs. </p>
  
  <p>Form which I am concluding still AspectJ is not enabled in this project OR there is a configuration error </p>