Compile Android application as part of AOSP source code

This post details about how you can integrate your Android application as part of Android OpenSource Build system to get it compiled using command line. Normally Android applications are developed using Android Studio and it generates build.gradle to configure and compile the application, but when you want to get this same application compiled as part of AOSP project, you need to write, change the directory structure to match with AOSP directory structure and get this app compiled from command line.

This post has sample which we can use to compile the HelloWorld Application.

$ cd Android_AOSP
$ mkdir packages/apps/HelloWorld

Copy your java application source code to packages/apps/ e.g. HelloWorld

$ cd packages/apps/HelloWorld

Write an as below,

$ vim
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
LOCAL_SRC_FILES := $(call all-java-files-under, src)
include $(BUILD_PACKAGE)

If you want to enable proguard optimizations by default, just remove the line LOCAL_PROGUARD_ENABLED := disabled from above.

 Resolving Errors

1) Error: This attribute must be localized.
If you get error like below,

packages/apps/HelloWorld/res/layout/activity_main.xml:12: error: Error: This attribute must be localized. (at ‘text’ with value ‘Advertise’).

Solution :

Change packages/apps/HelloWorld/res/layout/activity_main.xml as below,


and add this reference to res/values/string.xml:

<string name="advertise">Advertise</string>
Reference : Click the Link

Installing Android Application

$ ./out/host/linux-x86/bin/adb install application_name.apk

After Installing, or during installation you might get an error like, “Error : Parsing the package”, to resolve this you need to verify the ” minSdkVersion ” whether its compatible to API on your mobile or not, and correct the same or alternatively, change AndroidManifest.xml Like below to set to min. value.

– android:minSdkVersion=”11″
+ android:minSdkVersion=”1″^M

Reference : Click the Link

custom alert dialog in android with... x
custom alert dialog in android with floating image logo

Leave a Comment

Sign up to our newsletter!

ADB Commands Android Android Applications Android Build system Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia NDK / Middleware / HAL Operating System Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto Embedded Linux