Android Gradle Tip II: Favorite command line

Source: Internet
Author: User

Command line

Many of the students do Android development soon, accustomed to using the graphical interface, the command line operation is very unfamiliar and even fear. Encountered as run error, helpless.
As in order to ensure ease of use, but also in the UI interface to block a lot of command line running details, resulting in many people feel as difficult to use.
In this case, I often encounter the problem of user integration using the Bugtags SDK. In fact, the operation of the GUI interface, in most cases, is also based on command tools. If you get used to the command line, you'll love it because it's simple, straightforward, and deep.

Typical error

As just launched, StackOverflow asked the most questions, that is, when entering the project, has been in:

Gradle: resolve dependancies ‘_debugCompile‘

State, has been unable to advance, in the end what the IDE is doing? I can't see it.

a command line

When users encounter problems, I most often remind users to use the project root directory, run as command line:

mac:./gradlew clean build --info > bugtags.logwindows:gradlew.bat clean build --info > bugtags.log

This command line means running clean and build two gradle tasks, and opening the info parameter to output more information, eventually outputting all output information to the Bugtags.log file in the project root directory. The user sent me this file, and I can usually analyze the problem based on this output file.
Assume that the command line removes the redirect output directive:

./gradlew clean build --info

The information will be output in the console, the typical error mentioned just now, which may be:

In fact, is downloading a relatively large file, do not panic, you have to do is just wait! As for what is being downloaded. I would like to describe in detail in the next article.
If you have a good understanding of the basic command-line knowledge, the front is enough, if you want to learn more, please continue.

Where the extension runs

When I give this command, the most common question is where to run. The answer is the console (Terminal).

Control Desk

Under Mac, there are terminal (BASH/ZSH, etc.), under Windows, either PowerShell or CMD.
Key point:

├── gradlew├── gradlew.bat

As when using Gradle, to be flexible, or to respond to the fast iterations of the Gradle system, it is recommended to use the Wrapper:gradlew that place Gradle in the project root to achieve different versions.
Therefore, running commands in the console is mainlygradlewDeal. This wrapper, under Mac, is a file with Execute permissions:gradlew, under Windows, is a batch file:gradlew.bat
Typically, your Mac runs under the current directory under the executable file:

./gradlew xxx

Under Windows, run the batch file under the current directory as follows:

gradlew.bat xxx
Terminal Plug-in

As (Intellij idea) has made a very useful plugin:

Clicking Terminal,as will help you do the following:

  • Analog Open Terminal
  • CD to the current project root directory quick Locate folder The IDE also supports dragging and dropping a folder in the project into the Terminal window for quick positioning to this folder:
    Use Help to know what Gradle commands are running parameters, which can be used:
    $ ./gradlew --helpUSAGE: gradlew [option...] [task...]...
    To get. Several important parameters are listed below. Build a specified moduleas the recommended structure ismultiple projectStructure, under one project, to manage multiple module, if you want to build all of project every time, a bit of a waste of time, you can use-p moduleparameter, where module is the module you want to build:
    $ ./gradlew -p app clean build
    Explicitly specifying that there is a dependency on a command that does not execute a taskgradle, such as a build task, is dependent on a series of other tasks, and if you want to specify that a task is not executed, you can use the-x taskparameter, where the task is the one to ignore, and this parameter can be passed multiple times.
    $ ./gradlew build -x test -x lint
    Summary gradle command line There are a lot of other tricks, the above is only listed in my daily use of the most of the few. Interested can leave a message in-depth discussion. Reference mac-terminal
    Windows-terminal
    You got a problem? In the article under the message or add QQ Group: 453503476, hope to help you.
    To receive the latest blog post in time, please pay attention to:
    "Mobdev" Public number QR code
?

Android Gradle Tip II: Favorite command line

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.