How to import android.arch.lifecycle in AOSP - android

I am trying to build my APP in AOSP with Android.mk on Android 8.1. I uses MVVM architecture which requires the package "android.arch.lifecycle". When compiling the codes, i encourtered the error:
The import android.arch.lifecycle.LiveData cannot be resolved
Here is my Android.mk:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, java)
LOCAL_PRIVATE_PLATFORM_APIS := true
#LOCAL_STATIC_ANDROID_LIBRARIES := \
# android-arch-core-runtime \
# android-arch-lifecycle-extensions
#LOCAL_SHARED_JAVA_LIBRARIES := \
# android-arch-lifecycle-common
#
#LOCAL_SHARED_ANDROID_LIBRARIES := \
# android-arch-lifecycle-runtime
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-design \
android-support-v4 \
android-support-v7-appcompat \
android-support-v7-recyclerview \
android-support-v7-cardview \
android-support-v7-preference \
android-support-transition \
android-support-v14-preference \
constraint-layout-solver \
volley \
XXFwUpdateCore
LOCAL_JAVA_LIBRARIES := \
core-oj \
XXDeviceAdminSDK
LOCAL_RESOURCE_DIR := \
$(TOP)/frameworks/support/design/res \
$(TOP)/frameworks/support/v7/appcompat/res \
$(TOP)/frameworks/support/v7/cardview/res \
$(TOP)/frameworks/support/v7/recyclerview/res \
$(TOP)/frameworks/support/v7/preference/res \
$(TOP)/frameworks/support/v14/preference/res \
$(LOCAL_PATH)/res
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.design \
--extra-packages android.support.v7.appcompat \
--extra-packages android.support.v7.recyclerview \
--extra-packages android.support.v7.cardview \
--extra-packages android.support.v14.recyclerview \
--extra-packages android.support.v7.preference \
--extra-packages android.support.v14.preference \
--extra-packages android.support.constraint \
--extra-packages com.android.settingslib
LOCAL_AAPT_FLAGS += --rename-manifest-package XX.com.firmwareupdate
LOCAL_STATIC_JAVA_AAR_LIBRARIES := \
constraint-layout
LOCAL_PACKAGE_NAME := XXFirmwareAgent
LOCAL_PROGUARD_FLAGS := -include $(LOCAL_PATH)/proguard.flag
#LOCAL_DEX_PREOPT := false
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_REQUIRED_MODULES := privapp-permissions-XX.com.firmwareupdate.xml
LOCAL_JNI_SHARED_LIBRARIES := libvendorlibproxy
LOCAL_MODULE_INCLUDE_LIBRARY := true
LOCAL_REQUIRED_MODULES += libvendorlibproxy
LOCAL_REQUIRED_MODULES += XXFwUpdateCore
LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_MODULE := privapp-permissions-XX.com.firmwareupdate.xml
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
include $(LOCAL_PATH)/jni/Android.mk
include $(LOCAL_PATH)/../../../../fwupatecore/src/main/Android.mk
include $(call all-makefiles-under,$(LOCAL_PATH))
#include $(CLEAR_VARS)
#LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := constraint-layout-solver:../../libs/constraint-layout-solver-1.0.2.jar
#include $(BUILD_MULTI_PREBUILT)
#include $(CLEAR_VARS)
#LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := constraint-layout:../../libs/constraint-layout-1.0.2.aar
#include $(BUILD_MULTI_PREBUILT)
Thanks.
Thanks.
Thanks.
Thanks.Thanks.

You have not added the JAR / AAR dependency for the said lib

Related

How to import a .so Library in Android.mk when i build APK

