How to compile AIDL files with android make file? - android

I need to compile a android project with make file, but it seems that cannot find aidl files.
here is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_OVERRIDE_SRC_FILES := $(call all-java-files-under, devices/$(TARGET_DEVICE))
LOCAL_SRC_FILES := $(call all-java-files-under, SDK src) \
src/com/skyworth/skyappstore/aidl/AppStoreCallBackAIDL \
src/com/skyworth/skyappstore/aidl/AppStoreServiceAIDL \
LOCAL_SRC_FILES := $(foreach f,$(LOCAL_SRC_FILES), \
$(if $(findstring $(f),$(LOCAL_OVERRIDE_SRC_FILES)),,$(f)))
# This is the target being built.
LOCAL_PACKAGE_NAME := APPStore
LOCAL_CERTIFICATE := shared
LOCAL_STATIC_JAVA_LIBRARIES := android fastjson jackson ksoap2 layoutlib tdcode
LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := android:android.jar \
fastjson:fastjson-1.1.32.jar \
jackson:jackson-all-1.9.8.jar \
ksoap2:ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar \
layoutlib:layoutlib.jar \
tdcode:tdcode.jar
include $(BUILD_MULTI_PREBUILT)
include $(call all-makefiles-under,$(LOCAL_PATH))
this returns that package com.skyworth.skyappstore.aidl does not exist, com.skyworth.skyappstore.aidlis the place where I place my aidl file.
So how to change the make file to compile this project right

Are AppStoreCallBackAIDL and AppStoreServiceAIDL aild files? Maybe you can change
LOCAL_SRC_FILES := $(call all-java-files-under, SDK src) \
src/com/skyworth/skyappstore/aidl/AppStoreCallBackAIDL \
src/com/skyworth/skyappstore/aidl/AppStoreServiceAIDL \
to this:
LOCAL_SRC_FILES := $(call all-java-files-under, SDK src) \
src/com/skyworth/skyappstore/aidl/AppStoreCallBackAIDL.aidl \
src/com/skyworth/skyappstore/aidl/AppStoreServiceAIDL.aidl \

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.

Unable to use third party Lib.aar in AOSP

I have made a aar library and added path: framework/base/packages/MyLib/MyLib.aar in AOSP.
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyLib
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_PREBUILT_MODULE_FILE := $(LOCAL_PATH)/MyLib.aar
include $(BUILD_PREBUILT)
When I add this lib in other application like Settings and it's working fine. But I want to use in framework/base/service/ in some java file. I am getting unable to import class file of that library.
I have added it in other apps Andropid.mk like LOCAL_STATIC_ANDROID_LIBRARIES := MyLib
This is my method to convert prebuilt aar to static android lib. It worked fine for me. You can refer this method for your situation.
include $(BUILD_PACKAGE)
######################## TuanPM13 #####################################
# add config to convert prebuilt aar to static android lib
#######################################################################
define aar-to-android-lib
$(foreach t,$(1), \
$(eval include $(CLEAR_VARS)) \
$(eval tw := $(subst :, ,$(strip $(t)))) \
$(eval LOCAL_MODULE := $(word 1,$(tw))) \
$(eval LOCAL_MODULE_TAGS := optional) \
$(eval LOCAL_SRC_FILES := $(word 2,$(tw))) \
$(eval LOCAL_RESOURCE_DIR := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/aar/res) \
$(eval LOCAL_USE_AAPT2 := true) \
$(eval LOCAL_RENDERSCRIPT_TARGET_API := $(2)) \
$(eval LOCAL_MODULE_CLASS := JAVA_LIBRARIES) \
$(eval LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)) \
$(eval LOCAL_BUILT_MODULE_STEM := javalib.jar) \
$(eval LOCAL_UNINSTALLABLE_MODULE := true) \
$(eval include $(BUILD_PREBUILT)) \
)
endef
prebuilt_aar_libraries := exoplayer-core:libs/exoplayer-core-2.10.8.aar \
exoplayer-ui:libs/exoplayer-ui-2.10.8.aar \
exoplayer-extension-mediasession:libs/extension-mediasession-2.10.8.aar
$(call aar-to-android-lib, $(prebuilt_aar_libraries), 28) # API level 28
prebuilt_aar_libraries :=
Noted that in my case, all *.arr were placed in libs directory.
Then in Android.mk of other applications, I link to them like below
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
...
LOCAL_STATIC_ANDROID_LIBRARIES += \
exoplayer-extension-mediasession \
exoplayer-ui \
exoplayer-core
include $(BUILD_PACKAGE)

