Import a jar file into flutter android plugin and use it in android studio 3.6.1

Viewed 4121

I imported a JAR file by creating libs folder in my project roots -> copy and pasted the JAR file into the libs folder -> right click on the JAR file and click Add As Library. How do I use the imported JAR in my code? the JAR file is xxx.jar. Thanks.

2 Answers

Can you specify what jar it is exactly?

Other than that you can call it at the top of your code by typing

"import XYZ.XYZ.XYZ" replace with the folder name and name of your jar etc.

You can also go to File > Project Structure > Dependencies and below Declared dependencies you can add your jar file.

I add my SDK to libs folder in android folder and than:

  1. Select the android folder from your project
  2. Right-click on it, go to -> Flutter -> Open project in android studio.
  3. Go to File->Project Strucuture-> Dependencies.
  4. Select the name of plugin (you should ad dependency here, not in app or All Modules)
  5. Click on the "+" button to add a new dependency

after that you can import your classes in your plugin.

Related