How to build SimpleClient.apk by Android.mk instead of Eclipse

asked 2015-12-07 02:04:57 -0700

fengying.chu gravatar image

updated 2015-12-07 13:48:51 -0700

praveenb gravatar image

Hi, I compiled and built the SimpleClient.apk by using Android.mk instead of Eclipse. The build result is fine and the SimpleClient.apk is installed to my Android device successfully. However, when I executed the SimpleClient application, it is not workabble. From the logs of Dalvik Debug Monitor, I found that "JNI_ERR returned from JNI_OnLoad in liballjoyn_java.so" Does it mean something wrong with my Android.mk? The source codes that I used to build the SimpleClient.apk are all from the offical released SDK. I am stuck in this, I have tried many things but nothing is working. Does someone know how to solve this problem?

The following are my Android.mk and the Error Log. Thanks a lot.


    LOCAL_PATH:= $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_MODULE_TAGS := samples
    LOCAL_JNI_SHARED_LIBRARIES := liballjoyn_java
    LOCAL_SRC_FILES := $(call all-java-files-under, src)
    LOCAL_PACKAGE_NAME := SimpleClient
    LOCAL_PROGUARD_FLAG_FILES := proguard.flags
    LOCAL_CERTIFICATE := platform
    LOCAL_DEX_PREOPT := false
    include $(BUILD_PACKAGE)
    include $(CLEAR_VARS)
    LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := alljoyn:libs/alljoyn.jar
    include $(CLEAR_VARS)
    include $(BUILD_PREBUILT)
    include $(call all-makefiles-under,$(LOCAL_PATH))

The Error Log:

12-07 17:33:11.957: I/ActivityManager(672): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.alljoyn.bus.samples.simpleclient/.Client (has extras)} from uid 10012 on display 0
12-07 17:33:11.993: I/ActivityManager(672): Start proc 28748:org.alljoyn.bus.samples.simpleclient/u0a100 for activity org.alljoyn.bus.samples.simpleclient/.Client
12-07 17:33:12.081: W/linker(28748): /data/app/org.alljoyn.bus.samples.simpleclient-1/lib/arm/liballjoyn_java.so: is missing DT_SONAME will use basename as a replacement: "liballjoyn_java.so"
12-07 17:33:12.112: D/AndroidRuntime(28748): Shutting down VM
12-07 17:33:12.113: E/AndroidRuntime(28748): FATAL EXCEPTION: main
12-07 17:33:12.113: E/AndroidRuntime(28748): Process: org.alljoyn.bus.samples.simpleclient, PID: 28748
**12-07 17:33:12.113: E/AndroidRuntime(28748): java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/org.alljoyn.bus.samples.simpleclient-1/lib/arm/liballjoyn_java.so"**
12-07 17:33:12.113: E/AndroidRuntime(28748):    at java.lang.Runtime.loadLibrary(Runtime.java:372)
12-07 17:33:12.113: E/AndroidRuntime(28748):    at java.lang.System.loadLibrary(System.java:1076)
12-07 17:33:12.113: E/AndroidRuntime(28748):    at org.alljoyn.bus.samples.simpleclient.Client.<clinit>(Client.java:50)
12-07 17:33:12.113: E/AndroidRuntime(28748):    at java.lang.Class.newInstance(Native Method)
12-07 17:33:12.113: E/AndroidRuntime(28748):    at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
12-07 17:33:12.113: E/AndroidRuntime(28748):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
12-07 17:33:12.113: E/AndroidRuntime(28748):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
12-07 17:33:12.113: E/AndroidRuntime(28748):    at android.app.ActivityThread.-wrap11(ActivityThread.java)
12-07 17:33:12.113: E/AndroidRuntime(28748):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
12-07 17:33:12.113: E/AndroidRuntime(28748):    at android.os.Handler.dispatchMessage(Handler.java ...
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-12-07 13:38:39 -0700

praveenb gravatar image

If you are looking to build SimpleClient.apk from the command line, you can do the fillowing:

  1. Unpack the AllJoyn Android SDK

  2. Change directory to java/samples/simple/client

  3. android update project -t android-23 -p . -n SimpleClient (Use an appropriate API Level, instead of 23)

  4. ant debug or ant release (needless to add, supply the app signing key when using release)

One thing to verify is if libs/alljoyn.jar and libs/armeabi/liballjoyn_java.so are accessible. Also, you can confirm that the JNI library is packaged correctly in your apk by: jar tvf SimpleClient.apk or unzip -l SimpleClient.apk.

edit flag offensive delete publish link more


Hi Praveenb, The steps you provided are workable. But may I ask you how to modify my Android.mk to make SimpleClient.apk running in the Android device successfully? Thanks a lot.

fengying.chu ( 2015-12-08 01:22:37 -0700 )edit

Unfortunately, I am unaware of using Android.mk to create an apk. To the best of my knowledge, Android.mk files (make-based builds) are used to create C/C++ Native libraries using Android NDK. The apks, which are Java applications are always built using ant / gradle.

praveenb ( 2015-12-16 12:46:47 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-12-07 02:04:57 -0700

Seen: 1,574 times

Last updated: Dec 07 '15