1

I'm trying to create a plugin that relies upon AWS' Mobile SDK (In Java). It says to put

implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar') { transitive = true }

inside the app/build.grade. However, when I'm developing that plugin as per the documentation, there is no app/ folder within the plugin's android root (there is one in the example project, but I don't think that's where I'm supposed to put it).

Specifically, I'm creating the plugin using this command:

flutter create --template=plugin hello

Where should I put this? Should I download the .jar itself, and put it in the project.

Cheers.

Richard Heap
  • 48,344
  • 9
  • 130
  • 112
haz
  • 2,034
  • 4
  • 28
  • 52

2 Answers2

5

When using a plugin, add your gradle dependencies in [projectFolder]/android/build.gradle. At the bottom, below the android section, add a dependencies section like this:

android {
    compileSdkVersion 27

    defaultConfig {
        minSdkVersion 16
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        disable 'InvalidPackage'
    }
}

dependencies {
    implementation('com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar') { transitive = true }
}

Then run the example application provided by the plugin project. Gradle will fetch the dependencies.

Richard Heap
  • 48,344
  • 9
  • 130
  • 112
  • 1
    What if you have the file locally and it's not hosted anywhere? Like a local jar for example. – MisterJimson May 15 '20 at 12:43
  • @MisterJimson see https://stackoverflow.com/questions/50020347/calling-native-libraries-in-flutter-using-platform-channels/50026052#50026052 – Richard Heap May 15 '20 at 13:12
  • Worked like a charm) My mistake was to add dependencies into [projectFolder]/android/app/build.gradle instead that resulted in my plugin not being able to see added dependencies. Moving it to [projectFolder]/android/build.gradle solved the problem – Shpand Nov 11 '21 at 09:52
-1

You need to create a plugin package for that

flutter create --template=plugin hello

--template=package is for packages that contain only Dart code.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • I think that's actually what I ran, and I wrote the wrong thing in the question (sorry). Anyhow, I ran that command exactly and I have the same issue. There is no `/app` directory in the `/android`. Should I be doing this a different way? – haz Apr 26 '18 at 06:33
  • Why are you looking for an `app/` directory anyway? https://github.com/flutter/plugins/tree/master/packages/ contains lots of examples – Günter Zöchbauer Apr 26 '18 at 06:52