Does Android.mk require AndroidManifest.xml? - android

I am trying to build my app as a part of the AOSP and realized that the Android.mk file does not take the path of the AndroidManifest.xml as input.
How can the mm command build the app with just the java files and the resources?
From where does the Android make get the information contained in AndroidManifest.xml?
Note:
Currently, my app is building with mm but has a smaller size (1MB vs 5MB) and does not show up on the device after adb install. Maybe this will fix it.
My Android.mk file for any reference
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_STATIC_ANDROID_LIBRARIES += \
android-arch-lifecycle-extensions \
android-support-v7-recyclerview \
android-support-v7-appcompat \
android-support-constraint-layout \
# Build all java files in the java subdirectory
#LOCAL_SRC_FILES := $(call all-subdir-java-files)
#Commented line just made a ~17kB apk file
LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/java)
LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/app/src/main/res
# Name of the APK to build
LOCAL_PACKAGE_NAME := LocalPackage
LOCAL_SDK_VERSION := current
#Otherwise build failing
# Tell it to build an APK
include $(BUILD_PACKAGE)

Related

any easy way AOSP app development workflow?

i am trying development an app put in aosp source tree.it use aosp built system,and with some native code .it also is an system app.but development workflow is a bit annoying: i am modify my app code first.then go aosp dir,run mmm command,then use make command build system images and flash it to my android development board.then run app for test and check logcat,then back to modify code ....
is there any other workflow for development system app ?
i have tryed these method:
Android.mk with these line:
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
i can not use adb install install app apk file found in build out dir.
if i comment out that two lines,and set LOCAL_MODULE_TAGS := tests,then i can install apk use adb install command. but app is not system app,can not access some native api.
and my app have some native code.(not prebuilt library),aosp build apk but without my library.so my app can not running with error:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data
/app/com.mytest.app-IpmPY1ehtNYFMP3BCMb8HA==/base.apk"],nativeLibraryDirectories=[/data/app/com.mytest.app-IpmPY1ehtNYFMP3BCMb8HA==/lib/arm64,
/system/lib64, /vendor/lib64]]] couldn't find "libmytest_jni.so"
then i am check my device filesystem,aosp not pack my library into system.img.
here is Android.mk for app:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(call all-subdir-java-files)
# LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_TAGS := tests
LOCAL_PACKAGE_NAME := Mytest
LOCAL_SDK_VERSION := current
# with this two lines,i can not use adb install to update my app
# without ,can not access some system api
# LOCAL_CERTIFICATE := platform
# LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
LOCAL_JNI_LIBRARIES := libmytest_jni
LOCAL_REQUIRED_MODULES := libmytest_jni
include $(BUILD_PACKAGE)
#jni
include $(CLEAR_VARS)
include $(call all-makefiles-under,$(LOCAL_PATH))
Android.mk for libmytest_jni library:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# with this line, library not pack into system.img
# without this line,is pack into system.img,but i must refulsh image file to test
# whatever with or without,library is not pack into apk file.
# LOCAL_MODULE_TAGS := tests
LOCAL_MODULE:= libmytest_jni
LOCAL_SRC_FILES:= \
main_jni.cpp
LOCAL_SHARED_LIBRARIES := \
libnativehelper \
libcutils \
libutils \
liblog
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE)
LOCAL_CFLAGS +=
include $(BUILD_SHARED_LIBRARY)
For a module to be added as part of system when you run full make, you'll have to add it in your device makefile, or device.mk a line like this: PRODUCT_PACKAGES += MyTest
When building a specific module via mmm, you'll have to run make snodto re-generate system.img
Instead of flashing system.img like in step 2, you can use adb sync. This will push any changed files to device. You might need to run adb reboot, or at least adb shell stop && adb shell start after.

How to build Trade Federation test cases

I am able to compile and execute Trade Federation test cases which are located inside /tools/tradefederation/core/tests. But how can I execute the test cases which are located inside my project? My Unit and Instrumentation test cases are located inside /vendor/xyz/packages/apps/MyApp/test folder. How can I build Trade Federation inside this folder and run my test cases? Any help regarding this is appreciated.
Since I couldn't get an answer from others, I did little research and managed to solve it myself. I built my project main classes and test classes into a separate jar file which has the reference to all its dependencies. Then I put it inside out/host/linux-x86/tradefed folder so that tradefed can detect my tests. Then I executed them from the terminal after building tradefed. Below Android.mk file will generate the jar file and copy it to tradefed folder,
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v13 \
android-support-v4
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, res)
LOCAL_PACKAGE_NAME:= MyUTSampleApp
LOCAL_CERTIFICATE := platform
LOCAL_DEX_PREOPT := false
include $(BUILD_PACKAGE)
# To include test folder.
#include $(call all-makefiles-under,$(LOCAL_PATH))
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, test)
LOCAL_MODULE := sample-tests
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_JAVA_LIBRARIES := mockito-host junit-host android-support-test MyUTSampleApp android_stubs_current
#LOCAL_JAVA_LIBRARIES := tradefed host-libprotobuf-java-full
LOCAL_JAR_MANIFEST := MANIFEST.mf
include $(BUILD_HOST_JAVA_LIBRARY)
# makefile rules to copy jars to HOST_OUT/tradefed
# so tradefed.sh can automatically add to classpath
DEST_JAR := $(HOST_OUT)/tradefed/$(LOCAL_MODULE).jar
$(DEST_JAR): $(LOCAL_BUILT_MODULE)
$(copy-file-to-new-target)
$(LOCAL_INSTALLED_MODULE) : $(DEST_JAR)
And you can use another shell script file to execute the test cases like this,
TEST_CLASS="com.example.myutsampleapp.LocalManagerTest"
FORWARDED_ARGS=()
while [[ $# -gt 0 ]]; do
next="$1"
case ${next} in
--class)
TEST_CLASS="$2"
shift
;;
*)
FORWARDED_ARGS+=("$1")
;;
esac
shift
done
/home/bsherif/workspace/source/tools/tradefederation/core/tradefed.sh run singleCommand host -n \
--console-result-reporter:suppress-passed-tests \
--class ${TEST_CLASS} ${FORWARDED_ARGS[*]}

