I have two native extension,A.java in one and B.java in another, how can I import A.java from B.java?
BTW, A.java have different package than B.java.
Currently, it’s not possible. We’d like the same feature for C++ as well, in order to build extensions with more commonly used functionality (e.g OpenSSL etc)
I didn’t find a ticket for it though, so I created one: DEF-3348
I don’t think it will be done until a few months from now though.
So,is it isolated between extensions?Extension can only be used by lua or script or gui_script?
Extension can be used by script and gui_script and module.
If you have A.java and B.java you could merge them into the same extension as well.
OK,got it
I put A.java and B.java into one extension, and A.java with first line package a.b.c.d, B.java with first line package e.f.g.h;
when I import a.b.c.d; in B.java, It builds failed.How can I fix this?
What does the error say?
It says:
cannot find symbol
import xxxxxxx;
It should be possible, we just did such a test:
A.java
package a.b.c.d;
public class A {
public static void LOL()
{
System.out.println("LOL");
}
}
B.java
package e.f.g.h;
import a.b.c.d.A;
public class B {
public static void LOL2() {
A.LOL();
}
}
Here is the full extension we used:
testext.zip (1.3 KB)
OK,I’ll try it out.
Does the java file must be in the src folder?I found if I place A.java outside src folder, It won’t be bundled in classes.dex
Yes, the source files need to be placed in the src
folder: https://www.defold.com/manuals/extensions/