Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
665 views
in Technique[技术] by (71.8m points)

java - cordova plugin add external .aar file (not .jar)

I am writing a plugin to use the native android SDK of filepicker https://github.com/Ink/filepicker-android.

On maven central, they only provide an .aar file (http://search.maven.org/#artifactdetails%7Cio.filepicker%7Cfilepicker-android%7C3.8.13%7Caar) and not a .jar.

If I add this line in my config.xml <source-file src="src/android/filepicker-android-3.8.13.aar" target-dir="libs/" />

the file is copy in libs but not included in the class path during the build via cordova build, so the build failed.

what is the best solution to include a third party library with aar files?

Thank you for your help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After cordova project creation, adding platform, adding plugin is done.

Lets say the aar file are copied in libs folder. ( assume file name is cards.aar )

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

repositories { flatDir { dirs 'libs' } }

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

It works for me!! but one drawback of this solution is .. you need to open the project from platform folder on Android Studio and add the above lines to your build.gradle


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...