简体   繁体   English

在没有eclipse的情况下将android项目编译为apk

[英]Compile android project to apk without eclipse

What I have done is I have taken the class-files from my eclipse project and run them trough an optimizer/obfuscator. 我所做的是我从我的eclipse项目中获取了类文件,并通过优化器/混淆器运行它们。 So I now have optimized class-files that I want to get in the form of an apk so I can sign and publish it. 所以我现在已经优化了我想以apk形式获取的类文件,因此我可以签名并发布它。 However, I am lost on how to do this. 但是,我迷失了如何做到这一点。 I guess I cant just copy them into the bin-folder of my eclipse-project, because eclipse would just overwrite them with a new compilation when I try to export a signed apk. 我想我不能将它们复制到我的eclipse项目的bin文件夹中,因为当我尝试导出已签名的apk时,eclipse会用新的编译覆盖它们。 So how do I create an apk from these class-files? 那么如何从这些类文件创建一个apk呢?

you can try to put them in bin/classes and then use "ant" command to build your application 你可以尝试将它们放在bin / classes中,然后使用“ant”命令来构建你的应用程序

cd /path/to/my/app
ant release

it will ask you every time for your private key to sign the app, it can be configured to auto-sign by editing "build.properties" file: 每次都会要求您为私钥签署应用程序,可以通过编辑“build.properties”文件将其配置为自动签名:

key.store=release.keystore
key.alias=release
key.store.password=my_key_password
key.alias.password=my_key_password

you can also investigate Android SDK, find the ANT build scripts it actually uses, and insert your custom obfuscator/optimizer call in middle of build process. 您还可以调查Android SDK,找到它实际使用的ANT构建脚本,并在构建过程中插入自定义混淆器/优化器调用。

Here's an example: 这是一个例子:

android create project \
--target 1 \
--name MyAndroidApp \
--path ./MyAndroidAppProject \
--activity MyAndroidAppActivity \
--package com.example.myandroid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM