“Could not resolved the package” every install new packages inside my own package

1,679

I Already fix it my issue with adding it to the root project. So I add new package like shimmer 2x, one in shared modules and one in root project.

Not all of it has to be added twice, only those that cause errors are added.

Share:
1,679
R Rifa Fauzi Komara
Author by

R Rifa Fauzi Komara

Updated on December 20, 2022

Comments

  • R Rifa Fauzi Komara
    R Rifa Fauzi Komara over 1 year

    I have some problem about installing new package from pub.dev. I split my architecture using package for implemented modularization. This is my packages (core and shared) inside my project.

    enter image description here

    I create core and shared modules using this command flutter create --template=package name_of_modules.

    Then I installing new package inside core or shared modules. Every I install new package in that modules I always received an error like this:

    Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
    Invalid depfile: /Users/rrifafauzikomara/Downloads/MovieCatalogue/.dart_tool/flutter_build/009f5ba5376d66cb437ddc8aa8ed1cad/kernel_snapshot.d
    Invalid depfile: /Users/rrifafauzikomara/Downloads/MovieCatalogue/.dart_tool/flutter_build/009f5ba5376d66cb437ddc8aa8ed1cad/kernel_snapshot.d
    
    Compiler message:
    Error: Could not resolve the package 'json_annotation' in 'package:json_annotation/json_annotation.dart'.
    core/lib/src/network/api/rest_client.dart:2:8: Error: Not found: 'package:json_annotation/json_annotation.dart'
    import 'package:json_annotation/json_annotation.dart';
           ^
    core/lib/src/network/api/rest_client.dart:39:2: Error: Method not found: 'JsonSerializable'.
    @JsonSerializable()
     ^^^^^^^^^^^^^^^^
    core/lib/src/network/api/rest_client.dart:51:2: Error: Method not found: 'JsonSerializable'.
    @JsonSerializable()
     ^^^^^^^^^^^^^^^^
    Unhandled exception:
    FileSystemException(uri=org-dartlang-untranslatable-uri:package%3Ajson_annotation%2Fjson_annotation.dart; message=StandardFileSystem only supports file:* and data:* URIs)
    #0      StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:33:7)
    #1      asFileUri (package:vm/kernel_front_end.dart:604:37)
    #2      writeDepfile (package:vm/kernel_front_end.dart:799:21)
    <asynchronous suspension>
    #3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:472:15)
    <asynchronous suspension>
    #4      _FlutterFrontendCompiler.compile (package:flutter_frontend_server/server.dart:38:22)
    #5      starter (package:flutter_frontend_server/server.dart:149:27)
    #6      main (file:///b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:8:30)
    #7      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
    #8      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
    
    Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
    Failed to build bundle.
    Error launching application on iPhone 11 Pro Max.
    

    The result of error always about Could not resolved the package, but I can import the package and also use the package. But after I run the project, the error it's showing. This is a bug on Flutter? And how to fix it? Because I need this approach to make my project scalable and also for implemented modularization like in Android native.

    This is my result of flutter doctor -v:

    [✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.2 19C57,
        locale en-US)
        • Flutter version 1.12.13+hotfix.8 at
          /Users/rrifafauzikomara/Documents/flutter
        • Framework revision 0b8abb4724 (3 months ago), 2020-02-11 11:44:36 -0800
        • Engine revision e1e6ced81d
        • Dart version 2.7.0
    
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
        • Android SDK at /Users/rrifafauzikomara/Library/Android/sdk
        • Android NDK location not configured (optional; useful for native profiling
          support)
        • Platform android-29, build-tools 29.0.3
        • Java binary at: /Applications/Android
          Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          1.8.0_212-release-1586-b4-5784211)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 11.4.1, Build version 11E503a
        • CocoaPods version 1.8.4
    
    [✓] Android Studio (version 3.6)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 45.1.1
        • Dart plugin version 192.7761
        • Java version OpenJDK Runtime Environment (build
          1.8.0_212-release-1586-b4-5784211)
    
    [✓] VS Code (version 1.39.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.5.1
    
    [✓] Connected device (1 available)
        • iPhone 11 Pro Max • 641006EC-FDB0-4918-B547-593818B98B05 • ios •
          com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
    
    • No issues found!
    
    • Nux
      Nux over 3 years
      I have exactly the same problem and I can't fix it
    • R Rifa Fauzi Komara
      R Rifa Fauzi Komara over 3 years
      @Nux please read my answer below.
  • krumpli
    krumpli over 3 years
    How did you add it to the root project?