Android Gradle Plugin 3.0.0-alpha4 - not picking .so libraries from local AAR

牧云@^-^@ 提交于 2020-04-12 18:26:47

问题


I'm currently migrating my Android project to the latest version of the Android Gradle Plugin in order to use it with Android Studio 3.0.

Everything seems to be working fine except for the fact that .so native libraries files I have in a local AAR file are not packaged into the final APK. There is no lib folder inside it.

My project was already defining two flavor dimentions and I don't see any error or warning about it, so I think that's not the problem.

Android Gradle Plugin:

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

Gradle version is 4.0.

The local AAR is added using the New Module... option in Android Studio and it has always worked.

That's the build.gradle generated:

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

And in the application build.gradle I declare it as usual like this:

implementation project(':NAME_OF_THE_MODULE')

Am I missing a breaking change? Is the following known issue related to my problem? While using this plugin with Android Studio, dependencies on local AAR files are not yet supported.

Update: the old flatDir trick still works fine:

flatDir {
  dirs 'libs'
}

Then copy the AA inside that folder (i.e. app/libs) and declare it as a dependency in this way:

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

回答1:


in my case using "api" solved the problem.

instead of using:

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

use:

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

inside of build.gradle in your library project

And for more information see:

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



来源:https://stackoverflow.com/questions/44785068/android-gradle-plugin-3-0-0-alpha4-not-picking-so-libraries-from-local-aar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!