iammdsameer
iammdsameer

Reputation: 116

How can I add a .aar file as a package in my flutter android application?

I just received a *.aar file from my vendor, which turned out to be the SDK I need to use to consume their service. But since my application is in Flutter how can I import that SDK and use its methods from my flutter application.

Upvotes: 2

Views: 413

Answers (1)

Hamid Musayev
Hamid Musayev

Reputation: 602

Add .aar files under android/libs/ folder.

Then edit build.gradle like this.

buildscript { 
     repositories { 
         google() 
         jcenter() 
         flatDir { 
             dirs 'libs' 
         } 
     } 
  
     dependencies { 
         classpath 'com.android.tools.build:gradle:4.0.1' 
     } 
 } 
  
 rootProject.allprojects { 
     repositories { 
         google() 
         jcenter() 
         flatDir { 
             dirs 'libs' 
         } 
     } 
 }
dependencies { 
     //rx Android for updating status 
     implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' 
     implementation 'io.reactivex.rxjava2:rxjava:2.2.19' 
  
 //    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') 
  
     implementation files('libs/xUtils-2.5.5.jar') //implementation files('org.xutils:xutils:2.5.+') 
     implementation files('libs/jxl.jar') 
     implementation(name: 'DeviceAPI-20211216', ext: 'aar') 
  
     //implementation files('/Users/apple/Desktop/sdks/flutter/bin/cache/artifacts/engine/android-x64/flutter.jar') 
  
 }

Upvotes: 2

Related Questions