Android 编译系统APP <1>

其实这个包括两中方向:

<1> : 如果系统APP是自己开发的,源代码可以提供出来的情况下;

<2> : 如果系统APP不是自己开发的,可能是第三方提供的,只是对其进行数字签名后成为系统APP;

首先看看<1>这种的制作方式,其实也很简单,步骤如下:

<1> : 自己利用eclipse先新建一个工程,比如说SystemAppDemo,这个名字要记住!我的sample程序很简单,没有什么实际价值,只是确认制作系统APP流程;

MainActivity.java

package com.example.systemappdemo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}
View Code

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

<--!  android:text="@string/show_information" 这个必须使用strings.xml文件中的值,不能够直接使用字符串填入,比如:android:text="install android system application",it's wrong when compling-->
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="89dp"
        android:text="@string/show_information"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

<2> 在系统中编译,还需要一个Android.mk的配置文件,这个文件需要手工新建:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_JAVA_LIBRARIES := bouncycastle telephony-common
LOCAL_STATIC_JAVA_LIBRARIES := guava android-support-v4 jsr305

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-java-files-under, src)

#android project name , not package name
LOCAL_PACKAGE_NAME := SystemAppDemo
LOCAL_CERTIFICATE := platform

#proguard.flags is also important , but here ignore
#LOCAL_PROGUARD_FLAG_FILES := proguard.flags

include $(BUILD_PACKAGE)

# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))

<3> : OK,把整个工程压缩成zip格式的压缩包,然后传到android系统编译环境下,放到/packages/apps目录下,然后解压,解压后删除zip.

<4> : 还需要在系统中配置一个mk的文件,这个文件目录可以通过上网查,一般是放在什么目录下,我的系统是修改过的,不是通用的,是放在device/***/g***e/imx6.mk中,

里面已经放了很多工程名字,依葫芦画瓢,把自己的工程插入到对象列表中,打开一看就知道插入在哪里了.

<5> : 好像没有其他的了,就到package/apps/SystemAppDemo目录下输入mm即可.

看到生成:Install:out/target/product........../SystemAppDemo.apk就代表编译成功了,你可以cd到这个目录下去看看SystemAppDemo.apk是否存在了.我的

参见下图:

<6> : 然后编译整个系统的时候生成img文件烧入到机器,机器中就有这个APK了.

 

 

 

 

 

 

 

 

 

posted @ 2014-04-16 20:28  MMLoveMeMM  阅读(520)  评论(0)    收藏  举报