Hello.
I try to write an extension to get calendar events.
in this extension i use:
JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
of course i have import com.google.api.client.json.JsonFactory;
there is no compil error, but when i import my extension in app inventor and built app, app can't works it cratch as soon as it open
I refine my extention in order to point where was the problem,
so here it is. it does nothing but declare a JsonFactory ....
to built the extension i use git bash ant extensions
how do I include the jar in the extension ?
if i write this line import com.google.api.client.json.JsonFactory; - google-http-client-1.22.0.jar
i get a compil error:
error: class, interface, or enum expected
[javac] import com.google.api.client.json.JsonFactory; - google-http-client-1.22.0.jar
I added librairies as you told me but it doesn't work either....even if there is no problem in companion...only my phone crashs
(I stored .jar in app inventor lib folder)
you're brobably rigth but i spent lot of time to find a way to built extensions few years ago and i use it may be once a year so i'm not motivated to leanr an other way...
In addition to your own Java code, you can also include external libraries, by following the steps in How to Add a Component. The library jar files will be included in the aix file when you package your extension
Hello Taifun
i already edited the components/build.xml to include the folder where i put my jar files.
it seems there were a mistake in syntax so i corrected my line with: @UsesLibraries(libraries ="google-api-client-1.22.0.jar,"+"google-api-services-calendar-v3-rev20220715-2.0.0.jar,"+"google-api-services-storage-v1-rev78-1.22.0.jar,"+"google-http-client-1.22.0.jar,"+"google-http-client-gson-1.42.1.jar,"+"google-http-client-jackson2-1.22.0.jar,"+"google-oauth-client-1.22.0.jar" )
This was not a syntax error since this annotation accepts both forms.
public @interface UsesLibraries {
/**
* The names of the libraries separated by commas.
*
* @return the library name
*/
String libraries() default "";
/**
* The names of the libraries (as an array)
*
* @return the array of library names
*/
String[] value() default {};
}
Debug your application using Logcat. You may find that some classes are still missing.
You can also open your extension with e.g. winrar, and see if it contains the right classes.