0
votes

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)

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

4

4 Answers

1
votes

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.

1
votes

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

1
votes

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

1
votes

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