0

I am trying to create flutter plugin, but unfortunately I have some problems. When I run flutter run command, I see output:

Couldn't read file LocalFile: 'E:\Workspace\vision-plugin\android\src\main\kotlin\com\example\VisionPlugin.kt' even though it exists. Please verify that this file has read permission and try again.

I think the main problem is how is organized my android directory. My plugin class exists under:

E:\Workspace\vision-plugin\android\app\src\main\kotlin\com\example\VisionPlugin.kt

instead of

E:\Workspace\vision-plugin\android\src\main\kotlin\com\example\VisionPlugin.kt

(there is an extra app directory, which is my gradle module). I was wondering if there is a way to make flutter to read from direcory which includes app directory. In my pubspec.yaml, I have defined:

flutter:
  plugin:
    androidPackage: com.example
    pluginClass: VisionPlugin

Does anyone faced this issue and knows how to solve it? I have to keep app directory, as its gradle module. I've introduced modules, because I needed to add third-party .aar file, which is later used in my plugin So my project has a structure:

vision_plugin
 |_android
   |_app
     |_src
     |_build.gradle
   |_some-library
     |_some-library.aar
     |_build.gradle
   |_buid.gradle
   |_settings.gradle
 |_ios
 |_example
 |_lib
 |_test
 |_pubspec.yaml
  • Why not make a new project `flutter create -t plugin --androidx --org=org.someorg pluginName`. Run it immediately with `cd pluginName/example; flutter run` then open it in the IDE and copy across anything useful from the original. – Richard Heap Apr 20 '20 at 18:01
  • @RichardHeap I've updated my message. I think that I have to keep app directory in my project, as I need additional module `some-library` with .aar file in android part. – Adrian Kaczmarek Apr 21 '20 at 16:18
  • 1
    Does this help? https://stackoverflow.com/questions/50971022/how-to-use-local-aar-inside-flutter-plugin/57075972#57075972 – Richard Heap Apr 21 '20 at 17:20
  • It looks very useful, will check this. Thank you! – Adrian Kaczmarek Apr 21 '20 at 17:37

0 Answers0