title: Could not find class X referenced from method X.<init>
body: <p>I came across this strange problem while testing my app on a Galaxy S III. It works fine on other devices.</p>
  
  <p>The subject class goes like this:</p>
  
  <pre><code>public class MyClass extends Service {
  
      public void onCreate() {
          super.onCreate();
  
          // do stuff
      }
  }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/14765910/could-not-find-class-xxx-referenced-from-method-xxx-yyy">Other people</a> have had the same problem and it seems to be related to the built of the source code. However, I don't know how to solve this on Android Studio. </p>
  
  <hr>
  
  <p><strong><em>SOLVED</em></strong></p>
  
  <p>It appears that the cause of the problem where the <strong>camera2 APIs</strong> which were used in that class. Those APIs target <strong>Lollipop</strong> and above and for that reason the app was crashing trying to resolve the imports,even if at runtime I wasn't using any unavailable method (checking the build version of the device).
  <br>I'm not sure about the reason of this, but anyway moving the Camera2 implementation to another class fixed the problem.</p>