Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a method from library (jar)
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload