Flutter plugin development Unresolved reference: io

9,604

Solution 1

Solved the problem by following these steps from this issue on github.

  1. Delete the .idea folder in the project (do not know if is needed but just to be sure)
  2. In Android Studio click on Open an existing Android studio project and select the folder your_plugin/example/android (It's important to open your_plugin/example/android first and then your_plugin).

Solution 2

Shahzad Akram's answer didn't work for me but another tip from the given github link did:

Add the following to the module's build.gradle:

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

after the other apply declarations, and

flutter {
    source '..'
}

at the bottom.

Edit: It looks like the extra lines need to be commented out for the depending project to build; definitely not ideal

Solution 3

In my case I had to:

  1. Open the Flutter Project on Android Studio
  2. Open the file located on android/src/main/kotlin/com/example/flutter_your_plugin/FlutterYourPlugin.kt
  3. Android Studio will suggest you to Open for Editing in Android Studio

PS: My Android Studio Version: Android Studio Arctic Fox | 2020.3.1 Patch 3 Android Studio Suggestion

Share:
9,604
Shahzad Akram
Author by

Shahzad Akram

Updated on December 12, 2022

Comments

  • Shahzad Akram
    Shahzad Akram over 1 year

    Its my first attempt to create a flutter plugin, I created flutter plugin project from android studio and its running fine, when I tried to add platform specific code for android I stuck in some issues, in the same project platform specific code editing is almost dead (no linting). I imported MyPluginProject/android in android studio and there are also some issues,

    Unresolved reference: io
    

    enter image description here

    Here is output of flutter doctor

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, v1.7.8+hotfix.2, on Linux, locale en_US.UTF-8)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    [✓] Android Studio (version 3.4)
    [✓] Connected device (1 available)
    
    • No issues found!
    
  • Suragch
    Suragch over 4 years
    I don't think you need to delete the .idea folder. It works without it.
  • JoKr
    JoKr about 4 years
    Did not help me :(
  • JoKr
    JoKr about 4 years
    Actually it did help. I didn't realize I need to open two projects. First example/android and then library android.
  • Subtain Malik
    Subtain Malik over 3 years
    I think there is also a need of replacing this to FlutterEngine(this), as a solution