如何在 Android Studio 中构建 CHAQUOPY Android 库(.AAR 或 .JAR 文件)

How to build CHAQUOPY Android library (.AAR or .JAR file) in Android Studio

我正在尝试使用 chaquopy https://chaquo.com/chaquopy/ android 插件来开发一个 android 应用程序,该应用程序使用 python 脚本进行一些严肃的计算,我想做应用程序模块作为 android 库 (.AAR),以便能够在其他项目中重用它。 (例如离子应用程序)。

当我按照此处的建议将 apply plugin: 'com.android.application' 更改为 apply plugin: 'com.android.library' 时:https://developer.android.com/studio/projects/android-library 然后重新同步项目 gradle,我收到此错误:

Could not get unknown property 'applicationVariants' for object of type com.android.build.gradle.LibraryExtension.

谷歌搜索后我得到了这个解决方案:

所以我将applicationVariants.all改为libraryVariants.alltestVariants.all

但是错误依然存在,无法构建项目。

图片:

所以https://chaquo.com/chaquopy/不能嵌入到android库中?

从 Chaquopy 版本 8.0.0 开始支持此功能。有关详细信息,请参阅 the documentation

The Chaquopy plugin can also be used in an Android library module (AAR). However, it can only be used in one module in a project: either in the app module, or in exactly one library module. Attempting to use it in multiple modules will give the error “More than one file was found with OS independent path”.

Chaquopy 的最新版本允许在模块/AAR 中使用插件。每个项目仅适用于一个模块:

The Chaquopy plugin can also be used in an Android library module (AAR). However, it can only be used in one module in a project: either in the app module, or in exactly one library module. Attempting to use it in multiple modules will give the error “More than one file was found with OS independent path”.

请看:https://chaquo.com/chaquopy/doc/current/android.html