Skip to content

Can't resolve symbol io.flutter.plugin dependency #19830

Open
flutter/website
#12203

Description

@abacaj

Edit from Flutter team:

Please see #19830 (comment). If following these steps still doesn't resolve the imports, please add a comment with your Android Studio version and the output of flutter doctor -v

Original issue:

I'm trying to build a flutter plugin in Android studio using an example template.

When I open the build.gradle in android studio and gradle resolves dependencies I cannot get these symbols to resolve:

I'm not sure what I'm missing as flutter doctor shows I have all checks.

image

Activity

  1. zoechi commented on Jul 26, 2018

    @zoechi
    Contributor

    Please post the output of flutter doctor -v.

  2. abacaj commented on Jul 26, 2018

    @abacaj
    Author
    PS C:\Users\Anton> flutter doctor -v
    [√] Flutter (Channel master, v0.5.8-pre.79, on Microsoft Windows [Version 10.0.17134.48], locale en-US)
        • Flutter version 0.5.8-pre.79 at C:\Users\Anton\Documents\flutter
        • Framework revision bb338ef2c6 (7 days ago), 2018-07-19 07:24:06 -0700
        • Engine revision 5557e3006e
        • Dart version 2.0.0-dev.67.0.flutter-84ca27a09e
    
    [!] Android toolchain - develop for Android devices (Android SDK 28.0.0)
        • Android SDK at C:\Users\Anton\AppData\Local\Android\sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-28, build-tools 28.0.0
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
        X Android license status unknown.
    
    [√] Android Studio (version 3.1)
        • Android Studio at C:\Program Files\Android\Android Studio
        • Flutter plugin version 26.0.1
        • Dart plugin version 173.4700
        • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
    
    [√] VS Code, 32-bit edition (version 1.24.1)
        • VS Code at C:\Program Files (x86)\Microsoft VS Code
        • Flutter extension version 2.16.0
    
    [!] Connected devices
        ! No devices available
    
    ! Doctor found issues in 2 categories.
    
  3. abacaj commented on Jul 27, 2018

    @abacaj
    Author

    has anyone else had to deal with this? I am not able to build the project in android studio because of those missing symbols.

  4. abacaj commented on Jul 27, 2018

    @abacaj
    Author

    I found a workaround by adding the cached flutter.jar file as a library located in flutter\bin\cache\artifacts\engine\android-x64.

    Not sure if this is the correct approach since it is the cached version and will need to be manually replaced each time, but it does resolve the symbols for me while editing.

  5. rahulgul8 commented on Aug 20, 2018

    @rahulgul8

    https://stackoverflow.com/questions/25660166/how-to-add-a-jar-in-external-libraries-in-android-studio

    this helped me.

    I had to get the jar from flutter\bin\cache\artifacts\engine\android-arm instead of x-86

  6. rohitgupta1694 commented on Nov 28, 2018

    @rohitgupta1694

    I found a workaround by adding the cached flutter.jar file as a library located in flutter\bin\cache\artifacts\engine\android-x64.

    Not sure if this is the correct approach since it is the cached version and will need to be manually replaced each time, but it does resolve the symbols for me while editing.

    In order to resolve flutter dependencies in Android Studio, we need to a flutter.jar file from the flutter project. I also did the same. But, Is it a good way to do it? @zoechi What effect can it have on our flutter project apart from size?

  7. remonh87 commented on Jan 4, 2019

    @remonh87

    I had the same problem but then I found out that the flutter plugin package is recognised when you open the example/android folder in Android studio. Now I can build the project and I can unittest my plugin from Android studio without adding the flutter.jar.

    What I did step for step:

    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

    If you want to build your library through gradle you can run ./gradlew :your_plugin:assembleDebug

  8. kartdroid commented on Mar 1, 2019

    @kartdroid

    I had the same problem but then I found out that the flutter plugin package is recognised when you open the example/android folder in Android studio. Now I can build the project and I can unittest my plugin from Android studio without adding the flutter.jar.

    What I did step for step:

    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`
    

    If you want to build your library through gradle you can run ./gradlew :your_plugin:assembleDebug

    I guess this is the proper way for now

  9. bitsydarel commented on Mar 17, 2019

    @bitsydarel

    I'm also having the same issue, I'm trying to add flutter to our existing gradle project, it's a really big project.
    The flutter plugin need to include another local library which has the platform feature to be used but since gradle can't see the flutter sdk dependency the code does not compile... I don't understand why the flutter team does not provide gradle dependency for the flutter sdk...
    We really want to move our ios and android project to flutter its seems that the tooling is not ready yet...

  10. tolotrasamuel commented on Mar 19, 2019

    @tolotrasamuel

    For those who are confused, why opening the the your_plugin/example/android would allow you to fix this issue and continue editing your plugin, here is the explanation:
    #11632
    Basically, when you open the example/android module, the gradle script will simultaneously attached the plugin directory in the current project and you can edit from there.

  11. bitsydarel commented on Mar 20, 2019

    @bitsydarel

    This structure is not great if you want to integrate it to another native project.

    This break the following use case :
    Mutlit module android root project -> flutter module <- flutter plugins.

    If a flutter plugin need to access native features provided by a module in the root project. including the module in the flutter plugin settings.gradle won't work.
    The flutter example app won't compile.

    The only easy solution would be to publish the module to mavenLocal and then access it in the flutter android library build.gradle...

  12. amorenew commented on Aug 5, 2019

    @amorenew

    I still face the same issue in August 2019

    [√] Flutter (Channel beta, v1.7.8+hotfix.4, on Microsoft Windows)
    [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [√] Android Studio (version 3.4)
    
  13. westracer commented on Aug 6, 2019

    @westracer

    Same issue. Importing flutter.jar fixes resolving, but then project fails to build.

  14. 71 remaining items

  15. yullg commented on Jun 12, 2024

    @yullg

    我在Windows系统下遇到过相同的问题,似乎是项目代码和PUB的缓存目录在不同的磁盘分区导致的。通过PUB_CACHE环境变量将PUB缓存目录修改为和项目代码在相同的磁盘分区后恢复正常。

  16. Code-Remote commented on Jun 12, 2024

    @Code-Remote

    I've tried with different Android Studio versions (Koala rc, Jellyfish patch 2 and 1, Iguana) and different flutter versions (3.22.2 and 3.13.8) and I keep on getting the same unresolved errors.

    I checked stack overflow(https://stackoverflow.com/questions/56965783/flutter-plugin-development-unresolved-reference-io) and all I can find is people saying to delete the .idea folder and open the android folder that is inside of my flutter project as a separate project in Android Studio, but still the lines stay red and keep the "Unresolved reference: io"

    Also, when I have my flutter project open and navigate to the MyPlugin.kt file inside of the android folder that is in the root of my Flutter project it shows this message "Open for Editing in Android Studio", but when I click it nothing happens.

  17. Code-Remote commented on Jun 12, 2024

    @Code-Remote

    @yullg, can you explain the exact steps you've taken to do that and how that can be done on macOS?

    yullg's message translated > I encountered the same problem in Windows system. It seems that the project code and PUB cache directory are in different disk partitions. After changing the PUB cache directory to the same disk partition as the project code through the PUB_CACHE environment variable, it returned to normal.

  18. Code-Remote commented on Jun 14, 2024

    @Code-Remote

    @SEGVeenstra found the solution, you will never guess, apparently if you read the documentation very carefully (😅 🤦‍♂️) You will succeed!

    https://docs.flutter.dev/packages-and-plugins/developing-packages#step-2b-add-android-platform-code-kt-java

    When creating a flutter plugin project called 'hello'

    Before editing the Android platform code in Android Studio, first make sure that the code has been built at least once (in other words, run the example app from your IDE/editor, OR in a terminal execute cd hello/example; flutter build apk --config-only).

    After that

    Launch Android Studio.
    Select Open an existing Android Studio Project in the Welcome to Android Studio dialog, or select File > Open from the menu, and select the hello/example/android/build.gradle file.
    In the Gradle Sync dialog, select OK.
    In the Android Gradle Plugin Update dialog, select Don't remind me again for this project.
    The Android platform code of your plugin is located in hello/java/com.example.hello/HelloPlugin.

    This worked for me!

  19. yusuphwickama commented on Jul 2, 2024

    @yusuphwickama

    @Code-Remote,

    At this point, the plugin generation command should automatically run the extra flutter build apk --config-only command after generating the project.

  20. rekire commented on Jul 25, 2024

    @rekire
    Contributor

    I might found a nice workaround. Check my comment here: flutter/flutter-intellij#7487 (comment)

  21. canxin121 commented on Oct 8, 2024

    @canxin121

    Do not open project/android, instead open project/example/android.

  22. added a commit that references this issue on Jun 4, 2025
    0c0406a
  23. github-actions commented on Jun 18, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  24. locked as resolved and limited conversation to collaborators on Jun 18, 2025
  25. reidbaker commented on Oct 15, 2025

    @reidbaker
    Contributor

    Reopening due to #177053

  26. unlocked this conversation on Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: pluginsSupport for writing, building, and running plugin packagescustomer: crowdAffects or could affect many people, though not necessarily a specific customer.platform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions