0

I am having a library in vendor/xxx/libs/frameworks. I want to use that library in a separate application located at packages/apps/. when I am calling the classes of the library I am getting ClassNotFoundException. So should I declare this jar in my application makefile or manifest file. If yes How can I do that?

Here is make file of the jars

LOCAL_PATH := $(call my-dir)

# ============================================================

include $(CLEAR_VARS)

LOCAL_MODULE := xxx_core.jar

LOCAL_MODULE_CLASS := JAVA_LIBRARIES

LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)

LOCAL_SRC_FILES := $(LOCAL_MODULE)

include $(BUILD_PREBUILT)

==== permissions ========================

include $(CLEAR_VARS)

LOCAL_MODULE := xxx_core.xml

LOCAL_MODULE_CLASS := ETC

LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions

LOCAL_SRC_FILES := $(LOCAL_MODULE)

include $(BUILD_PREBUILT)

============================================================

Satya
  • 800
  • 7
  • 20

4 Answers4

1

You haven't mentioned if you added the jar to the buildpath of the app. To do this, right click on the project > Build Path > Add external Archives.

If this doesn't resolve this, then you should have a look at this tread: Android ClassNotFoundException

I hope this helps.

Community
  • 1
  • 1
Luke Taylor
  • 9,481
  • 13
  • 41
  • 73
  • 1
    I am not using eclipse... I am working on open source code...So i cant do which you have suggested – Satya Aug 20 '12 at 06:49
1

Follow this step to include the jar file in android application. It will be helpfull to you.

put your jar file in the lib folder.

Now right click on the jar file. go to Build Path and then Configure build path.. A dialog box open now. Click on the Add JARs.. Button. Now select the jar file which you want to add in your app from the project list opened.

Now Click On OK. your jar file is added in your application

Preet_Android
  • 2,332
  • 5
  • 25
  • 43
1

If you haven't figured this out already, the build command you're looking for is:

LOCAL_STATIC_JAVA_LIBRARIES := android-common <YOUR-FRAMEWORK>

Assuming that your makefile in frameworks has a directive like

LOCAL_MODULE:= <YOUR-FRAMEWORK>

Good luck, I've found the Android build system to be a giant undocumented mess - but then they probably intended it to be that way

JRaymond
  • 11,625
  • 5
  • 37
  • 40
1

Use <uses-library> in application's manifest to make a reference to this .jar.

LubosD
  • 781
  • 6
  • 18