Dowemo
0 0 0 0


Question:

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 'actionbarsherlock.aar'. What I'm trying to do is actually use this aar to build my final APK. If I include the whole ActionBarSherlock library as an android-library module to my main project using compile project (':actionbarsherlock') I'm able to build successfully without any problems.

But my problem is that I want to provide that dependency as a aar file package MANUALLY just if I would a JAR then I can't seem to figure out how to properly include it into my project. I've attempted to use the compile configuration but this doesn't seem to work. I keep on getting cannot find symbol during compile which tells me that the classes.jar from aar package isn't getting included in the classpath.

Does anyone know of the syntax to manually include an aar package as a file?

build.gradle

buildscript {
 repositories {
     mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:0.4'
  }
}
apply plugin: 'android'
repositories {
   mavenCentral()
}
dependencies {
    compile files('libs/actionbarsherlock.aar')
}
android {
    compileSdkVersion 15
    buildToolsVersion "17.0"
}

EDIT: So the answer is that it's not currently supported, here's the issue if you want to track it.

EDIT: Currently as this is still not supported directly the best alternative seems to be the proposed solution from @RanWakshlak

EDIT: Also simpler by using the syntax proposed by @VipulShah


Best Answer:


I've just succeed!

  • copy mylib-0.1.aar file under libs/ folder

  • add these lines to bottom of build.gradle [should be app, not project]

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

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

    So you have to be sure that you have enabled Offline work checkbox in Project Structures/Gradle

    -- OR --

    configured proxy settings in order to access network.

    In order to configure proxy settings you have to modify gradle.properties file of project 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 <for NT auth>
    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 <for NT auth>

    Hope this works..




    Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs