Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile Helloworld with Android source code

I wanted to run a helloworld application with the AOSP and see it in emulator. [ Not through Android SDK setup]

I followed the steps in http://source.android.com/source/download.html and compiled successfully the full code from / directory.

I could see contacts.apk, camera.apk all applications apk in ~/mydroid/out/target/product/generic/system/app.

I tried two things.

1 - Went to /package/apps folder. Took a helloworld application( helloworld folder which was created in android-sdk), and copied a 'Android.mk' file from Launcher2 folder, kept my new name for application and placed the folder in packages/app folder and compiled at /. I couldnt see .apk file created for ~/mydroid/out/target/product/generic/system/app.

2 - I changed the package name for Launcher2 in packages/app folder in 'Android,mk' file and compiled at root. I couldnt see a new apk created on the new packaged name under ~/mydroid/out/target/product/generic/system/app.

I tried several times with changes in activity names, application names in manifest.xml file. Nothing reflects.But it is sure, both helloworld, and change in package name is getting picked up while compiling. I could see intermediate classes getting created. ~/mydroid/out/target/common/obj/APPS/manifirst_intermediates/src/com/android/mani --> manifirst is like a helloworld which i created and run. ~/mydroid/out/target/common/obj/APPS/Launcher2_intermediates/src/com/android/launcher

Could anyone please share the steps of compiling a simple Helloworld program in AOSP.?

Thanks, Mani

like image 811
Mani Avatar asked Sep 12 '10 02:09

Mani


People also ask

Can I compile code on Android?

In android studio we can write our code and we can compile code after that we need to build the gradle so that we can run the app. Using run button we can run the app either in emulator or real android device.

How is Java compiled in Android?

Java bytecode in Java Archive (JAR) files is not executed by Android devices. Instead, Java classes are compiled into a proprietary bytecode format and run on Dalvik (or compiled version thereof with newer ART), a specialized virtual machine (VM) designed for Android.


1 Answers

Copy Android.mk from any other package and just have to change the LOCAL_PACKAGE_NAME and make that one match the folder name in packages/apps.

Also, add your package in the list in /build/target/product/core.mk

After compiling you should find the apk where you expect it... (out/target/product/.../system/app)

like image 145
Matthieu Avatar answered Oct 18 '22 05:10

Matthieu