How to convert Android.mk to CMake.txt?

This is how my Android.mk file looks like. What is the equivalent CMakeLists.txt? I am struggling to find libhardware in CMake. Any ideas?
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libtestLed
LOCAL_SRC_FILES := testled.cpp
LOCAL_C_INCLUDES := $(call include-path-for, libhardware)/hardware
LOCAL_SHARED_LIBRARIES += \
libandroid_runtime \
libcutils \
liblog \
libhardware \
LOCAL_MODULE_TAGS := optional
LOCAL_VENDOR_MODULE := true
include $(BUILD_SHARED_LIBRARY)
the line you mentioned would be
target_link_libraries(testLed hardware)

While building the AOSP build tree, LOCAL_MODULE not defined error is occures

While building the AOSP (Oreo)source tree, The following error occurs
build/core/dynamic_binary.mk:17: error: packages/apps/TerminalTest/jni:
LOCAL_MODULE not defined before call to local-intermediates-dir.
18:25:16 ckati failed with: exit status 1
#### failed to build some targets (26 seconds) ####
Application Source tree
jni
Android.mk
src
res
Android.mk
Main Android.mk
LOCAL_PATH:= $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := TerminalTest
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libjni_terminal
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
LOCAL_JNI_SHARED_LIBRARIES := libjni_terminalTest
# TODO: enable proguard once development has settled down
#LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
jni/Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
jni_init.cpp \
com_android_terminal_Terminal.cpp \
LOCAL_C_INCLUDES += \
external/libvterm/include \
libcore/include \
frameworks/base/include
LOCAL_SHARED_LIBRARIES := \
libandroidfw \
libandroid_runtime \
liblog \
libnativehelper \
libutils
LOCAL_STATIC_LIBRARIES := \
libvterm
LOCAL_CFLAGS := \
-Wno-unused-parameter \
LOCAL_MODULE := libjni_terminal
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
Any help will appreciate
If you use LOCAL_MODULE := libjni_terminal in any other project this error will happen.
When using the same LOCAL_MODULE name in different places lead to problems while creating and accessing intermediate files.

how to config android.mk when i need to export several native library

Now i export one native library and my folder is like this :
JNI\ANN*.cpp.
android.mk file is like this:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../
LOCAL_MODULE := libann
LOCAL_LDLIBS := -llog
NDK_TOOLCHAIN_VERSION := clang
LOCAL_CPPFLAGS += -std=c++11
LOCAL_SRC_FILES := \
ANN.cpp \
bd_pr_search.cpp \
bd_tree.cpp \
kd_pr_search.cpp \
kd_split.cpp \
kd_util.cpp \
bd_fix_rad_search.cpp \
bd_search.cpp \
brute.cpp \
kd_fix_rad_search.cpp \
kd_search.cpp \
kd_tree.cpp \
kd_dump.cpp \
perf.cpp\
sample.cpp
include $(BUILD_SHARED_LIBRARY)
Now i want to add some other cpp files and export another native lib.
for example, i add two files: graph.h,dijkstra,cpp
how should i config the android.mk file?
project/
liba/
srca.cpp
libb/
srcb.cpp
# TOP_PATH refers to the project root dir (project)
TOP_PATH := $(call my-dir)/.
# Build library a
include $(CLEAR_VARS)
LOCAL_PATH := $(TOP_PATH)/liba
LOCAL_MODULE := liba
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := srca.cpp
include $(BUILD_SHARED_LIBRARY)
# Build library b
include $(CLEAR_VARS)
LOCAL_PATH := $(TOP_PATH)/libb
LOCAL_MODULE := libb
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := srcb.cpp
include $(BUILD_SHARED_LIBRARY)

Categories

Resources