【问题标题】:Android Gradle Plugin 3.0.0-alpha4 - not picking .so libraries from local AARAndroid Gradle Plugin 3.0.0-alpha4 - 不从本地 AAR 中选择 .so 库
【发布时间】:2017-06-27 16:08:12
【问题描述】:

我目前正在将我的 Android 项目迁移到最新版本的 Android Gradle 插件,以便在 Android Studio 3.0 中使用它。

除了我在本地 AAR 文件中的 .so 本机库文件未打包到最终 APK 之外,一切似乎都运行良好。里面没有lib文件夹。

我的项目已经定义了两个风味维度,我没有看到任何错误或警告,所以我认为这不是问题。

Android Gradle 插件:

classpath 'com.android.tools.build:gradle:3.0.0-alpha4'

Gradle 版本是4.0

本地 AAR 是使用 Android Studio 中的 New Module... 选项添加的,并且一直有效。

这是生成的build.gradle

configurations.maybeCreate("default")
artifacts.add("default", file('FILENAME.aar'))

在应用程序build.gradle 中我像往常一样声明它:

implementation project(':NAME_OF_THE_MODULE')

我是否错过了重大变化? 以下已知问题与我的问题有关吗? While using this plugin with Android Studio, dependencies on local AAR files are not yet supported.

更新:旧的 flatDir 技巧仍然可以正常工作:

flatDir {
  dirs 'libs'
}

然后复制该文件夹中的 AA(即app/libs)并以这种方式将其声明为依赖项:

implementation(name: 'libvlc', ext: 'aar')

【问题讨论】:

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


【解决方案1】:

在我的情况下,使用“api”解决了这个问题。

而不是使用:

implementation(name: 'libvlc', ext: 'aar')

使用:

api(name: 'libvlc', ext: 'aar')

在您的库项目中的 build.gradle 内部

有关更多信息,请参阅:

https://blog.mindorks.com/implementation-vs-api-in-gradle-3-0-494c817a6fa https://developer.android.com/studio/build/dependencies.html

【讨论】:

    猜你喜欢
    • 2017-11-22
    • 2015-02-24
    • 2017-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-18
    • 2018-07-06
    相关资源
    最近更新 更多