I have this problem: I have to build my app using the Android.mk file and I have to insert the library "libcom_google_ase_Exec.so" inside the final apk, but I can't do it. What I get is an APK that doesn't contain the library and therefore the app doesn't work.
The code for the Android.mk I'm currently using is:
#ifneq ($(TARGET_BUILD_PDK), true)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := com_google_ase_Exec
LOCAL_SRC_FILES := app/src/main/jniLibs/armeabi/libcom_google_ase_Exec.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := Sshd
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_MODULE_TAGS := samples
LOCAL_USE_AAPT2 := true
LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/java)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/app/src/main/res/
LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
# LOCAL_ASSETS_DIR := $(LOCAL_PATH)/assets
LOCAL_STATIC_ANDROID_LIBRARIES += \
android-support-v13 \
android-support-v7-cardview \
android-support-v7-recyclerview \
android-support-annotations
LOCAL_STATIC_JAVA_LIBRARIES := \
libsshd-core \
libsshd-common \
libsshd-scp \
libsshd-sftp \
libslf4j \
libbcpkix \
libbcprov
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
LOCAL_SHARED_LIBRARIES := libcom_google_ase_Exec
#LOCAL_PREBUILTS := com_google_ase_Exec
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
libsshd-core:app/libs/sshd-core-2.8.0.jar \
libsshd-common:app/libs/sshd-common-2.8.0.jar \
libsshd-scp:app/libs/sshd-scp-2.8.0.jar \
libsshd-sftp:app/libs/sshd-sftp-2.8.0.jar \
libslf4j:app/libs/slf4j-api-1.7.35.jar \
libbcpkix:app/libs/bcpkix-jdk15on-1.70.jar \
libbcprov:app/libs/bcprov-jdk15on-1.70.jar
include $(BUILD_MULTI_PREBUILT)
#include $(call all-makefiles-under, $(LOCAL_PATH))
#endif
The folder structure within my project is as follows:
In the root i have:
--> /app and Android.mk
In the app folder i have:
--> app/src/main/jniLibs/armeabi/libcom_google_ase_Exec.so
How can i change the Android.mk file to import the .so library in the final APK?
#ifneq ($(TARGET_BUILD_PDK), true)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := Sshd
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_MODULE_TAGS := samples
LOCAL_USE_AAPT2 := true
LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/java)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/app/src/main/res/
LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
# LOCAL_ASSETS_DIR := $(LOCAL_PATH)/assets
LOCAL_STATIC_ANDROID_LIBRARIES += \
android-support-v13 \
android-support-v7-cardview \
android-support-v7-recyclerview \
android-support-annotations
LOCAL_STATIC_JAVA_LIBRARIES := \
libsshd-core \
libsshd-common \
libsshd-scp \
libsshd-sftp \
libslf4j \
libbcpkix \
libbcprov
LOCAL_JNI_SHARED_LIBRARIES := libcom_google_ase_Exec
#LOCAL_MULTILIB = 32
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_ENABLED := disabled
#LOCAL_UNINSTALLABLE_MODULE := true
#LOCAL_DEX_PREOPT := false
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_CERTIFICATE := platform
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
libsshd-core:app/libs/sshd-core-2.8.0.jar \
libsshd-common:app/libs/sshd-common-2.8.0.jar \
libsshd-scp:app/libs/sshd-scp-2.8.0.jar \
libsshd-sftp:app/libs/sshd-sftp-2.8.0.jar \
libslf4j:app/libs/slf4j-api-1.7.35.jar \
libbcpkix:app/libs/bcpkix-jdk15on-1.70.jar \
libbcprov:app/libs/bcprov-jdk15on-1.70.jar
include $(BUILD_MULTI_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := libcom_google_ase_Exec
LOCAL_MODULE_TAGS := samples
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := app/src/main/jniLibs/armeabi/libcom_google_ase_Exec.so
#LOCAL_MULTILIB = 32
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX = .so
include $(BUILD_PREBUILT)
#include $(call all-makefiles-under, $(LOCAL_PATH))
#endif
I solved in this way, i build a 64bit version.
If u need a 32bit version u can uncomment all LOCAL_MULTILIB = 32.

alsa-utils + ndk-build not working

I have source code alsa-utils-1.0.27.2 from http://www.alsa-project.org/main/index.php/Main_Page
I need for build it to my android:
user#vbUbuntu1204:~/Android-alsa/alsa-utils$ cat jni/Android.mk
ifeq ($(strip $(BOARD_USES_ALSA_AUDIO)),true)
ifeq ($(strip $(BUILD_WITH_ALSA_UTILS)),true)
LOCAL_PATH:= $(call my-dir)
#
# Build aplay command
#
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-fPIC -D_POSIX_SOURCE \
-DALSA_CONFIG_DIR=\"/system/usr/share/alsa\" \
-DALSA_PLUGIN_DIR=\"/system/usr/lib/alsa-lib\" \
-DALSA_DEVICE_DIRECTORY=\"/dev/snd/\"
LOCAL_C_INCLUDES:= \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/android \
external/alsa-lib/include
LOCAL_SRC_FILES := \
aplay/aplay.c
LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := alsa_aplay
LOCAL_SHARED_LIBRARIES := \
libaudio \
libc
include $(BUILD_EXECUTABLE)
#
# Build alsactl command
#
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-fPIC -D_POSIX_SOURCE \
-DALSA_CONFIG_DIR=\"/system/usr/share/alsa\" \
-DALSA_PLUGIN_DIR=\"/system/usr/lib/alsa-lib\" \
-DALSA_DEVICE_DIRECTORY=\"/dev/snd/\"
LOCAL_C_INCLUDES:= \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/android \
external/alsa-lib/include
LOCAL_SRC_FILES := \
alsactl/alsactl.c \
alsactl/init_parse.c \
alsactl/state.c \
alsactl/utils.c
LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := alsa_ctl
LOCAL_SHARED_LIBRARIES := \
libaudio \
libc
include $(BUILD_EXECUTABLE)
#
# Build amixer command
#
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-fPIC -D_POSIX_SOURCE \
-DALSA_CONFIG_DIR=\"/system/usr/share/alsa\" \
-DALSA_PLUGIN_DIR=\"/system/usr/lib/alsa-lib\" \
-DALSA_DEVICE_DIRECTORY=\"/dev/snd/\"
LOCAL_C_INCLUDES:= \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/android \
external/alsa-lib/include
LOCAL_SRC_FILES := \
amixer/amixer.c
LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := alsa_amixer
LOCAL_SHARED_LIBRARIES := \
libaudio \
libc
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
ALSAINIT_DIR := $(TARGET_OUT)/usr/share/alsa/init
files := $(addprefix $(ALSAINIT_DIR)/,00main default hda help info test)
$(files): PRIVATE_MODULE := alsactl_initdir
$(files): $(ALSAINIT_DIR)/%: $(LOCAL_PATH)/alsactl/init/% | $(ACP)
$(transform-prebuilt-to-target)
ALL_PREBUILT += $(files)
endif
endif
user#vbUbuntu1204:~/Android-alsa/alsa-utils$ cat jni/Application.mk
APP_PROJECT_PATH := /home/user/Android-alsa/alsa-utils/
NDK_PROJECT_PATH := ~/android-ndk-r9d/
user#vbUbuntu1204:~/Android-alsa/alsa-utils$
../../android-ndk-r9d/ndk-build
/home/user/android-ndk-r9d/build/core/build-all.mk:89: Android NDK:
WARNING: There are no modules to build in this project!
How to correct thish?

android.mk LOCAL_MODULE_FILENAME should not contain extensions

i am trying to build some of the files from libavcodec and libavutil
Following this, i created Android.mk file as below :
jni/Android.mk contains
LOCAL_PATH := $(call my-dir)
FFMPEG_TOP := $(LOCAL_PATH)
include $(CLEAR_VARS)
include $(FFMPEG_TOP)/libavutil/Android.mk
include $(FFMPEG_TOP)/libavcodec/Android.mk
LOCAL_PATH := $(FFMPEG_TOP)
LOCAL_MODULE := mylib
LOCAL_ARM_MODE := arm # remove this if you want thumb mode
LOCAL_SRC_FILES := myfunc1.c myfunc2.c maincfunction.c 3rdparty1.c 3rdparty2.c
LOCAL_SRC_FILES += libavcodec.a libavutil.a
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
jni/libavcodec/Android.mk contains
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
SOURCE_H264_DECODER += h264.c h264idct.c h264pred.c h264_parser.c cabac.c
SOURCE_H264_ENCODER += h264enc.c h264dspenc.c
SOURCE_HAVE_ARM = \
arm/dsputil_arm.c \
arm/dsputil_arm_s.S \
arm/jrevdct_arm.S \
arm/mpegvideo_arm.c \
arm/simple_idct_arm.S
SOURCE_HAVE_ARMV5TE = \
arm/mpegvideo_armv5te.c \
arm/mpegvideo_armv5te_s.S \
arm/simple_idct_armv5te.S
SOURCE_HAVE_ARMVFP = \
arm/dsputil_vfp.S \
arm/float_arm_vfp.S
SOURCE_HAVE_ARMV6 = arm/simple_idct_armv6.S
LOCAL_SRC_FILES := \
allcodecs.c \
audioconvert.c \
bitstream.c \
bitstream_filter.c \
dsputil.c \
eval.c \
faanidct.c \
imgconvert.c \
jrevdct.c \
opt.c \
options.c \
parser.c \
raw.c \
resample.c \
resample2.c \
simple_idct.c \
utils.c
LOCAL_SRC_FILES += $(SOURCE_H263_ENCODER)
LOCAL_SRC_FILES += $(SOURCE_H264_DECODER)
LOCAL_SRC_FILES += $(SOURCE_HAVE_ARM)
LOCAL_SRC_FILES += $(SOURCE_HAVE_ARMV5TE)
LOCAL_SRC_FILES += $(SOURCE_HAVE_ARMVFP)
LOCAL_MODULE := libavcodec
LOCAL_PRELINK_MODULE := false
LOCAL_C_INCLUDES := \
$(FFMPEG_TOP)/ \
$(FFMPEG_TOP)/libavutil/ \
$(LOCAL_PATH) \
$(LOCAL_PATH)/arm/
LOCAL_CFLAGS += -O4 -mno-thumb-interwork -mno-thumb -marm -DHAVE_AV_CONFIG_H
include $(BUILD_STATIC_LIBRARY)
jni/libavutil/Android.mk contains
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
adler32.c \
aes.c \
avstring.c \
base64.c \
crc.c \
des.c \
fifo.c \
intfloat_readwrite.c \
lfg.c \
lls.c \
log.c \
lzo.c \
mathematics.c \
md5.c \
mem.c \
random.c \
random_seed.c \
rational.c \
rc4.c \
sha1.c \
tree.c \
utils.c
LOCAL_MODULE := libavutil
LOCAL_PRELINK_MODULE := false
LOCAL_C_INCLUDES := \
$(FFMPEG_TOP)/ \
$(LOCAL_PATH) \
$(LOCAL_PATH)/arm/
LOCAL_CFLAGS += -O4 -mno-thumb-interwork -mno-thumb -marm -DHAVE_AV_CONFIG_H
include $(BUILD_STATIC_LIBRARY)
The problem addressed here is not relavant to what i am facing, though the error is similar.
The error i got is:
Android NDK: jni/inner/Android.mk:mylib: LOCAL_MODULE_FILENAME should not include file extensions
Android NDK: jni/inner/Android.mk:mylib: LOCAL_MODULE_FILENAME must not contain a file extension
Please help!!
[So often i am meeting headless problems!!]
You need to ensure that you call include $(CLEAR_VARS) after you include the make files which build your static libs. The auto generation of the module file name only works if that variable is empty, and your previous make file includes end up defining it when you call $include ($BUILD_STATIC_LIBRARY)
Try using LOCAL_MODULE_FILENAME := libavcodec LOCAL_MODULE_FILENAME += libavutil instead of LOCAL_SRC_FILES += libavcodec.a libavutil.a in your jni/Android.mk.

Unable to compile harfbuz_ng library using NDK

I am developing an application in which i am using indic-text-renderer for devnagri text renderering.As this is NDK library;i am trying to compile it using ndk-build command.
But it gives me following error:
Android NDK: Trying to define local module 'harfbuzz_ng' in /cygdrive/d/Project_WorkSpace/indic-text-renderer//jni/harfbuzz-ng/Android.mk.
Android NDK: But this module was already defined by /cygdrive/d/Project_WorkSpace/indic-text-renderer//jni/harfbuzz-ng/Android.mk.
My android.mk file is:
LOCAL_PATH := $(call my-dir)
MY_LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := complex-script-rendering
LOCAL_C_INCLUDES := $(LOCAL_PATH)/freetype/include $(LOCAL_PATH)/harfbuzz-ng/src
LOCAL_SRC_FILES := complex-script-rendering.c
LOCAL_STATIC_LIBRARIES := ft2 harfbuzz
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
include $(MY_LOCAL_PATH)/freetype/Android.mk
include $(MY_LOCAL_PATH)/harfbuzz-ng/Android.mk
How can i resolve this error?
I am very new to the NDK programming,so pls let me know if this information is not sufficient
Edit:
freetype/Android.mk
ifndef USE_FREETYPE
USE_FREETYPE := 2.4.2
endif
ifeq ($(USE_FREETYPE),2.4.2)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# compile in ARM mode, since the glyph loader/renderer is a hotspot
# when loading complex pages in the browser
#
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES:= \
src/base/ftbbox.c \
src/base/ftbitmap.c \
src/base/ftfstype.c \
src/base/ftglyph.c \
src/base/ftlcdfil.c \
src/base/ftstroke.c \
src/base/fttype1.c \
src/base/ftxf86.c \
src/base/ftbase.c \
src/base/ftsystem.c \
src/base/ftinit.c \
src/base/ftgasp.c \
src/raster/raster.c \
src/sfnt/sfnt.c \
src/smooth/smooth.c \
src/autofit/autofit.c \
src/truetype/truetype.c \
src/cff/cff.c \
src/psnames/psnames.c \
src/pshinter/pshinter.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/builds \
$(LOCAL_PATH)/include
LOCAL_CFLAGS += -W -Wall
LOCAL_CFLAGS += -fPIC -DPIC
LOCAL_CFLAGS += "-DDARWIN_NO_CARBON"
LOCAL_CFLAGS += "-DFT2_BUILD_LIBRARY"
# the following is for testing only, and should not be used in final builds
# of the product
#LOCAL_CFLAGS += "-DTT_CONFIG_OPTION_BYTECODE_INTERPRETER"
LOCAL_CFLAGS += -O2
LOCAL_MODULE:= libft2
include $(BUILD_STATIC_LIBRARY)
endif
harfbuzz-ng/android.mk
LOCAL_PATH:= $(call my-dir)
HARFBUZZ_SRC_FILES = \
src/hb-blob.cc \
src/hb-buffer-serialize.cc \
src/hb-buffer.cc \
src/hb-common.cc \
src/hb-fallback-shape.cc \
src/hb-face.cc \
src/hb-font.cc \
src/hb-ot-tag.cc \
src/hb-set.cc \
src/hb-shape.cc \
src/hb-shape-plan.cc \
src/hb-shaper.cc \
src/hb-tt-font.cc \
src/hb-unicode.cc \
src/hb-warning.cc \
src/hb-ot-layout.cc \
src/hb-ot-map.cc \
src/hb-ot-shape.cc \
src/hb-ot-shape-complex-arabic.cc \
src/hb-ot-shape-complex-default.cc \
src/hb-ot-shape-complex-indic.cc \
src/hb-ot-shape-complex-indic-table.cc \
src/hb-ot-shape-complex-myanmar.cc \
src/hb-ot-shape-complex-sea.cc \
src/hb-ot-shape-complex-thai.cc \
src/hb-ot-shape-normalize.cc \
src/hb-ot-shape-fallback.cc
#############################################################
# build the harfbuzz library
#
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
$(HARFBUZZ_SRC_FILES) \
src/hb-icu.cc
LOCAL_CPP_EXTENSION := .cc
LOCAL_SHARED_LIBRARIES := \
libcutils \
libicuuc \
libicui18n \
libutils
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/src \
external/icu4c/common
LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_ICU
LOCAL_LDLIBS += -lpthread
LOCAL_MODULE:= libharfbuzz_ng
include $(BUILD_SHARED_LIBRARY)
#############################################################
# build the harfbuzz static library
#
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
$(HARFBUZZ_SRC_FILES) \
src/hb-ucdn.cc \
src/hb-ucdn/ucdn.c
LOCAL_CPP_EXTENSION := .cc
LOCAL_STATIC_LIBRARIES := libft2
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/src \
external/freetype/include
LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_UCDN -DHAVE_FREETYPE
LOCAL_LDLIBS += -lpthread
LOCAL_MODULE:= libharfbuzz_ng
include $(BUILD_STATIC_LIBRARY)
I tried removing the entire BUILD_SHARED_LIBRARY block and it stopped complaining about re-defining problem,because I wanted to compile harfbuzz-ng just as a static library. You may give it a try.
The last time I got this error,is when I cross compile freetype and use it as a PRE-built static library in my project,I exported the NDK-MODULE-PATH and yet there's a line in my jni/Android.mk written include $(MY_LOCAL_PATH)/freetype/Android.mk
So I just comment out this line and everything works fine.
Because when you set NDK-MODULE-PATH , the compiler will look into your PATH directory and search for Android.mk and compile the source with it. please reference this,and I hope it will help you .
my jni/Android.mk looks like this:
LOCAL_PATH := $(call my-dir)
MY_LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := complex-script-rendering
LOCAL_C_INCLUDES := $(LOCAL_PATH)/freetype/include $(LOCAL_PATH)/harfbuzz-ng/src
LOCAL_SRC_FILES := complex-script-rendering.c
LOCAL_STATIC_LIBRARIES := libfreetype libharfbuzz
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
$(call import-module,freetype)
#include $(MY_LOCAL_PATH)/freetype/Android.mk
include $(MY_LOCAL_PATH)/harfbuzz-ng/Android.mk
and harfbuzz-ng/Android.mk:
LOCAL_PATH:= $(call my-dir)
HARFBUZZ_SRC_FILES = \
src/hb-blob.cc \
src/hb-buffer-serialize.cc \
src/hb-buffer.cc \
src/hb-common.cc \
src/hb-fallback-shape.cc \
src/hb-face.cc \
src/hb-font.cc \
src/hb-ot-tag.cc \
src/hb-ft.cc \
src/hb-set.cc \
src/hb-shape.cc \
src/hb-shape-plan.cc \
src/hb-shaper.cc \
src/hb-tt-font.cc \
src/hb-unicode.cc \
src/hb-warning.cc \
src/hb-ot-layout.cc \
src/hb-ot-map.cc \
src/hb-ot-shape.cc \
src/hb-ot-shape-complex-arabic.cc \
src/hb-ot-shape-complex-default.cc \
src/hb-ot-shape-complex-indic.cc \
src/hb-ot-shape-complex-indic-table.cc \
src/hb-ot-shape-complex-myanmar.cc \
src/hb-ot-shape-complex-sea.cc \
src/hb-ot-shape-complex-thai.cc \
src/hb-ot-shape-normalize.cc \
src/hb-ot-shape-fallback.cc
#############################################################
# build the harfbuzz library
#
#
#include $(CLEAR_VARS)
#
#LOCAL_ARM_MODE := arm
#
#LOCAL_MODULE_TAGS := optional
#
#LOCAL_SRC_FILES:= \
# $(HARFBUZZ_SRC_FILES) \
# src/hb-icu.cc
#
#LOCAL_CPP_EXTENSION := .cc
#
#LOCAL_SHARED_LIBRARIES := \
# libcutils \
# libicuuc \
# libicui18n \
# libutils
#
#LOCAL_C_INCLUDES += \
# $(LOCAL_PATH)/src \
# external/icu4c/common
#
#LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_ICU
#
#LOCAL_LDLIBS += -lpthread
#
#LOCAL_MODULE:= libharfbuzz_ng
#
#include $(BUILD_SHARED_LIBRARY)
#############################################################
# build the harfbuzz static library
#
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
$(HARFBUZZ_SRC_FILES) \
src/hb-ucdn.cc \
src/hb-ucdn/ucdn.c
LOCAL_CPP_EXTENSION := .cc
LOCAL_STATIC_LIBRARIES := libfreetype
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/hb-ucdn \
external/freetype/include
LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_UCDN -DHAVE_FREETYPE
LOCAL_LDLIBS += -lpthread
LOCAL_MODULE:= libharfbuzz
include $(BUILD_STATIC_LIBRARY)
and I have a build.sh file in my jni directory,which will exort my freetype module,quite simple:
export NDK_MODULE_PATH=/home/***/workspace/indic-text-renderer/jni
ndk-build
Besides all this, you will have to cross-compile freetype library.
Wish you good luck, it costs me almost a week.

Issue trying to build PocketSphinx for Android using the NDK on Windows with Cygwin

I'm currently trying to build the PocketSphinx library for Android using the NDK on Windows with Cygwin. I have the PocketSphinxAndroidDemo project code. I also have the pocketsphinx and shpinxbase projects as sub folders of the E:/Development/CMUSphinx folder.
I'm trying to build using ndk-build from the project folder. The Android.mk file in the /jni/ folder of the project looks like this -
# Build the native component of the PocketSphinx library for Android.
# You MUST change this to the absolute path of the directory containing
# sphinxbase and pocketsphinx source code.
SPHINX_PATH := E:/Development/CMUSphinx
# Copy this Android.mk along with pocketsphinx_wrap.c and the contents of the 'edu' folder
# built by swig to the jni/ directory of your Android project.
BASE_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK
LOCAL_PATH := $(SPHINX_PATH)/sphinxbase/src/libsphinxbase/util
LOCAL_MODULE := sphinxutil
LOCAL_SRC_FILES := \
bio.c \
bitvec.c \
case.c \
ckd_alloc.c \
cmd_ln.c \
dtoa.c \
err.c \
errno.c \
f2c_lite.c \
filename.c \
genrand.c \
glist.c \
hash_table.c \
heap.c \
huff_code.c \
info.c \
listelem_alloc.c \
logmath.c.arm \
matrix.c \
mmio.c \
pio.c \
profile.c \
sbthread.c \
strfuncs.c \
utf8.c
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK
LOCAL_PATH := $(SPHINX_PATH)/sphinxbase/src/libsphinxbase/fe
LOCAL_MODULE := sphinxfe
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES := \
fe_interface.c \
fe_sigproc.c \
fe_warp_affine.c \
fe_warp.c \
fe_warp_inverse_linear.c \
fe_warp_piecewise_linear.c \
fixlog.c
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK
LOCAL_PATH := $(SPHINX_PATH)/sphinxbase/src/libsphinxbase/feat
LOCAL_MODULE := sphinxfeat
LOCAL_SRC_FILES := \
agc.c \
cmn.c \
cmn_prior.c \
feat.c \
lda.c
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK
LOCAL_PATH := $(SPHINX_PATH)/sphinxbase/src/libsphinxbase/lm
LOCAL_MODULE := sphinxlm
LOCAL_SRC_FILES := \
fsg_model.c \
jsgf.c \
jsgf_parser.c \
jsgf_scanner.c \
lm3g_model.c \
ngram_model_arpa.c \
ngram_model_dmp.c \
ngram_model_set.c \
ngram_model.c
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include \
$(SPHINX_PATH)/pocketsphinx/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK
LOCAL_PATH := $(SPHINX_PATH)/pocketsphinx/src/libpocketsphinx
LOCAL_MODULE := pocketsphinx
LOCAL_SRC_FILES := \
acmod.c \
bin_mdef.c \
blkarray_list.c \
dict.c \
dict2pid.c \
fsg_history.c \
fsg_lextree.c \
fsg_search.c \
hmm.c.arm \
mdef.c \
ms_gauden.c.arm \
ms_mgau.c.arm \
ms_senone.c.arm \
ngram_search.c \
ngram_search_fwdtree.c \
ngram_search_fwdflat.c \
phone_loop_search.c \
pocketsphinx.c \
ps_lattice.c \
ps_mllr.c \
ptm_mgau.c.arm \
s2_semi_mgau.c.arm \
tmat.c \
vector.c
include $(BUILD_STATIC_LIBRARY)
# Create the dynamic library wrapper
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include \
$(SPHINX_PATH)/pocketsphinx/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK
LOCAL_PATH := $(BASE_PATH)
LOCAL_MODULE := pocketsphinx_jni
LOCAL_SRC_FILES := pocketsphinx_wrap.c
PRIVATE_WHOLE_STATIC_LIBRARIES := \
$(call static-library-path,sphinxutil) \
$(call static-library-path,sphinxfe) \
$(call static-library-path,sphinxfeat) \
$(call static-library-path,sphinxlm) \
$(call static-library-path,pocketsphinx)
LOCAL_STATIC_LIBRARIES := sphinxutil sphinxfe sphinxfeat sphinxlm pocketsphinx
include $(BUILD_SHARED_LIBRARY)
When I run the ndk-build command I get the following error:
build-binary.mk:197: *** target pattern contains no '%'. Stop.
I can build all the ndk samples just fine. Any clue what's causing this error? Many thanks in advance!
Jason, Edit jni/Android.mk file
Change Line 162 :
LOCAL_STATIC_LIBRARIES := sphinxutil sphinxfe sphinxfeat sphinxlm pocketsphinx
to :
LOCAL_STATIC_LIBRARIES := pocketsphinx sphinxlm sphinxfeat sphinxfe sphinxutil
That will resolve your issue.
Do you know if this project has been previously built using cygwin with success? Cygwin has a number of oddities, from the awkward combination of windows drive letters with unix paths, to interpreting an inadvertent double slash in an assembled path unusually, and more. You could try the /cygdrive/e/ type of path instead of a drive letter, but who knows if that will help.
Jason,
you have to change your sphinx path to cygwin format i.e without ":"
change
SPHINX_PATH := E:/Development/CMUSphinx
to
SPHINX_PATH := /cygdrive/e/Development/CMUSphinx
this will fix the error
I used following link for Building Pocketsphinx On Android On Windows
https://sites.google.com/site/opiatefuchs/home/pocketsphinxandroiddemo but it misses one step that #Hitesh mentioned about replacing LOCAL_STATIC_LIBRARIES in jni/Android.mk file and I was able to build to latest 0.8 version.. thanks #Hitesh

Categories

Resources