如何使用新的摇篮Android编译系统手动包括外部AAR包 [英] How to manually include external aar package using new Gradle Android Build System

查看:350
本文介绍了如何使用新的摇篮Android编译系统手动包括外部AAR包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试新的Andr​​oid构建系统,我碰到的一个小问题。我编译我自己的AAR包ActionBarSherlock的,我已经叫'actionbarsherlock.aar。我想要做的其实就是用这个AAR建立我最后的APK。如果我包括整个ActionBarSherlock库作为一个Android库模块来使用编译项目我主要的项目。(:actionbarsherlock'),我能够成功地建立一个没有任何问题。

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.

但我的问题是,我想提供这种依赖作为一个AAR文件包手动只是我是否一个JAR,然后我似乎无法弄清楚如何正确地包含到我的项目。我已经尝试使用编译的配置,但是这似乎并没有工作。我不断获取找不到编译它告诉我,从AAR包classes.jar是没有得到包含在类路径中的符号。

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.

有谁知道语法的手动包括AAR包中的文件?

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

build.gradle

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"
}

编辑:因此,答案是,它目前不支持,这里的问题,如果​​你想跟踪它。

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

编辑:目前,因为这仍然不支持直接最好的选择似乎是从@RanWakshlak建议的解决方案

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

编辑:另外通过使用建议@VipulShah语法简单

Also simpler by using the syntax proposed by @VipulShah

推荐答案

我发现多了一个解决方法(我测试了它在Android工作室0.5.6 +摇篮0.9+)

假设你已经在libs文件夹中保存AAR文件。 (假设文件名为 cards.aar

Lets say you have kept aar file in libs folder. ( assume file name is cards.aar )

然后在app <​​code> build.gradle 指定下面,然后点击同步项目摇篮文件。

then in app build.gradle specify following and click sync project with Gradle files.

repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile(name:'cards', ext:'aar')
}

如果一切顺利的话,你会看到库条目是在构建 - >爆炸-AAR

If everything goes well you will see library entry is made in build -> exploded-aar

这篇关于如何使用新的摇篮Android编译系统手动包括外部AAR包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