• Android系列之Android 命令行手动编译打包详解


    Android 命令行手动编译打包过程图

    【详细步骤】:

     

    1使用aapt生成R.java类文件: 
    例: 
    E:androidDevandroid-sdk-windows2.2 ools>E:androidDevandroid-sdk-windows2.2platformsandroid-3 oolsaapt.exe package -f -m -J E:androidDevAndroidByreadgen -S res -I E:androidDevandroid-sdk-windows2.2platformsandroid-3android.jar -M AndroidManifest.xml 
    其中  -f -m -J E:androidDevAndroidByreadgen 代表按覆盖的形式在gen目录下生成带包路径的R.java,-S res指定资源文件 ,-I E:androidDevandroid-sdk-windows2.2platformsandroid-3android.jar 指定使用的android类,-M AndroidManifest.xml指定程序的配置文件

    aapt Usage: 

    2使用android SDK提供的aidl.exe把.aidl转成.java文件: 
    usage: aidl OPTIONS INPUT [OUTPUT] 
           aidl --preprocess OUTPUT INPUT...

     

    OPTIONS: 
       -I<DIR>    search path for import statements. 
       -d<FILE>   generate dependency file. 
       -p<FILE>   file created by --preprocess to import. 
       -o<FOLDER> base output folder for generated files. 
       -b         fail when trying to compile a parcelable.

    INPUT: 
       An aidl interface file.

    OUTPUT: 
       The generated interface files.

     

    3第三步 编译.java类文件生成class文件: 
    例:E:AndroiddevAndroidByread>javac -encoding GB18030 -target 1.5 -bootclasspath E:Androiddevandroid-sdk-windows2.2platformsandroid-3android.jar -d bin srccomyread eader*.java gencomyread eaderR.java 

    4使用android SDK提供的dx.bat命令行脚本生成classes.dex文件:

    例: 
    E:AndroiddevAndroidByread>E:Androiddev android-sdk-windows2.2platformsandroid-3 oolsdx.bat --dex --output=E:AndroiddevAndroidByreadinclasses.dex E:AndroiddevAndroidByreadinclasses 
    其中classes.dex为生成的目标文件,E:AndroiddevAndroidByreadinclasses为class文件所在目录

     

    5使用Android SDK提供的aapt.exe生成资源包文件(包括res、assets、androidmanifest.xml等): 
    E:AndoridAndroidByread>E:Androiddevandroid-sdk-windows2.2platformsandroid-3 oolsaapt.exe package -f -M AndroidManifest.xml -S res -A assets -I E:Androiddevandroid-sdk-windows2.2platformsandroid-3android.jar -F binyreadreader 
    将AndroidManifest.xml,res和assets文件夹中的资源文件打包生成byreadreader,用法参见1

    6第六步 生成未签名的apk安装文件: 
    apkbuilder  ${output.apk.file} -u -z  ${packagedresource.file} -f  ${dex.file}  -rf  ${source.dir}  -rj  ${libraries.dir} 

    例: E:AdnroiddevAndroidByread>E:Adnroiddevandroid-sdk-windows2.2 oolsapkbuilder.bat E:Adnroiddevyreadreader.apk –v -u -z E:AdnroiddevAndroidByreadinyreadreader -f E:AdnroiddevAndroidByreadinclass.dex -rf E:AdnroiddevAndroidByreadsrc 其中E:Adnroiddevyreadreader.apk为生成的apk ,-z E:AdnroiddevAndroidByreadinyreadreader为资源包,E:AdnroiddevAndroidByreadinclass.dex为类文件包 

     

    7使用jdk的jarsigner对未签名的包进行apk签名: use jarsigner jarsigner  -keystore ${keystore} -storepass  ${keystore.password} -keypass ${keypass} -signedjar ${signed.apkfile} ${unsigned.apkfile} ${keyalias} 例如: E:Adnroiddevandroid-sdk-windows2.2 ools>jarsigner –keystore E:Adnroiddeveclipse3.5byread.keystore -storepass byread002 -keypass byread002 -signedjar E:Adnroiddevyread.apk E:Adnroiddevyreadreader.apk byread 其中–keystore E:Adnroiddeveclipse3.5byread.keystore 为密钥文件  -storepass byread002为密钥文件密码 byread 为密钥别名 -keypass byread002为密钥别名密码,-signedjar E:Adnroiddevyread.apk为签名后生成的apk文件 E:Adnroiddevyreadreader.apk为未签名的文件。 
    参考:http://asantoso.wordpress.com/2009/09/15/how-to-build-android-application-package-apk-from-the-command-line-using-the-sdk-tools-continuously-integrated-using-cruisecontrol/ 

  • 相关阅读:
    ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
    pycocotools使用教程
    with torch.no_grad() 详解
    虚拟机Ubuntu上下载Pytorch显示超时
    Deep Layer Aggregation DLA网络的结构
    tgz文件解压命令
    install mysql at linux
    devops issue
    process data
    unittest
  • 原文地址:https://www.cnblogs.com/zsw-1993/p/4879926.html
Copyright © 2020-2023  润新知