Build an Android Studio project on the intranet using Gradle

Source: Internet
Author: User

In an Android studio project, the default remote repository is Jcenter, and if some class libraries are referenced in the project, Gradle will download these dependent class libraries from the Jcenter Web site to local when the program is built, as we Build.gradle uses the following dependencies:

dependencies {    compile ' de.hdodenhof:circleimageview:2.1.0 '}

The download address is: https://jcenter.bintray.com/de/hdodenhof/circleimageview/2.1.0/

The local cache address is: C:\Users\xxx (user name)\.gradle\caches\modules-2\files-2.1\de.hdodenhof\circleimageview\2.1.0

These three directories store files in turn Circleimageview-2.1.0.pom,circleimageview-2.1.0.aar,circleimageview-2.1.0-sources.jar

If there is no network or if we set Gradle to offline mode, Gradle will use these cache files and no longer connect Jcenter to obtain these dependent packages

Many companies in the office network, taking into account the security, confidentiality and other factors, is not allowed to connect to the external network or inaccessible to Jcenter, then how to use Gradle build Android program in the network? This is a difficult question, ah, let me give up the beloved Butterknife,rxjava ...? Do you want me to copy a bunch of jar packages into the Libs directory?

Smart programmers are obviously not going to do this, research, and found that in the context of the network, we can still happily use Gradle to build Android projects

This assumes that extranet computer A, intranet PC B, if we need to use Circleimageview in the project, then copy the Circleimageview class library in a cache to the corresponding directory in the Android SDK Extras directory in B.

Copy the Circleimageview-2.1.0.pom,circleimageview-2.1.0.aar,circleimageview-2.1.0-sources.jar file cached in A to B in xxx ( Android SDK directory) \extras\m2repository\de\hdodenhof\circleimageview\2.1.0 Directory

If we use Butterknife in our project, here are the following:

dependencies {    compile ' com.jakewharton:butterknife:8.4.0 '    annotationprocessor  ' Com.jakewharton: Butterknife-compiler:8.4.0 '}

So how do we use Butterknife in the intranet? Since the Butterknife project references the Javapoet,auto-common,auto-service class library, we also need to place these libraries in the Extras directory

 

Build an Android Studio project on the intranet using Gradle

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.