Add external libraries to an extension

Hello everybody,
I am trying to develop an extension, but I found a problem that I don't be able to solve.
In my code I have:

Request request = Request.Post("https://tothewebsite.com");
	File f= new File(OBJECT_LOCATION);
	request.bodyFile(f,ContentType.MULTIPART_FORM_DATA);
	request.setHeader("Content-Type", "image/png");
	HttpResponse httpResponse = request.execute().returnResponse();
	System.out.println(httpResponse.getStatusLine());
	if (httpResponse.getEntity() != null) {
		String html = EntityUtils.toString(httpResponse.getEntity());
	System.out.println(html);

When I compile I have some errors like cannot find symbols for example on EntityUtils, ContentType and so on.
I tried to solve with these steps:

  1. I downloaded unzipped and copied into appinventor\lib\http_5.1.3 the file httpcore5-5.1.3.jar

  2. In the folder appinventor\components i opened the file build.xml abd added:
    Add extension libraries here

    copy toFile="${public.deps.dir}/httpcore5-5.1.3.jar" file="${lib.dir}/http_5.1.3/httpcore5-5.1.3.jar"

  3. in the extensions I added before @DesignerComponent:
    @UsesLibraries(libraries = "httpcore5-5.1.3.jar")

but I have the same mistakes.
Do you have any tips to solve?
Thank You
Best regards
Marco

1 Like

Have you imported these classes?

1 Like

Thank You @vknow360 ,
this was the problem, initially I wrote import for the classes but did not work, so I commented then i did it all the things that I wrote above and I forgot to uncomment the import.
Solved Thank You
Best Regards
Marco

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.