Wesley DaBes
Wesley DaBes

Reputation: 117

How do I implement an SDK into a Flutter project

I am trying to implement an SDK written in Java with 3 .aar files into a Flutter project. I added the .aar files to

myFlutterApp > android > app > libs 

and in my build.gradle dependencies I added

implementation(name: 'mysdk-internal', ext: 'aar')
implementation(name: 'mysdk-common', ext: 'aar')
implementation(name: 'mysdk-android', ext: 'aar')

Is this the correct way to go about implementing this? I am familiar with adding dependencies through the pubspec.yaml file of the Flutter project, but when I tried to add this to the dependencies, I received the error 'Can't find pubspec.yaml file in myFlutterApp/android/app/libs'. Is there a step that I am missing? Or have I done it correctly and if so, how to I reference these in code?

Upvotes: 0

Views: 825

Answers (1)

Wesley DaBes
Wesley DaBes

Reputation: 117

I resolved this by learning further about gradle. In my app level gradle.build, I added:

android {
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
        main.java.srcDirs += 'src/main/kotlin'
    }
}

and changing the dependencies to:

dependencies {
    implementation(files("libs/drive-internal.aar"))
    implementation(files("libs/drive-common.aar"))
    implementation(files("libs/drive-android.aar"))
}

Upvotes: 0

Related Questions