Using source code to compile the Android system's apk and executable command method _android

Source: Internet
Author: User

Build Android System apk
1, set up the environment

Export android_home=/home/administrator/soft/android
export path= $PATH: $ANDROID _home/out/host/linux-x86/bin
Export android_product_out= $ANDROID _home/out/target/product/generic

2, create the project

Android Create Project-t 1-k com.lhw.led-a mainactivity-p./led Avd id:1,it
' s Get by command "Android list"

p roject name:led
Package:com.lhw.led 

Main activity:mainactivity

Project Path:./

The next step is to write your own Android program.

3, the preparation of android.mk
android.mk need to be placed under the project root path, that is, under the LED, content:

Local_path       : = $ (call My-dir)

include $ (clear_vars)
local_src_files     : = $ (call all-subdir-java-files)
local_package_name   : = LED 

local_java_libraries  : = 
local_static_java_libraries: =

Include $ (build_package)


4, compile
execute under the Android source directory:

./build/envsetup.sh
mmm/home/administrator/workspace/android_test/led/

Execution results:

install:out/target/product/generic/system/app/led.apk


Build Android System executable command

The Android system allows developers to write "LS" commands on their Android systems.

1, the preparation of C documents: MYCMD.C

#include <stdio.h> 
 
int main (int argc, char **argv) 
{ 
  printf ("This are My command!\n"); 
  return 0; 
} 

2, the preparation of ANDROID.MK documents

Local_path   : = $ (call My-dir) 
 
local_src_files: = mycmd.c 
local_module  : = myCMD 
local_module_tags : = myCMD 
local_shared_libraries: = libc 
local_static_libraries: = 
 
include $ (build_executable)  


3, compile

mmm/home/administrator/workspace/android_test/mycmd/

After the compilation completes the information:

 Install:out/target/product/generic/system/bin/mycmd

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.