Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add plain Android library to a Flutter plugin

This might be a duplicate of this question. But it has no answer and I will give some details here.

I have created a module with File->New Module->Android Library inside my Flutter plugin's android project. And now I have a structure like below:

|-my_plugin
  |-android
    |-settings.gradle
    |-build.gradle
    |-mylibrary
      |-build.gradle

/android/settings.gradle:

rootProject.name = 'my_plugin'
include ':mylibrary'

/android/build.gradle:

...
dependencies {
  implementation project(':mylibrary')
}

When I build example plugin project (which is automatically created by Flutter CLI) with flutter build apk or flutter run, I get this error:

Project with path ':mylibrary' could not be found in project ':my_plugin'.

Any suggestions?

like image 975
Sait Banazili Avatar asked Apr 02 '19 13:04

Sait Banazili


People also ask

Can I use Android library in Flutter?

You can directly call native Android and iOS SDKs of Tokbox chat app from your Flutter application — wherein the UI will be driven by Tokbox SDKs. Since this approach uses native UIs of each platform, the app developer is devoid of any responsibility to create working UIs on both the Android and iOS platforms.

How do you add gradle in Flutter?

First step : open your project and then go to : File->Settings->Build, Execution, Deployment->Build Tools-> Gradle. Add the path of your Gradle in The Android Studio as shown bellow.


1 Answers

For those who are still looking for a solution. You can try this.

Instead of putting the below code in the plugin setting.gradle, place it in example/android/settings.gradle

include ':mylibrary'
like image 176
Panda World Avatar answered Sep 22 '22 19:09

Panda World