How to Call Native Libraries In Flutter?

· 3 min read
How to Call Native Libraries In Flutter?
How to Call Native Libraries In Flutter?

A native library contains a compiled code for a specific hardware architecture. So, in this article, we will see how to Call Native Libraries In Flutter.

How to Call Native Libraries In Flutter?

So, in order to call native libraries in the flutter application, we need to gather the third-party jars somewhere. Also, don’t put them in the plugin project/android/… folder.

  • Open the plugin project in your IDE. After that add the third-party jars to the Java classpath. In IDE, click Project Structure/Modules/Select pluginName_android / Dependencies tab/Green PlusSign/jars or directories. Later select the individual jars or the whole folder. Leave the scope as compile and don’t check export.
  • Implement your Android-specific code in Java or Kotlin in pluginproject/android/src/main/java/com/yourcompany…/…/ Here you will now be able to use the classes declared by the third-party jars.
  • Add the dependencies to Gradle so that it will compile. In plugin project/android/build.gradle add this at the end – after the android {} section.
    dependencies {
        implementation files('../../../java/someapi/somejar.jar')

    The path must be relative to the pluginproject/android folder. You can specify a whole folder with this syntax instead.

implementation fileTree(dir: '../../../somewhere/somefolder', 
include: ['*.jar'])
  • Run the example application provided in the plugin project.
  • Also, we are not sure why it’s not possible to put the third-party jars in. So, let’s say we will it in, pluginproject/android/lib. But that will cause a dex error in the project. So, leaving them outside of the pluginproject/ folder will work perfectly.


Thanks for being with us on a Flutter Journey!

So, in this article, we have seen how to Call Native Libraries In Flutter. Also, feel free to comment and provide any other suggestions regarding Flutter.

Flutter Agency is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

Flutter Agency is one of the most popular online portals dedicated to Flutter Technology. Daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

Leave a Reply