Make app in Android source compile to system/app

I'm trying to learn how to compile an app in android source. The app is just a simple hello world application. I followed instructions from Making an app in the Android Source compile into system/app instead of data/app? and a couple of other sources. But when I make the application the apk file is written to obj/APPS with suffix intermediates instead of system/app and fails to show up in the emulator when I boot up. Please find below the Android.mk file.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_PATH := system/app
LOCAL_UNINSTALLABLE_MODULE := true
LOCAL_SDK_VERSION := current
LOCAL_PACKAGE_NAME := MyApplication
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-gridlayout
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v13
LOCAL_STATIC_JAVA_LIBRARIES += android-support-design
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/appcompat/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/gridlayout/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/design/res
LOCAL_CERTIFICATE := platform
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat:android.support.v7.gridlayout
include $(BUILD_PACKAGE)
##################################################
include $(CLEAR_VARS)
include $(BUILD_MULTI_PREBUILT)
# Use the following include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))
I make the application by going to the application directory in packages/apps and doing 'mm'. Is there anything I'm missing here?
Find out the BoardConfig.mk and add this :
PRODUCT_PACKAGES += MyApplication
AOSP build system will build every Android.mk, but only packages defined in BoardConfig will be put into the final product path.
you have to add the app module into the PRODUCT_PACKAGE from the devices/"your preferred vendor"/"device_name"/aosp_"device Name".mk file
It should look something like the following
$(call inherit-product, device/lge/hammerhead/full_hammerhead.mk)
PRODUCT_NAME := aosp_hammerhead
PRODUCT_PACKAGES += \
Launcher3 \
MyApplication \
It has little bit changed. Aosp checks /device/"vendor"/"your_device"/"your_platform"/base.mk file for compiling and /device/"vendor"/"your_device"/common/base.mk for installing apk to /out/target/product/"your_device/system/app/"
You should add your app name to both files.
In my case; aosp/device/qcom/qssi/base.mk to compile,
aosp/device/qcom/common/base.mk to install output(apk) to /out/target/product/msm8953/system/app/

Add prebuilt apk to AOSP build

I tried to include a prebuilt google apk (with no .so file) to my marshmallow AOSP build based on the information found in this link as follows:
In my vendor/manufacturer/device/proprietary/system/app, I created a folder named 'Testapk'.
I saved two files in this 'Testapk' folder, the apk ('Testapk.apk') and an Android.mk file which contains the following instructions:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := Testapk
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
I added the following instruction in my vendor/manufacturer/device/vendor_device.mk :
PRODUCT_PACKAGES += \
Testapk
When making the AOSP build, I get the following error:
make: *** No rule to make target `/Testapk', needed by `out/target/product/mako/obj/APPS/Books_intermediates/Testapk.apk'. Stop.
#### make failed to build some targets (01:00 (mm:ss)) ####
The problem with my Android.mk file was that it had trailing spaces on each line. Everything worked fine after I deleted these trailing spaces.
after the \ the "testapk" should be on a new line.
PRODUCT_PACKAGES += \ Testapk

Android ndk: utils/Log.h: No such file or directory compilation terminated

am compiling android ndk project but couldn't get it successfully done. It says no such file or directory found for Log header file at main.cpp file. I'm new to android ndk please help.
here is my android.mk file.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := user
LOCAL_ARM_MODE := arm
# This is the target being built.
LOCAL_MODULE := libemu
# All of the source files that we will compile.
LOCAL_SRC_FILES := \
ticks.c \
main.cpp \
emulator.cpp
# All of the shared libraries we link against.
LOCAL_SHARED_LIBRARIES := \
libdl \
libnativehelper \
libutils
# Static libraries.
LOCAL_STATIC_LIBRARIES :=
# Also need the JNI headers.
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE)
# Special compiler flags.
LOCAL_CFLAGS += -O3 -fvisibility=hidden
# Don't prelink this library. For more efficient code, you may want
# to add this library to the prelink map and set this to true. However,
# it's difficult to do this for applications that are not supplied as
# part of a system image.
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
here is the log
"Compile++ arm : emu <= main.cpp
D:/EclipseWorkspace/NineTendo//jni/main.cpp:2:23: fatal error: utils/Log.h: No such file or directory
compilation terminated.
make: *** [D:/EclipseWorkspace/NineTendo//obj/local/armeabi/objs/emu/main.o] Error 1
any help would be much appreciated.
Thanks
This error started to show up in NDK version R9x. You need to declare the API version number in your Application.mk file. Here's how it looks to define a minimum API level of 8:
APP_PLATFORM := android-8
The Application.mk file should live alongside your Android.mk file in the JNI directory. Here's a sample from one of my projects:
APP_ABI := armeabi armeabi-v7a x86
APP_CFLAGS += -O2
LOCAL_ARM_MODE := arm
APP_PLATFORM := android-8

Categories

Resources