Search code examples
androidjarandroid-libraryaarchaquopy

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


I am trying to use chaquopy https://chaquo.com/chaquopy/ android plugin for developing an android app that uses python script for some serious calculations, and I would like to make the app module as an android library (.AAR) to be able to reuse that in other project. (.eg ionic app).

When I change apply plugin: 'com.android.application' to apply plugin: 'com.android.library' as suggested here: https://developer.android.com/studio/projects/android-library then resync project gradle, I get this error:

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

After googling it I get this solution: could not get unknown property for 'applicationVariants' for BuildType_Decorated

So I change applicationVariants.all to libraryVariants.all or testVariants.all.

But the error is still present, and cant build the project.

Image:

error

So https://chaquo.com/chaquopy/ can not be imbedded in android library?


Solution

  • This is now supported starting in Chaquopy version 8.0.0. See the documentation for details.

    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”.