【问题标题】:Build AAR with dependencies使用依赖项构建 AAR
【发布时间】:2019-05-20 10:13:54
【问题描述】:

我想构建 .AAR 并在其中包含依赖项。我一直在寻找很多,但没有任何效果。话题太老了。我意识到生成的 .AAR 里面应该有 classes.jar 并且有带有 .class 文件的目录。但我不知道如何在 gradle 中自动化这个过程。

【问题讨论】:

    标签: android gradle plugins aar


    【解决方案1】:

    Android 工具不支持它。有一个 issue open 请求 Google 实施它(请随意给它加星标以表示您的支持并帮助 Google 优先考虑它)。

    与此同时,有两个插件可以尝试修复或解决这种缺乏支持的问题,但对不同功能的支持有限:

    所以,正如你所见,未来并不光明。

    有关更多信息,另请参阅this article

    【讨论】:

      【解决方案2】:

      我们设法使用这个 Mobbeel fat AAR Gradle 插件来做到这一点: https://github.com/Mobbeel/fataar-gradle-plugin

          buildscript {
              repositories {
                  //...
                  maven {
                      url 'https://plugins.gradle.org/m2/'
                  }
              }
          }
      
          //...
      
          dependencies {
              classpath 'gradle.plugin.com.mobbeel.plugin:mobbeel-fataar:1.2.0'
          }
      

      api而不是implementation标记依赖

          apply plugin: 'com.mobbeel.plugin'
      
          dependencies {
              api 'org.greenrobot:eventbus:3.0.0'
              //...
          }
      
          fatAARConfig {
              includeAllInnerDependencies false
          }
      

      这篇文章很有帮助:http://wittchen.io/2018/10/02/creating-fat-aar/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-09-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多