How to use an android library (.aar file) in Ionic with Capacitor

问题描述 投票:0回答:1

我需要使用来自 android 设备的库,它是在一个带有 Ionic 的项目中以 aar 文件传递给我的,我无法集成它。搜索我发现的所有内容是它应该制作一个 Cordova 插件,但我正在使用 Capacitor。

我需要能够将它集成到项目中并与打字稿一起使用。

android ionic-framework capacitor aar
1个回答
0
投票

如果有人遇到同样的问题,我所做的是使用命令“npm init @capacitor/plugin”创建一个 Capacitor 插件。问题是在插件中包含 .aar 库时出现错误,因为它会自行编译为 .aar 库。您必须将 .aar 库放在插件和项目的 /android/libs 中,并在插件的 build.gradle 文件中,将其添加为“compileOnly files('libs/[lib_name].aar')”而不是一个实现。

© www.soinside.com 2019 - 2024. All rights reserved.