Native extensions: import additional packages in android?

R Ruben Ruben 3 years ago
1 1 0

Hi,

I'm trying to build a native extension that makes use of several external java packages. However, when I try to load them, the import always fails. I'm not very sure where to place the .java files for the packages; i've tried several locations without luck:

in my extension implementation, I try:

import com.abc.defgh.Test;
...

Then, I try to place Test.java in:
- extensions\myext\copilot\ext\platform\android\src\com\abc\defgh\Test.java
- extensions\myext\copilot\ext\platform\android\generated\src\com\abc\defgh\Test.java

It fails always with: error: package com.abc.defgh does not exist

Using the CLASSPATH env. variable doesn't work either.

I haven't done anything with Java in a while; sorry if this is a silly question, but i'm not sure if this something specific to Rhomobile or not.

Thanks!

Please register or login to post a reply

1 Replies

R Ruben Ruben

I've found the answer myself: it turns out that if you need additional .java files for android, you have to addin extensions/extension-name/ext/platform/android/ext_java.files an additional line with the url of the .java file.

This way, you are able to import them inside your java implementation for the native extension.

CONTACT
Can’t find what you’re looking for?