Android Gradle Basic Practice

Source: Internet
Author: User
Tags testng jcenter

1,gradle is a new IDE programming environment with Android Studio integrated with Gradle IDE

2, to download gradle (for example, gradle-2.10) decompression. Configure environment variables. For example G:\Program files\android\android studio\gradle\gradle-2.10

3. Create a Gradle Project

cmd command line mkdir projectName, create project folder

Gradle init--type java-library. Creating modules written in the Java language

Gradle Init--type groovy-library; creating modules written in groovy language

4. View Build.gradle files in the project folder

/* * This build file is auto generated by running the Gradle ' init ' task * by ' user ' at ' 16-4-13 Trickle example 崍 2:05 ' with Gradle 2.1 0 * * This generated file contains a sample Java project to get started. * For more details take a look at the Java Quickstart chapter in the Gradle * User Guide available at https://docs.gradle.  org/2.10/userguide/tutorial_java_projects.html *///Apply The Java plugin to add support for javaapply plugin: ' java '//' This section, you declare, where to find the dependencies of your projectrepositories {    //use ' jcenter ' for resolving Your dependencies.    You can declare any maven/ivy/file repository here.
    Mavenlocal ()//MAVEN local library
    maven{url ' XXXXX '}//maven
    Mavencentral ()//direct to the Web under    jcenter ()}//in this section you declare the dependencies for your production and test Codede pendencies {    //The Production code uses the SLF4J logging API at compile time    compile ' org.slf4j:slf4j-api:1.7.13 '    //Declare the dependency for your favourite test framework, you want to use in your tests.    TestNG is also supported by the Gradle Test task. Just Change the    //testcompile dependency to Testcompile ' org.testng:testng:6.8.1 ' and add    //' test.usetestng () ' to your build script.    Testcompile ' junit:junit:4.12 '}

5. Repositories is therefore the package configuration; Apply plugin: ' Java ' is the import Java module

6,gradle dependencies Download the corresponding package based on the configuration in the dependency


See the junit:4.12 and Org.slf4j-api unit test and log output packages downloaded.

Android Gradle Basic 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.