Building System App With Prebuilt .so Library - android

I've been stuck here for a week trying to build a 3rd party .so library along with my app into custom Android system. I followed http://www.maxters.net/2012/05/adding-prebuilt-shared-library-to-android-build-system/ and successfully add the .so lib as prebuilt shared library to Android Build System. Now I can see the .so lib at ../out/target/product/crespo4g/obj/lib/.
But the libraries in this directory are not going to be migrated to device when flashing. And my .so lib is not appeared at /data/data/my_app_name/lib either. So UnsatisfiedLinkError occurs when executing System.loadLibrary().
I thought there are three ways to solve this, but just don't know how to implement:
Maybe my app failed to indicate to compiler that my .so is along with my app as a whole, so the .so lib is not compiled into the system image with my app. But I did declare by "LOCAL_STATIC_LIBRARIES := libXX", anything wrong?
Is there a way to build my .so lib into /system/lib/? Where are the so libs under /system/lib/ derived from?
I am new to Android building, please help..
Thanks!

You might want to check you makefile against advice in this answer and this one as well as the advice in this groups thread
UPDATE
My original makefile was incorrect but this does work for me building ICS:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libmozglue
LOCAL_SRC_FILES := libmozglue.so
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := libplugin-container
LOCAL_SRC_FILES := libplugin-container.so
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
where the above are the native libraries required by firefox for android that I include as a system app in my custom system build.

Related

Add libstagefright in my Android NDK Application

I made some changes in AOSP code and compiled it. Now i want to Add created libstagefright.so in my Applicaton.
In Android.mk i'm adding as LOCAL_SRC_FILES compiled libstagefright.so library with path.
Here is it`
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libstagefright
LOCAL_SRC_FILES := ./Source/out/target/product/generic/system/lib/libstagefright.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := example
LOCAL_SRC_FILES := example.cpp
LOCAL_LDLIBS := -llog-landroid
LOCAL_SHARED_LIBRARIES := libstagefright
include $(BUILD_SHARED_LIBRARY)
When i'm building and running program I don't see any changes in library.What is the Problem that i don't see any changes?
Thanks in advance.
Instead of libstagefright.so, you can build the AOSP-derived library as libmybetterstagefrght.so and use it in your app instead of stagefright. You can put your library in your libs folder just like any other library. You don't need root for that.
Note that the library you build will still connect to many OMX and other binaries in /system/lib, so all interfaces should be maintained. You probably want to start with the AOSP revision that corresponds to the system level of your device. You may face compatibility problems if the device uses a customized Android - for best results, take a Nexus device.

Build Android from Source - Add Prebuilt App with Shared Library

i've build my own androidrom from source and modified a few things.
But now i wan't to add an prebuilt .apk to the project,
read that i should make an folder in /packages/apps/
and add the .apk and an Android.mk to it with following code
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := <folder name>
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
and the added the module to the in my case /device/sony/honami/full_honami.mk
when i now run brunch i get the error after some time that no rule for target *
so i tried some changes but nothing works for me and i can't find something where there write something other than this ...
so i added the .apk to the /vendor/cm/prebuilts folder and in the *.mk where i found the other .apks where copyed to the device i added my app and run brunch without an error.
But when i now start the app, which is on the device, it crash.
Via Logcat i found out that this apk have some .so files in it and that it can't find them.
This is because i only copied the app not the .so files in the lib directory. But i can't find some solution for my problem.
Should i now extract the .so file and copy it like the .apk to the path the app looks? or is there a better solution for doing this?
Cheers
Moritz
AOSP build system handles the shared libraries differently from Eclipse-ADT.
You will need to extract that .so from your apk and create an Android.mk to it.
To extract the .so, just unzip the apk and get it from libs folder.
Here is an example for the Android.mk to libfoo.so shared library:
LOCAL_PATH:= $(call my-dir)
# prebuilt shared library
include $(CLEAR_VARS)
LOCAL_MODULE := libfoo
LOCAL_SRC_FILES := libfoo.so
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)

Integrate android support library into froyo platform

I'm working on an android image for a multimedia set top box. Since it is Froyo, I have to use the android support library to get fragments. Now, instead of including the library in every app, it would be much cleaner to integrate it into the android framework. I would also save some space.
I'm thinking of something like dexing the library and copying it to a specific location (, if that is possible at all).
Can you please give me some hints how to achieve this? Since the make system is not so well documented, a makefile would be even better.
Edit: I'm following pskinks approach to add the support library as framework lib. I have a make file, which copies the dexed support lib to /system/framework/android.support.v4.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# Copy the support library
# This will install the file as /system/framework/android.support.v4
LOCAL_MODULE:= android.support.v4
LOCAL_SRC_FILES := android-support-v4.dex.jar
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)
LOCAL_CERTIFICATE := platform
include $(BUILD_PREBUILT)
I also added the lib to the platform.xml file:
<library name="android.support.v4"
file="/system/framework/android.support.v4"/>
But, when the build process gets to the apps, which link against the lib, they fail, because the classes of the support lib are not available.
Here is the makefile of one of the apps:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := AppManager
LOCAL_JAVA_LIBRARIES := android.support.v4
LOCAL_CERTIFICATE := shared
include $(BUILD_PACKAGE)
I also added the lib to manifest:
<uses-library android:name="android.support.v4" android:required="true" />
What else do I have to do, that the build process knows about the library?
see this http://groups.google.com/group/android-developers/browse_thread/thread/7390b16854ac0dfa, i think it should work pretty the same on your stb

NDK: using user created .so when trying to build another .so

I'm trying to link some .so that I generated using the NDK to a new .so I'm trying to create,
as the old .so contains definitions of functions that I want to use in the new .so.
I've tried this Android.mk :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := prog_test
LOCAL_SRC_FILES := main.c
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES += mylib
include $(BUILD_SHARED_LIBRARY)
$(call import-module,<tag>) # with and without
I've also tried this method I found in stackoverflow NDK - How to use a generated .so library in another project but still no succes as I get always :
prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lmylib.so
I really appreciate any help to solve this issue.
B.R
you have to use include $(PREBUILD_SHARED_LIBRARY) instead of include $(BUILD_SHARED_LIBRARY)

Using a third party .a library in Android ndk app

We are trying to use a third party .a static library in our Android app. The .a lib is built for x86 and we used it with a PC linux box without problem.
Then we try to use it on Android with this Android.mk:
LOCAL_PATH:= $(call my-dir)
# first lib, which will be built statically
#
include $(CLEAR_VARS)
LOCAL_MODULE := libtwolib-first
LOCAL_SRC_FILES := rwl.a
LOCAL_MODULE_SUFFIX := .a
include $(PREBUILT_STATIC_LIBRARY)
# second lib, which will depend on and include the first one
#
include $(CLEAR_VARS)
LOCAL_MODULE := libtwolib-second
LOCAL_SRC_FILES := second.c
LOCAL_STATIC_LIBRARIES := libtwolib-first
include $(BUILD_SHARED_LIBRARY)
We get this error:
could not read symbols: File in wrong format
Is it because the .a file is compiled with x86 and we are building for arm?
The .a file is a legacy and most likely can't be recompiled from source. If this is the issue, is there any other solution?
Thanks.
You need to obtain the source for the third-party lib and cross-compile it to native Android's NDK such that its binary compatible.
Simply dropping an x86 static lib into Android's NDK build will just not work.

Categories

Resources