Android Ant and Gradle packaging process and efficiency control

Source: Internet
Author: User
<span id="Label3"></p>one, ant pack: (download ant, Configure environment variable not to Say)<p><p></p></p>1.<span style="font-family:Helvetica,Tahoma,Arial,sans-serif; line-height:25.1875px"><span style="font-family:Helvetica,Tahoma,Arial,sans-serif; line-height:25.1875px">go to command-line mode and switch to the project folder, run for example the following command adds ant build support for an adt-created project:</span></span><p><p></p></p><p style="margin-top:0px; margin-bottom:0px; font-size:14px; padding-top:0px; padding-bottom:0px; font-family:Helvetica,Tahoma,Arial,sans-serif; line-height:25.1875px"><p style="margin-top:0px; margin-bottom:0px; font-size:14px; padding-top:0px; padding-bottom:0px; font-family:Helvetica,Tahoma,Arial,sans-serif; line-height:25.1875px">Android Update Project-p. -t "android-17"</p></p>2.<span style="background-color:inherit">The build script default target is help, so it displays the information above, and changing the target to debug or release will compile, build, and debug like no Ant.<p><p></p></p><p><p><span style="background-color:inherit">3. Add <span style="color:#ff0000; background-color:inherit">signature</span> information to local.properties when using release</span></p></p><p style="margin-top:0px; margin-bottom:0px; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><p style="margin-top:0px; margin-bottom:0px; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"></p></p><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><span style="font-family:Helvetica,Tahoma,Arial,sans-serif; background-color:inherit"><span style="background-color:inherit; line-height:25px">#keystore</span></span></p></p><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><span style="font-family:Helvetica,Tahoma,Arial,sans-serif; background-color:inherit"><span style="background-color:inherit; line-height:25px">Key.store=xx.p12</span></span></p></p><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><span style="font-family:Helvetica,Tahoma,Arial,sans-serif; background-color:inherit"><span style="background-color:inherit; line-height:25px">Key.alias=xxx</span></span></p></p><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><span style="font-family:Helvetica,Tahoma,Arial,sans-serif; background-color:inherit"><span style="background-color:inherit; line-height:25px">Key.store.password=xxx</span></span></p></p><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><span style="font-family:Helvetica,Tahoma,Arial,sans-serif; background-color:inherit"><span style="background-color:inherit; line-height:25px">Key.alias.password=xxx</span></span></p></p><span style="font-family:Helvetica,Tahoma,Arial,sans-serif; background-color:inherit"><span style="font-family:Helvetica,Tahoma,Arial,sans-serif; background-color:inherit"><span style="background-color:inherit; line-height:25px">4, command line run Build.xml:</span></span></span><span style="font-family:Verdana,Arial,Helvetica,sans-serif; line-height:20px"><span style="font-family:Verdana,Arial,Helvetica,sans-serif; line-height:20px">ant-buildfile Build.xml</span></span><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><span style="font-family:Verdana,Arial,Helvetica,sans-serif; line-height:20px"><br style="background-color:inherit"></span></p></p><span style="font-family:Verdana,Arial,Helvetica,sans-serif; line-height:20px"><span style="font-family:Verdana,Arial,Helvetica,sans-serif; line-height:20px">5. Error Handling</span></span><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)">> BUILD failed> c:\android\android-sdk\tools\ant\build.xml:601:the following error occurred while executing this l Ine:> c:\android\android-sdk\tools\ant\build.xml:653:the following error occurred while executing this line:> c \ Android\android-sdk\tools\ant\build.xml:698:null returned:1</pre></pre><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><br style="background-color:inherit"></pre></pre><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)">Also, if eclipse is set to ' build automatically ' then this could keep popping up because eclipse would keep regenerating in to the bin Folder.</pre></pre><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)">Just run '<span style="color:#ff0000; background-color:inherit">ant clean release</span>' instead of ' ant release ' is building This.</pre></pre><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)">RM-FR $ (find-type D-name Crunch|xargs)</pre></pre><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><span style="background-color:inherit; color:rgb(255,0,0)">Ant Clean Release</span></pre></pre><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><pre style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px; background-color:rgb(255,255,255)"><pre style="background-color:rgb(255,255,255); font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px"></pre><pre style="background-color:rgb(255,255,255); font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px">Be able to test my project: https://github.com/mentor811/Android-Batch-Pack</pre><pre style="background-color:rgb(255,255,255); font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; line-height:16px"></pre></pre></pre>second, gradle Packaging 1, Download<span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px">gradle 1.10 Configuring environment variables</span></span><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px">2. Configure the ANDROID environment variable <span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px">android_home</span></span> </span></span><p><p><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"></span></span></p></p><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px">3. Export the build file</span></span></span></span><p><p><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"></span></span></span></p></p><p><p>watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbwfzb25ibg9n/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast "></p></p><p><p><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><span style="color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><br></span></span></span></p></p>4. Change the Build file<p><p>References: Https://github.com/umeng/umeng-muti-channel-build-tool/tree/master/Gradle</p></p>5. operation<p><p></p></p><p style="margin-top:5px; margin-bottom:5px; color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><p style="margin-top:5px; margin-bottom:5px; color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><code style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; font-size:12px; line-height:16px; background-color:inherit">gradle clean</code></p></p><p style="margin-top:5px; margin-bottom:5px; color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><p style="margin-top:5px; margin-bottom:5px; color:rgb(51,51,51); font-family:Georgia,‘Times New Roman‘,Times,sans-serif; font-size:14px"><code style="font-family:Monaco,Consolas,Courier,‘Lucida Console‘,monospace; font-size:12px; line-height:16px; background-color:inherit">gradle build</code></p></p><br>three, Gradle and ant comparison 1, I used to feel gradle than harsh<p><p>a, Androidmanifest.xml in the gaze must <!--before and after the need to have space--</p></p><p><p>b, Chinese gaze may be garbled</p></p><p><p>c, the MINSDK and TARGETSDK in each library project should be consistent with the main project</p></p><p><p>d, the format of PNG images is very strict</p></p><p><p>e, Lint</p></p><p><p>When using ant, without encountering the above problems, the direct success.</p></p>2, Gradle will merge the library project Androidmanifest.xml into the main project. Ant does not 3, the flexibility is absolutely gradle. Configure friends to multi-channel, change the package name configuration is ok, and ant very laborious. 4, Packaging Efficiency Control:<p><p></p></p><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><p style="margin-top:0px; margin-bottom:0px; background-color:inherit; font-family:微软雅黑; font-size:14px; padding-top:0px; padding-bottom:0px"><span style="font-family:Verdana,Arial,Helvetica,sans-serif; line-height:20px">Projects that did not build before the first run</span></p></p>Gradle 2min pk Ant 2min 54 is the time to pack after a build has been run:<span style="font-family:微软雅黑; font-size:14px"><span style="font-family:微软雅黑; font-size:14px"></span></span><p><p>Left Gradle right Ant</p></p><p><p></p></p><p><p><br></p></p><p><p><br></p></p><p><p><br></p></p> <p style="font-size:12px;"><p style="font-size:12px;">Copyright Notice: This article blog original Article. blogs, without consent, may not be reproduced.</p></p> <p><p>Android Ant and Gradle packaging process and efficiency control</p></p></span></span>

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.