1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Android中使用Ant编译打包

Android中使用Ant编译打包

时间:2023-11-24 23:20:11

相关推荐

Android中使用Ant编译打包

本文参照自:/xyz_lmn/article/details/7268582?reload一、环境配置1.1、配置ant首先从ant官网可下载ant,接着解压ant的包到本地目录,紧接着在环境变量中设置ANT_HOME为你的ant所在目录,然后把%ANT_HOME%/bin加到你系统环境的path,最后在命令行执行ant命令测试其是否已经添加到了系统path中。二、基本使用

2.1、使用android create创建项目 参数说明: -k/--package为命名空间(包名) -a/--name工程名 -p/--path项目 -t为目标平台的版本编号实例1

C:\Users\hubin5\Desktop\temp\0503>android create project -k com.android.Tank -a Tank -t 4 -p G:\projects\tank Error: Project folder 'G:\projects\tank' is not empty. Please consider using 'android.bat update' instead. Updated file G:\projects\tank\src\com\android\Tank\Tank.java Updated file G:\projects\tank\res\values\strings.xml Updated file G:\projects\tank\res\layout\main.xml Updated file G:\projects\tank\AndroidManifest.xml Updated file G:\projects\tank\build.xml Updated file G:\projects\tank\proguard-project.txt 可以通过android-sdk\tools下的android.bat列出不同版本平台的对应id编号命令1::android.bat list targets命令2:android list2.2、android update更新现有项目 对已经存在的android工程,我们可以update下(修改平台的版本),这样会自动添加build.xml 等ant 的配置文件示例1C:\Documents and Settings\Administrator>android update project --name Tank -t 11 -p F:\tank 示例2 G:\temp>android update project --name Test -t 15 -p D:\workspace\test Updated project.properties Updated local.properties Updated file D:\workspace\test\build.xml <wbr></wbr> 2.3、打包 在Android工程中,我们可以使用ant release或ant debug来打包apk。实例2

D:\workspace\test>ant release Buildfile: D:\workspace\test\build.xml 在使用antrelease或antdebug打apk包时,默认使用当前目录的build.xml配置来进行打包。 当然我们可以使用-buildfile选项来制定build.xml配置文件。 实例3

call ant release -buildfile test\build.xml

实例4文件1 config.bat

set out_dir=.\out set out_file_name=Appstore5_Phone set NO=%Date:~0,4%%Date:~5,2%%Date:~8,2% set t=%Time% if "%t:~0,1%" ==" " ( set t=0%t:~1% ) set NO=%Date:~0,4%%Date:~5,2%%Date:~8,2%%t:~0,2%%t:~3,2%%t:~6,2% set out_file_name=%out_file_name%_%NO%.apk 文件2 build.bat

call config.bat pushd dependency call build.bat popd call android update project -p Appstore5_Utils -t android-8 call ant release -buildfile Appstore5_Utils\build.xml call android update project -p Appstore5_Download_Install -t android-8 call ant release -buildfile Appstore5_Download_Install\build.xml call android update project -p Appstore5_Common -t android-8 call ant release -buildfile Appstore5_Common\build.xml call android update project -p Appstore5_Phone -t android-9 call ant release -buildfile Appstore5_Phone\build.xml if not exist %out_dir%\ mkdir %out_dir% if exist %out_dir%\%out_file_name% del %out_dir%\%out_file_name% /q copy /y Appstore5_Phone\bin\Loft-release.apk %out_dir%\%out_file_name% pause 文件3 dependency\build.bat

call android update project -p lepay_Res -t android-8 call ant release -buildfile lepay_Res\build.xml call android update project -p lepush_Res -t android-8 call ant release -buildfile lepush_Res\build.xml call android update project -p leuser_Res -t android-8 call ant release -buildfile leuser_Res\build.xml 三、签名 只要在Android工程的project.properties进行示例3类似的配置,在使用Ant打包时,Ant就会对生成的apk文件进行签名. 示例3 文件project.properties中

has.keystore=true has.password=true key.store=debug.keystore key.alias=androiddebugkey key.store.password=android key.alias.password=android 这里的数字签名文件debug.keystore和project.properties处于同一目录。 关于请签名参考《Android应用程序签名简介》四、混淆打包关于使用Ant混淆打包的知识请参考《Android的代码混淆》五、其他* install:安装调试构建的包到运行着的模拟器或者设备; * reinstall * uninstall

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。