[Android Q&A, Help & Troubleshooting] bingge1:
I want to use a 3rd party jar in the system app - Settings.

I have tried two methods, but both failed.

The Android version is 4.2.2 JB.

The first method is that I put the jar file into /packages/apps/Settings/ and modify the Android.mk.

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_JAVA_LIBRARIES := bouncycastle telephony-common
LOCAL_STATIC_JAVA_LIBRARIES := guava android-support-v4 jsr305 nxpnfclib

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PACKAGE_NAME := Settings
LOCAL_CERTIFICATE := platform

LOCAL_PROGUARD_FLAG_FILES := proguard.flags

include $(BUILD_PACKAGE)
include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := nxpnfclib.jar

include $(BUILD_MULTI_PREBUILT)
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))

Some proguard warnings show up:

Warning: class [com/nxp/nfclib/ntag/╦К.class] unexpectedly contains class [com.nxp.nfclib.ntag.ˊ]
Warning: there were 30 classes in incorrectly named files. You should make sure all file names correspond
to their class names. The directory hierarchies must correspond to the package hierarchies. If you don't mind
the mentioned classes not being written out, you could try your luck using the '-ignorewarnings' option.
Error: Please correct the above warnings first. make: *** [out/target/common/obj/APPS/Settings_intermed
iates/proguard.classes.jar] Error 1

Then I add some proguard flags to prevent this warnings. I can compile Android now. However, when I boot the system, some errors show up:

W/dalvikvm( 732): Unable to resolve superclass of Lcom/nxp/nfclib/ntag/NTag213215216; (1855)

W/dalvikvm( 732): Link of class 'Lcom/nxp/nfclib/ntag/NTag213215216;' failed

W/dalvikvm( 732): Unable to resolve superclass of Lcom/nxp/nfclib/ntag/NTag213F216F; (1844)

W/dalvikvm( 732): Link of class 'Lcom/nxp/nfclib/ntag/NTag213F216F;' failed

E/dalvikvm( 732): Could not find class 'com.nxp.nfclib.ntag.NTag213F216F', referenced from method com.nxp.nfclib.NxpNfcLib.ˊ

Another mothod: I put the jar file to /prebuilts/misc/common/nxp and write an Android.mk:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_PREBUILT_JAVA_LIBRARIES := \
nxpnfclib$(COMMON_JAVA_PACKAGE_SUFFIX)

LOCAL_MODULE_TAGS := optional

include $(BUILD_HOST_PREBUILT)

Then modify /packages/apps/Settings/Android.mk:

LOCAL_STATIC_JAVA_LIBRARIES := guava android-support-v4 jsr305 nxpnfclib

However, when I compile the whole AOSP, the same proguard warnings show up:

Warning: class [com/nxp/nfclib/ntag/╦К.class] unexpectedly contains class [com.nxp.nfclib.ntag.ˊ]
Warning: there were 30 classes in incorrectly named files. You should make sure all file names correspond
to their class names. The directory hierarchies must correspond to the package hierarchies. If you don't mind
the mentioned classes not being written out, you could try your luck using the '-ignorewarnings' option.
Error: Please correct the above warnings first. make: *** [out/target/common/obj/APPS/Settings_interm
ediates/proguard.classes.jar] Error 1

Is there some other way to add the jar?

The jar runs well if I use Android Studio to build an app.

Can I put the jar in the system instead of merge it into the system?