How to add external libraries

welcome all,


i need this library for testing,learning pupose in my extension code(i use ant)

here it is mentioned as i can add a library and said how to do it but i want a step by step guide for this specific library please say how to do it instead of saying there are many such topic or linking those i have searched but can't understand for my need
@ewpatton sir i hope you will help me
thanks,

If you have the jar file of the project then you can do it easily, else you need to put the main code of the library into the src folder and then use.

where can i get that file i read in the link i need jar file but i don't know how to get it please say where it is
in this lib

If it doesn't has, and if you need to use it, you have to create it, it's easy.

how to do it

Step : 1

Download JAR or AAR or both file into your computer or laptop.

Step : 2 (In case of AAR)

Change the file extension from .aar to .zip and open zip file and extract .jar file.

Step : 3

Past your .jar and .aar file into lib folder.
path is : appinventor-sources/appinventor/lib

Step : 4

Add path of external libraries into build.xml file.
Path is : appinventor-sources/appinventor/components/build.xml
Reference : see this

Step : 5

Add @UsesLibraries annotation into your code.
Example : @UsesLibraries(libraries = "example1.jar," + "example2.jar")
Reference: see this

2 Likes

The problem is he cannot get the .jar / .arr file.

1 Like

Where is the file in this git repository

you can search into maven or you can contact developer

Doing a quick search for the library gives me the following results. I'm not sure which version you need, but you can find out by reading the documentation.

4 Likes

what is it is it .jar file

Here is the arr file :

https://mvnrepository.com/artifact/com.yalantis/ucrop/2.2.0

okay i will try

yes now i got the .jar file ,
i added this code in components/build.xml as said in docs
<copy toFile="${public.deps.dir}/ucrop.jar" file="${lib.dir}/ucrop/ucrop-2.2.0-javadoc.jar" />

now i coded in java file as

package edu.hifiapps.Croppy;
import android.content.Context;
import android.util.Log;
import com.google.appinventor.components.annotations.;
import com.google.appinventor.components.runtime.
;

import android.app.Activity;

import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

import android.net.Uri;

import android.text.TextUtils;

import android.util.Log;

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.AndroidViewComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;

import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.common.YaVersion;

import com.google.appinventor.components.runtime.errors.YailRuntimeError;

import com.google.appinventor.components.runtime.util.AnimationUtil;
import com.google.appinventor.components.runtime.util.ErrorMessages;
import com.google.appinventor.components.runtime.util.NougatUtil;
import com.google.appinventor.components.runtime.util.YailList;

import java.io.File;
import com.google.appinventor.components.runtime.util.*;
import android.graphics.Bitmap;
import android.media.Image;
import android.net.Uri;

@DesignerComponent(version = 1, description = "this extension is used to make cropping easy made by
" +"hifi apps. contact here-<br><a href='https://sites.google.com/view/hifiappcoders' target='_blank'>website</a><br>",
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = "https://i.ibb.co/pnVG9xf/picture.png")

  @SimpleObject(external = true)

public class Croppy extends AndroidNonvisibleComponent {
@UsesLibraries(libraries = "ucrop.jar")
private ComponentContainer container;
private Context context;
/**
* @param container container, component will be placed in
*/

public Croppy (ComponentContainer container) {
super(container.$form());
this.container = container;
this.context = container.$context();
}
}

and got error while compiling

please help

You need to put it above @DesignerComponent annotation.

i will try

it worked :star_struck:

1 Like

here is the jar,aar all files

also @bartmathijssen can i get .jar file for all respository

No. You cannot find jar for every repo.

Then should I google it how to create .jar file