Importing .aar file into kivy app

175 views
Skip to first unread message

Simple Pleasures by Aswini

unread,
Sep 21, 2022, 12:26:54 AM9/21/22
to Kivy users support
I want to import .aar file into kivy app ,i tried it by using pyjnius by accessing directly java class mentioning path of java class, i saw in some answers where to add .aar in buildozer. But i dont know how to import a file (.aar) and use in kivy app.  .Pls help me to solve this 

Robert

unread,
Sep 21, 2022, 12:59:41 AM9/21/22
to Kivy users support
You already know what you need to know. Though you will have a learning curve as you learn to use what you know. Practice and research is the answer to that.

1) Specifying the .aar in buildozer.spec is what causes the .aar to be included in the app.

2) The Pyjnius autoclass statement imports the Java class, an overview here:

Though you probably don't know the following, which is a possible pitfall:

Before you start check that the Java version used to build the aar is not newer than the Java version you installed for Buildozer.
If the arr is built with a newer Java you will get an error message similar to this:

Simple Pleasures by Aswini

unread,
Sep 21, 2022, 2:16:32 AM9/21/22
to Kivy users support
But when i tried to run "no class found error" ,so i need to know whether it is run only on android devices ,right?

Robert

unread,
Sep 21, 2022, 2:42:31 AM9/21/22
to Kivy users support
Well clearly buildozer.spec is for building for Android.

Alternatively you can read the Pyjnius install instructions for Linux or Windows
I've never used Pyjnius on a Desktop OS, so I won't try to answer any questions on that. Maybe somebody else will....

Simple Pleasures by Aswini

unread,
Sep 22, 2022, 1:50:55 AM9/22/22
to Kivy users support
class =autoclass("org.TestClass")
like this i tested a sample java class in a folder using pyjnius and mentioned the folder in buildozer..apk build succesfully .i want to know Is the same way to call java api for accessing class in .aar file ? or could u pls share a sample code

Robert

unread,
Sep 22, 2022, 3:02:24 AM9/22/22
to Kivy users support
I don't understand the question, I see you say that you can access a Java class. But then you ask if this the way.......

Same link again:

Simple Pleasures by Aswini

unread,
Sep 23, 2022, 12:46:47 AM9/23/22
to Kivy users support
means i want to know how to write  java api to access aar file
"class =autoclass("org.TestClass")"---- in this call org is the folder have java class "TestClass" .is this the same way to call java class in aar file 

Robert

unread,
Sep 23, 2022, 2:12:49 AM9/23/22
to Kivy users support
Sort of, I think you need to read about java packaging, particularly the Package statement.
Java classes are reference by their package.
For .java files there is (by convention?) a relationship between the Package statement and file hierarchy. Clearly that is not true for packaged Java.
But I'm not the one to give you a java tutorial (because I don't want to and I'm not qualified).

Simple Pleasures by Aswini

unread,
Sep 23, 2022, 2:19:39 AM9/23/22
to Kivy users support
k thanks for the help
Reply all
Reply to author
Forward
0 new messages