Adding prebuilt shared library to Android Build System

Last two days i was unable to do a neat eng build for my galaxy note from cyanogen source. I was running into errors like unable to find libUMP.so and libion.so while building exynos hal specifically libgralloc_ump.
I was applying dirty workaround copy libUMP.so and libion.so to libUMP.so and libion.so and build again.
Another neat way to do is add both lib as prebuilt shared library to build system. For that you need to create projects for each and add it to product package.let me show how to do that for libUMP

  1. create a folder named libUMP in external folder.
  2. copy libUMP.so to the folder
  3. create make file named Android.mk
  4. paste the content to Android.mk
  5. now add libUMP( LOCAL_MODULE value in Android.mk) to your product make file. in my case i will add this line to n7000.mk
  6. repeat same for libion dont forget to replace libUMP with libion also dont forget to copy corresponding library file.

Enjoy ROM building

  • CosmoDroid

    Thanx man…Did my work…!!! 😀

    • maxters

      🙂

  • Sumit Sharma

    in my case its showing error

    make: *** No rule to make target out/target/product/am335xevm_sk/obj/lib/ldpfpdd.so', needed by out/target/product/am335xevm_sk/obj/EXECUTABLES/fingerprint_intermediates/LINKED/fingerprint’. Stop.
    make: *** Waiting for unfinished jobs….
    target Strip: libgabi++ (out/target/product/am335xevm_sk/obj/lib/libgabi++.so)

    • maxters

      I am not sure what is ldpfpdd.so library if its a prebuilt library you have do exactly what i mentioned replacing libUMP with your library. Or please give more details

      • Sumit Sharma

        i have the prebuilts, .c and .h files in /external/fprint/ directory. i created an Android.mk in the same directory as

        ########### libdpfpdd ############
        LOCAL_PATH := $(call my-dir)
        include $(CLEAR_VARS)
        LOCAL_MODULE := ldpfpdd
        LOCAL_SRC_FILES := libdpfpdd.so
        LOCAL_MODULE_SUFFIX := .so
        LOCAL_MODULE_CLASS := SHARED_LIBRARIES
        #include $(PREBUILT_SHARED_LIBRARY)
        LOCAL_MODULE_TAGS := optional
        include $(BUILD_PREBUILT)

        ########### libdpfj ##############

        include $(CLEAR_VARS)
        LOCAL_MODULE := ldpfj
        LOCAL_SRC_FILES := libdpfj.so
        LOCAL_MODULE_SUFFIX := .so
        LOCAL_MODULE_CLASS := SHARED_LIBRARIES
        #include $(PREBUILT_SHARED_LIBRARY)
        LOCAL_MODULE_TAGS := optional
        include $(BUILD_PREBUILT)

        ######### fingerprint ############

        include $(CLEAR_VARS)
        LOCAL_MODULE_TAGS := optional
        LOCAL_MODULE := fingerprint
        LOCAL_SRC_FILES :=
        enrollment.c helpers.c identification.c
        menu.c sample.c selection.c verification.c
        LOCAL_SHARED_LIBRARIES += ldpfpdd ldpfj
        #LOCAL_LDLIBS += -ldpfpdd -ldpfj
        # local ldlibs are used to add some extra flags to the build environment
        # ldlibs includes the system libraries included in …./system/lib/
        # like libz can be included as -lz

        include $(BUILD_EXECUTABLE)

        and added the modules ldpfpdd, ldpfj and fingerprint in the PRODUCT_PACKAGE, and then i exported the variables and ran the cross compilation.

        • maxters

          can you try with changing LOCAL_MODULE to libldpfpdd and libldpfj. also modify LOCAL_SHARED_LIBRARIES in the executable as well

          • Sumit Sharma

            yup i got the first two .so in out directory but still running into error

            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: out/target/product/am335xevm_sk/obj/lib/libdpfpdd.so: unknown mandatory EABI object attribute 44
            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: out/target/product/am335xevm_sk/obj/lib/libdpfj.so: unknown mandatory EABI object attribute 44

          • Sumit Sharma

            please help me out to fix it…

          • maxters

            see this discussion https://groups.google.com/forum/?fromgroups#!topic/android-ndk/7IA6cyqYaLc
            seems like your library is compiled with a different IIRC attribute. Try using different versions of gcc. The discussion says that in gcc 4.4.3 it will be a waring. check your gcc flags weather warings are treated as error. Or get an updated prebuilt from vendor

  • Pingback: Building System App With Prebuilt .so Library | BlogoSfera()