【问题标题】:local .aar file cannot be supported不支持本地 .aar 文件
【发布时间】:2016-05-20 09:09:10
【问题描述】:

我尝试将本地.aar 文件添加到项目中,正如here 所描述的那样,因为我不想在每次更改库代码时都执行this 例程。

所以在我的项目build.gradle 文件中我添加了:

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
}

我的库和我的应用程序都有两种风格 - alphaTestmyRelease。我希望每个库都严格添加到应用程序的相应风格中。

在我的应用程序的build.gradle 中,我有以下dependencies 块:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar', '**/*.aar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    alphaTestCompile files ('libs/myLib-alphaTest-release.aar')
    myReleaseCompile files('libs/myLib-myRelease-release.aar')
}

不幸的是,我总是收到这种错误:

Error:Project myApp: Only Jar-type local dependencies are supported. Cannot handle: C:\Users\...\myApp\libs\myLib-myRelease-release.aar

我尝试使用这种格式

alphaTestCompile  ('my.package:libs/myLib-alphaTest-release:0.1@aar')

还有这个

alphaTestCompile  (name:'myLib-alphaTest-release', ext:'aar')

但在这种情况下,gradle 无法解析文件。

我怎样才能使.aar文件也被编译?

【问题讨论】:

标签: android android-studio android-gradle-plugin android-library


【解决方案1】:

以下是我使用aar 文件的配置:

//dependencies
compile fileTree(include: ['*.jar'], dir: 'libs') // dont change anything here
compile(name: 'yourLib', ext: 'aar') // yourLib.aar is put in libs folder

repositories {
     flatDir {
         dirs 'libs'
     }
}

【讨论】:

  • 你的台词和我的台词有什么本质区别?
  • @user2957954 完全不同。 1.fileTree,2.编译aar库
  • 不!你有相同的文件树(我也有'*.aar')并且你实现了我的一种编译格式。
猜你喜欢
  • 2021-09-23
  • 2020-07-07
  • 2015-10-23
  • 2019-06-21
  • 1970-01-01
  • 1970-01-01
  • 2016-06-04
  • 1970-01-01
  • 2019-04-15
相关资源
最近更新 更多