Android 制作 升级包
http://hi.baidu.com/j_fo/blog/item/81ae650953ea5ec13ac76312.html
http://hi.baidu.com/j_fo/blog/item/53a45b82206837af0df4d21a.html
如何制作自己的android升级包(update.zip) 2010-09-04 19:34
手动制作update.zip包的过程:
1.创建一个update目录, 该目录包含自己想要升级或替换的内容 例如: update/ update/system update/system/app update/system/app/doodle_jump. apk update/META-INF update/META-INF/com update/META-INF/com/google update/META-INF/com/google/ android update/META-INF/com/google/ android/update-script 该目录包含doodle_jump游戏, 升级后该apk将出现在手机的/system/app/目录下。 META-INF目录下包含升级脚本,update-script脚本的内容如下: show_progress 0.500000 0 copy_dir PACKAGE:system SYSTEM: show_progress 0.100000 0 大家可以根据自己的升级内容添加相应的命令。 2.创建压缩包 在update/目录下运行: $ zip -qry ../update.unsigned.zip ./ 将在update/的父目录下产生update. unsigned.zip 压缩包 3.签名 $ java -Xmx512m -jar signapk.jar -w key.x509.pem key.pk8 update.unsigned.zip update.zip 生成签过名的update.zip包,其中 signapk.jar,key.x509.pem, key.pk8与具体手机系统相关 4.将签过名的update. zip包放入手机sdcard根目录,
重启系统进入recovery模式,选择 apply update.zip,成功后重启手机 ok,现在手机上已经有doodle_jump游戏了, 并且它无法被删除~


refer:
http://hi.baidu.com/j_fo/blog/item/53a45b82206837af0df4d21a.html

How to Create Android Update Zip Package

There are several ways to install applications or library files to anAndroidPhone. You can useMarketapplication to find and install oradbcommand line tool to install or push the files to Android file system. These are all easy to implement for single file but if you have several applications or library files to install at once, it might be better to useupdate zipfile. The update zip file is Android advanced system to install applications or lib files to Android file system using recovery tool. This method is commonly used by rom or theme developers to distribute their package.

Creating an update zip file is quite easy, all you have to do is put the files in corresponding directory in Android file system and anupdate-scriptfile to copy the files. For example, to installCalculator.apkintosystem/appand copylibsec-ril.sofile intosystem/lib:

  • Create an empty folder (eg. C:\myupdate)
  • CreateC:\myupdate\system\appfolder forCalculator.apkandC:\myupdate\system\libfolder forlibsec-ril.so
  • CreateC:\myupdate\META-INF\com\google\androidfolder forupdate-scriptfile.
  • Create theupdate-scriptfile with the following syntax:
    show_progress 0.1 0copy_dir PACKAGE:system SYSTEM:show_progress 0.1 10

    Line 1&5 : show progress bar
    Line 3: copysystemfolder from update package to Android’s/system

    Note: you should add one extra line at the end of the file (Line 6)

  • Compress the entire contents ofC:\myupdatefolder to zip (not themyupdatefolder itself)
  • Sign themyupdate.zipfile

    java -jar signapk.jar certificate.pem key.pk8 myupdate.zip update.zip

    Note: you can find tutorial on how to sign the update.zip filehere

  • Copy theupdate.zipfile to sdcard and apply it from recovery console

update-script syntax reference (definitions from recovery.c android source code):

  • copy_dir

    Syntax:copy_dir <src-dir> <dst-dir> [<timestamp>]
    Copy the contents of <src-dir> to <dst-dir>. The original contents of <dst-dir> are preserved unless something in <src-dir> overwrote them.
    Ex:copy_dir PACKAGE:system SYSTEM:

  • format

    Syntax: format <root>
    Format a partiti0n
    Ex:format SYSTEM:, will format entire/system. Note: formatting erases data irreversibly.

  • delete

    Syntax:delete <file1> [... <fileN>]
    Delete file.
    EX:delete SYSTEM:app/Calculator.apk, will deleteCalculator.apkfromsystem/appdirectory.

  • delete_recursive

    Syntax:delete_recursive <file-or-dir1> [... <file-or-dirN>]
    Delete a file or directory with all of it’s contents recursively
    Ex:delete_recursive DATA:dalvik-cache, will delete/data/dalvik-cachedirectory with all of it’s contents

  • run_program

    Syntax:run_program <program-file> [<args> ...]
    Run an external program included in the update package.
    Ex:run_program PACKAGE:install_busybox.sh, will runinstall_busybox.shscript (shell command) included in the update package.

  • set_perm

    Syntax:set_perm <uid> <gid> <mode> <path> [... <pathN>]
    Set ownership and permission of single file or entire directory trees, like ‘chmod’, ‘chown’, and ‘chgrp’ all in one
    Ex:set_perm 0 2000 0550 SYSTEM:etc/init.goldfish.sh

  • set_perm_recursive

    Syntax:set_perm_recursive <uid> <gid> <dir-mode> <file-moe> <path> [... <pathN>]
    Set ownership and permission of a directory with all of it’s contents recursively

    Ex:set_perm_recursive 0 0 0755 0644 SYSTEM:app

  • show_progress

    Syntax:show_progress<fraction> <duration>
    Use of the on-screen progress meter for the next operation, automatically advancing the meter over <duration> seconds (or more rapidly if the actual rate of progress can be determined).
    Ex:show_progress 0.1 0

  • symlink

    Syntax:symlink <link-target> <link-path>

    Create a symlink (like ‘ln-s’). The <link-path> is in root:path format, but <link-target> is
    for the target filesystem (and may be relative)

----------


用Android自带的signapk.jar + .x509.pem + .pk8签名应用程序


http://lmdy2001.blog.163.com/blog/static/8423891020114262323816/


文件位置:可以在platform/build/target/product/security/中找到platform.pk8 platform.x509.pem等签名文件,对应不同的权限。
signapk.jar:由/platform/build/tools/signapk/编译产出,可以在/out/host/linux-x86/framework/中找到。

签名:
java -jar signapk.jar platform.x509.pem platform.pk8 MyDemo.apk MyDemo_signed.apk 得到具有对应权限的APK

优化APK:
zipalign -v 4 MyDemo_signed.apk MyDemo_new.apk

查循APK是否优化过:
zipalign -c -v 4 MyDemo.apk
原文转自: http://www.blogjava.net/MEYE/articles/357111.html

更多相关文章

  1. Android获取手机信息
  2. android获取手机通讯录联系人
  3. Android(安卓)手机震动
  4. Linux 命令行更新指定版本 android sdk
  5. Androidの异常总结
  6. android模块化开发
  7. Android(安卓)Studio 的 gradle 插件升级失败
  8. android 一键锁屏实现
  9. Linux下Android(安卓)ADB驱动安装详解

随机推荐

  1. Anubis,一个支持Android apk(Android bin
  2. android java 调用 .so 动态库实例
  3. Android Training - 使用IntentService执
  4. Android Http网络数据传输备忘
  5. ImageView的android:scaleType属性和 src
  6. android 双击图片放大缩小
  7. Android保持屏幕常亮,PowerManager.WakeLo
  8. android之音乐播放器
  9. Android(安卓)4.0 Launcher源码分析系列(
  10. android UI组件