Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I use an external jar in an Android project in NetBeans?
    primarykey
    data
    text
    <p>I need to create an Android library which I can include as a jar in any Android application. I use NetBeans 6.8, the nbandroid plugin, and the Android SDK.</p> <p>The steps I took so far are:</p> <p>1) Create the library project, with android.jar included to have access to Android classes (the library uses android.util.Log and other Android classes).</p> <p>2) Compile the library as a jar.</p> <p>3) Add the library's jar to the Android application (right-click on Libraries under the project node and add the jar).</p> <p><del>4) Add &lt;uses-library&gt; to the Android manifest.</del> (erroneous and unnecessary)</p> <p>Step 3 at least allows me to reference the library's classes in the application's source code, but the classes don't seem to actually be included at compile time. When I run the application, I get the following error in the log.</p> <pre><code>I/dalvikvm( 349): Could not find method mylibrarypackage.MyClass.myMethod, referenced from method myapplicationpackage.HomeActivity.onCreate W/dalvikvm( 349): VFY: unable to resolve static method 985: Lmylibrarypackage/MyClass;.myMethod ()V D/dalvikvm( 349): VFY: replacing opcode 0x71 at 0x000a D/dalvikvm( 349): Making a copy of Lmyapplicationpackage/HomeActivity;.onCreate code (160 bytes) D/AndroidRuntime( 349): Shutting down VM W/dalvikvm( 349): threadid=3: thread exiting with uncaught exception (group=0x4001b188) E/AndroidRuntime( 349): Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime( 349): java.lang.NoClassDefFoundError: mylibrarypackage.MyClass E/AndroidRuntime( 349): at myapplicationpackage.HomeActivity.onCreate(HomeActivity.java:58) E/AndroidRuntime( 349): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) E/AndroidRuntime( 349): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) E/AndroidRuntime( 349): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470) E/AndroidRuntime( 349): at android.app.ActivityThread.access$2200(ActivityThread.java:119) E/AndroidRuntime( 349): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) E/AndroidRuntime( 349): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 349): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 349): at android.app.ActivityThread.main(ActivityThread.java:4310) E/AndroidRuntime( 349): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 349): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 349): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) E/AndroidRuntime( 349): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) E/AndroidRuntime( 349): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>Do I have to add the library to the build path somewhere else? Am I missing something?</p>
    singulars
    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.
    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