Ant automatically compiles and packs and signs Android apps under Windows system--practice

Source: Internet
Author: User

1. Background

Project to a certain extent, before each release, product requirements packaging test, all need to manually export signature apk from Eclipse, it is very troublesome. So I thought about the previously explored ant auto-signature package. Check out the blog you wrote before Windows system ant automatically compiles the packaged and signed Android app-Explore the chapter and try to review it. But there's a whole bunch of questions behind it ...

2. Problem solving Process

1), third-party package in Libs library

If the project simply refers to a third-party jar package, just put the jar package in the Project Libs directory, and Ant compiles the third-party jar package automatically, without any problems.

2), the project cited other library projects

If other library projects are referenced in your project, you will be prompted to add the--subproject parameter after the command to update the other referencing items when you use the Android Update Project command, and at first think there's nothing wrong with this step, Who knows the Build.xml file for the library project is not found later.

BUILD FAILED F:\android\adt-bundle-windows-x86-20140321\sdk\tools\ant\build.xml:471:invalid
Prompt this error, do not worry, after all, can probably know the reason, is because the reference third-party library project has no Build.xml file it. It doesn't matter, we do an Android Update Project command for all third-party projects, allowing them to automatically generate Build.xml and local.properties files in their root directory, which solves the problem.

3), invalid resource directory name:f:\workspace\zlib\bin\res/crunch Error

-code-gen:[mergemanifest] Found Deleted Target file[mergemanifest] merging androidmanifest files into one. [Mergemanifest] Manifest merger disabled. Using project manifest only.     [Echo] Handling aidl Files ...     [Aidl] No aidl files to compile.     [Echo]----------     [echo] handling Renderscript files ...     [Echo]----------     [echo] Handling Resources     ... [AAPT] Generating Resource IDs ...     [AAPT] Invalid resource directory Name:f:\workspace\zlib\bin\res/crunch BUILD failedd:\android\sdk\tools\ant\ Build.xml:601:the following error occurred while executing this line:d:\android\sdk\tools\ant\build.xml:653:the Following error occurred while executing this line:d:\android\sdk\tools\ant\build.xml:698:null returned:1
encountered this error, compile failed, very tricky, completely do not know the reason。 By finding the data, it may be that the Android SDK version is too new (I'm using 22.6.2), and the crunch directory is automatically generated, and ant always does not recognize the compiled resources in the bin directory at compile time.

Two solutions found:

①, turn off eclipse because eclipse automatically generates the Res\bin\crunch directory, delete the bin folder from the project directory, and execute the ant release command on the command line;

②, add in Ant\tools\build.xml or build.xml file of project

<property name= "Aapt.ignore.assets" value= "<dir>crunch:!. Svn:!. git:.*:<dir>_*:! Cvs:!thumbs.db:!picasa.ini:!*.scc:*~ "/>
My practice is to follow ① 's practice, and then add the ② property in the project's Build.xml file, and I don't know if ② 's shielding method will cause other problems anyway, the command line prompts the following

-compile:    [Javac] compiling, source files to/users/rubert/myapp/platforms/android/cordovalib/ant-build/ Classes    [Javac] Warning: [options] Source value 1.5 is obsolete and will be removed in all future releases    [Javac] Warning: [options] target value 1.5 is obsolete and will be removed in all future releases    [Javac] Warning: [options] to hide warnings about obsolete options, use-xlint:-options.    [Javac] Note: Some input files use or overwrite outdated APIs.    [Javac] Note: For more information, please use-xlint:deprecation to recompile.    [Javac] 3 warnings    [Echo] Creating Library output Jar file ...
4), encountered Java file encoding UTF-8 BOM Header signature Error (illegal character \ufeff or \65279)

The problem is obvious, because the file encoding UTF-8 the problem of the signature header, using a text editor to re-save the file as a UTF-8 encoded file without BOM header, OK. I'm using sublime Text 2.

3. Final results

Release:build successfultotal time:1 minute seconds


Ant automatically compiles and packs and signs Android apps under Windows system--practice

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.