title: Calling a method from library (jar)
body: <p>I'm trying to understand library usage in Android. So I created a very simple library and import it in my project. I want to call the method <strong>cubeOf()</strong> from <strong>MyOperations.jar</strong> (library file). There is no building errors but the application is stopping unexpectedly when I runned.</p>
  
  <p><strong>MainActivity.java</strong> class (in MyApplication):</p>
  
  <pre><code>package com.sam.myapplication;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.widget.TextView;
  import com.sam.mylibrary.MyOperations;
  
  public class MainActivity extends Activity {
  
      TextView tv1;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          tv1 = (TextView) findViewById(R.id.textView1);
          MyOperations op = new MyOperations();
          int a = op.cubeOf(8); // Just a random number
          tv1.setText(a);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  }
  </code></pre>
  
  <p><strong>MyOperations.java</strong> class (in MyLibrary):</p>
  
  <pre><code>package com.sam.mylibrary;
  
  public class MyOperations {
      public static void main(String[] arg) {
  
      }
      public static int cubeOf(int i) {
          int c = i*i*i;
          return c;
      }
  }
  </code></pre>
  
  <p><h3><strong>SOLVED!</strong></h3> Thanks for replies, I solved the issue through <a href="http://www.vogella.com/articles/AndroidLibraryProjects/article.html" rel="nofollow"><strong>this article</strong></a>.</p>