How to manually include external aar package using new Gradle Android Build System

后端 未结 23 1795
故里飘歌
故里飘歌 2020-11-22 03:58

I\'ve been experimenting with the new android build system and I\'ve run into a small issue. I\'ve compiled my own aar package of ActionBarSherlock which I\'ve called \'act

23条回答
  •  北海茫月
    2020-11-22 04:29

    I've just succeeded!

    1. Copy the mylib-0.1.aar file into the libs/ folder

    2. Add these lines to the bottom of build.gradle (should be app, not project):

      repositories {
         flatDir {
             dirs 'libs'
         }
      }
      dependencies {
          compile 'com.example.lib:mylib:0.1@aar'
      }
      
    3. So far so good. Here comes the most important point:

    Gradle needs to access the network for dependencies unless offline mode is enabled.

    Make sure that you have enabled Offline work via the checkbox in Project Structures/Gradle

    -- OR --

    Configure the proxy settings in order to access the network.

    To configure the proxy settings you have to modify the project's gradle.properties file, configuring http and https separately as below:

    systemProp.http.proxyHost=proxy.example.com
    systemProp.http.proxyPort=8080
    systemProp.http.proxyUser=user
    systemProp.http.proxyPassword=pass
    systemProp.http.nonProxyHosts=localhost
    systemProp.http.auth.ntlm.domain=example 
    
    systemProp.https.proxyHost=proxy.example.com
    systemProp.https.proxyPort=8080
    systemProp.https.proxyUser=user
    systemProp.https.proxyPassword=pass
    systemProp.https.nonProxyHosts=localhost
    systemProp.https.auth.ntlm.domain=example 
    

    Hope this works.

提交回复
热议问题