We are trying to develop a custom ROM using AOSP's master branch. We have successfully built and run the compiled image on the emulator provided by AOSP.
Now we are trying to add an application in the AOSP so that the AOSP branch compiles and runs with the application present in it, that means when we run the android version our newly added application will act as a default/system application.
We have tried doing that using following steps, but have failed:
Place the App_name folder to /packages/apps
Add Android.mk to /packages/apps/App_name/
Add App_name entry to /build/target/product/core.mk
PRODUCT_PACKAGES := \
... \
SomeApp \
App_name
Note: App_name is the application folder that is developed using android studio and is present the Android-Studio Projects folder.
After performing these steps we compile the entire source code/AOSP and eventually the compilation fails.
Could someone please help me out??
For adding a default application to AOSP , You should create a directory with arbitrary name in packages/apps (name of directory doesn't matter) , then you should put necessary code and resources in it . Notice AOSP build system doesn't use Gradle ,hence you don't need to copy gradle build files (like build.gradle and setting.gradle and etc).
For a typical app you should create these directories :
src : place your java codes here .
res : place your resources directory for examle drawable , layout , ...
assets : if your project has any assests file , place them in this folder
Your AndroidManifest.xml file should be added in top of your directory.After placing your code and resources , create an Android.mk file and write the following lines in it :
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := <Name of your app>
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, src)
# Include libraries
LOCAL_JAVA_LIBRARIES := <Java lib dependencies>
LOCAL_STATIC_JAVA_LIBRARIES := android-common
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_ASSETS_DIR := $(LOCAL_PATH)/assets
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat
include $(BUILD_PACKAGE)
LOCAL_PACKAGE_NAME is name of your app (for examle camera , app1 , ...) ,you should add this name to /build/target/product/core.mk (no folder name , folder name is not important) .
LOCAL_SRC_FILES is pointer to Java codes.
LOCAL_JAVA_LIBRARIES : if your project has java lib dependency , reference to it here.
LOCAL_RESOURCE_DIR is address of res directory
LOCAL_ASSETS_DIR is address of assets directory
Finally build your app and add it to system image . use these commands
make <name of your app>
make snod
<name of your app> is value of LOCAL_PACKAGE_NAME in your Android.mk file. You don't need to build whole AOSP build tree using something like make -j8 . Just build your app and add it to system image. Default applications are placed in read only system partition.
Related
As I was trying to change my package name using a package (change_app_package_name). I bumped into this error:-
Old Package Name: com.milanzi.shamba_huru
Updating build.gradle File
Updating Main Manifest file
Updating Debug Manifest file
Updating Profile Manifest file
ERROR:: Unknown Directory structure, both java & kotlin files not found.
Seems the package cannot find either java or kotlin files within the directory.
I have solved by changing the directory name where the MainActivity.kt is placed
For example
First your package name is com.example.app_name
Then you need to change into com.milanzi.shamba_huru (use your own package name)
Run
flutter pub run change_app_package_name:main com.milanzi.shamba_huru
So if the error appears, you just need to create a new folder by name of your package
Before your path was
/android/app/src/main/kotlin/com/example/app_name/MainActivity.kt
Change into
/android/app/src/main/kotlin/com/milanzi/shamba_huru/MainActivity.kt
Now try run against flutter pub run change_app_package_name:main com.milanzi.shamba_huru
NB: If you didn't change the folder name, you can't run it on android. But you can run on IOS.
I am trying to install a custom application on my Yocto build.
I currently use a Raspberry Pi 4 64 bit setup, for which I want PyQt5 to display an application directly on the frame buffer (so no windowing manager or desktop envoirement).
My current build with Yocto completes and boots on the Raspberry Pi. All the Qt5 libraries are also present in the root fs after the bitbake build.
Although, I'm having problems getting a custom layer, that adds a custom recipe with a custom application to also copy over to the destination root fs.
My custom layer is called 'meta-rpikms' with recipe 'recipes-kms-qt-app' which contains the application bb files. This files is called 'basicquick_0.1.bb' and has the following contents (this test application tries to add a EGLFS friendly Qt5 applicaiton, i'll try PyQt5 later):
SUMMARY = "Simple Qt5 Quick application"
#SECTION = "examples"
LICENSE = "MIT"
#PACKAGE_ARCH = "all"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
DEPENDS += "qtbase qtdeclarative qtquickcontrols2"
SRCREV = "${AUTOREV}"
SRC_URI = "git://github.com/shigmas/BasicQuick.git"
S = "${WORKDIR}/git"
require recipes-qt/qt5/qt5.inc
do_install() {
install -d ${D}${bindir_native}
install -m 0755 BasicQuick ${D}${bindir_native}
}
FILES_${PN} += "${bindir_native}"
When I bitbake the custom layer of my meta-rpikms (called 'qt5-kms-rpi-image'), it does compute. When I take a look at the 'image_initial_manifest' file, my custom application does show up, suggesting that it does compile and try to install the application:
# This file was generated automatically and contains the packages
# passed on to the package manager in order to create the rootfs.
# Format:
# <package_type>,<package_name>
# where:
# <package_type> can be:
# 'mip' = must install package
# 'aop' = attempt only package
# 'mlp' = multilib package
# 'lgp' = language package
mip,basicquick
mip,bluez5
mip,bridge-utils
mip,hostapd
mip, bla bla bla etc etc etc.
And if I take a look in: '~/builds/pyqt5_try1/poky/rpi64-build/tmp/work/cortexa72-poky-linux/basicquick/0.1-r0', the expected files do show up. Also suggesting that it does atleast build the application. This makes the think that the 'install' arguments in my .bb file are pointing to the wrong folder.
In my basicquick_*.bb file this is to make the directory and install (copy) the built files:
install -d ${D}${bindir_native}
install -m 0755 BasicQuick ${D}${bindir_native}
I used the 'bitbake -e' command to trace the variable D and bindir_native:
D="/home/mats/builds/pyqt5_try1/poky/rpi64-build/tmp/work/raspberrypi4_64-poky-linux/qt5-kms-rpi-image/1.0-r0/image"
bindir_native="/usr/bin"
This seems okay at first glance, but when I manually follow the destination of the variable 'D', there is no 'images' folder created. I also wonder why everybody installs their custom applications on ${D}/usr/bin? Should this not be written to the build/tmp/deploy directory? Or am I missing a step here.
So, in this 'qt5-kms-rpi-image/1.0-r0' folder, there is a folder called 'deploy-qt5-kms-rpi-image-image-complete', which contains a rootfs. But there also is a rootfs folder in the 'qt5-kms-rpi-image/1.0-r0' folder. Both of these rootfs's do not contain any mention of my basicquick application, or a BasicQuick folder being created in /usr/bin.
Also, the rootfs found in the "build/tmp/deploy/images/raspberrypi4-64/qt5-kms-rpi-image-raspberrypi4-64.tar.bz2" does not contain any mention of the basicquick application being present in the filesystem.
Does anybody have any clues on what I am missing? Am I just not copying my files to the correct location? Or does the final deploy image end up somewhere else from where I am expecting it?
Thanks in advance.
With kind regards,
Mats de Waard
I need to build an application with android.mk in aosp build tree. I have a custom .arr lib with some resources like drawables,strings..etc, Which resides in the following folder apps/libs/mylib.aar
Anyone can tell me how to include the aar in the android aosp build and use that aar resources in another applications. I already tried the following method described here in Stackoverflow.
https://stackoverflow.com/questions/31205856/aar-support-in-android-mk
Android.mk of my application is looked like
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_PACKAGE_NAME := TestSampleAarLib
LOCAL_STATIC_JAVA_AAR_LIBRARIES:= sampleaarlib
LOCAL_STATIC_ANDROID_LIBRARIES += android-support-v7-appcompat
LOCAL_STATIC_ANDROID_LIBRARIES += android-support-v7-gridlayout
LOCAL_STATIC_ANDROID_LIBRARIES += android-support-v13
LOCAL_USE_AAPT2 := true
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages com.myaar.sample.lib
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_TAGS := optional
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MANIFEST_FILE := AndroidManifest.xml
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := sampleaarlib:libs/sampleaarlib.aar
include $(BUILD_MULTI_PREBUILT)
If anyone have idea about using resources from aar in AOSP Please share.
Thanks in advance.
To add resources from the aar file, please add the following in your android.mk file.
LOCAL_RESOURCE_DIR +=$(call intermediates-dir-for,JAVA_LIBRARIES,<aar_file_name>,,common)/aar/res
Tested and verified in the Android 8.1 version.
NB: In the latest android versions like 9+ resources automatically merged to the project.
I have an Akka SBT project. It consists of multiple SBT submodules:
common contains resources/logback-prod.xml
app depends on two other submodules
postgres
I build a docker image of the project. The only command which does not affect the image is:
...
dockerPackageMappings in Docker +=
((resourceDirectory in Compile).value / "logback-prod.xml") -> "/opt/docker/conf/logback-prod.xml"
...
This line of code does not copy the logback-prod.xml from the common subproject to the docker /opt/docker/conf/ path
Instead it creates a directory with name "logback-prod.xml" by the path I mentioned above.
What I'm doing wrong?
Usually when you get an empty directory instead of the file in Docker, it means that the source file doesn't exist. I.e. in your case it could mean that your source path is wrong. Try it with copying a file with an absolute path, and see if it gets copied in correctly.
The problem is solved by this line of code:
mappings in Docker += (resourceDirectory in common in Compile).value / "logback-prod.xml" -> "/opt/docker/conf/logback-prod.xml",
I have built a C++ shared library with NDK builder in Eclipse (firestly creating a JNI project with no MainActivity), which provided as output the different platforms that I have specified in the Application.mk file. The output is in the /obj/local/ directory, spread over the platforms subdirectories (armabi, mips, ... i.e. all the platforms that I have specified in the above file).
Now, I want to use this shared library inside an Android native project, where my shared library is called inside a project's native library (therefore it is about "native-calling-native").
If I build both the shared library and the Android native aplication for just one type of platform (let's say "armeabi"), everything works fine.
My question is how to create the make files, Android.mk and Application.mk, of the Android native project so that to build for ALL the platforms.
I suppose the key is in the Android.mk file, which, for just one platform build it looks like this (on Linux, for the .so type, C++11 for info):
LOCAL_PATH := $(call my-dir)
# Define the shared library module used by the calling JNI C++ module
include $(CLEAR_VARS)
LOCAL_SRC_FILES := libs/libCreateSharedWithJni.so
LOCAL_MODULE := CreateSharedWithJni
LOCAL_EXPORT_C_INCLUDES := libs/CreateSharedWithJni.h
include $(PREBUILT_SHARED_LIBRARY)
# Define the calling JNI C++ module
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_MODULE := finalmodule
LOCAL_SRC_FILES := CppJniCallShared.cpp
LOCAL_SHARED_LIBRARIES := libCreateSharedWithJni
include $(BUILD_SHARED_LIBRARY)
Thanks!
Got it!
In the above Android.mk file just change the line as following
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libCreateSoWithJni.so
i.e. using the $(TARGET_ARCH_ABI) in the path drives the builder to process all platforms specified in the Application.mk APP_ABI variable.