1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter project wont build successfully after adding some packages from pub.dev

Discussão em 'Mobile' iniciado por Stack, Outubro 7, 2024 às 09:52.

  1. Stack

    Stack Membro Participativo

    My flutter app fails the build process when i add a dependency in my pubspec.yaml file

    I noticed it happens when i add webview_flutter: ^4.9.0 or shared_preferences with the error below

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':webview_flutter_android:compileDebugJavaWithJavac'.
    > Could not resolve all files for configuration ':webview_flutter_android:androidJdkImage'.
    > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
    > Execution failed for JdkImageTransform: C:\Users\Hi\AppData\Local\Android\Sdk\platforms\android-34\core-for-system-modules.jar.
    > Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\Hi\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\Hi\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}

    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    > Get more help at https://help.gradle.org.

    BUILD FAILED in 22s
    Error: Gradle task assembleDebug failed with exit code 1



    This is the error message for shared_preferences package

    Resolving dependencies...
    Downloading packages...
    collection 1.18.0 (1.19.0 available)
    firebase 9.0.3 (discontinued replaced by firebase_core)
    http 0.13.6 (1.2.2 available)
    http_parser 4.0.2 (4.1.0 available)
    js 0.6.7 (0.7.1 available)
    leak_tracker 10.0.5 (10.0.7 available)
    leak_tracker_flutter_testing 3.0.5 (3.0.8 available)
    lints 5.0.0 (5.1.0 available)
    material_color_utilities 0.11.1 (0.12.0 available)
    meta 1.15.0 (1.16.0 available)
    stack_trace 1.11.1 (1.12.0 available)
    string_scanner 1.2.0 (1.3.0 available)
    test_api 0.7.2 (0.7.3 available)
    vm_service 14.2.5 (14.3.0 available)
    Got dependencies!
    1 package is discontinued.
    13 packages have newer versions incompatible with dependency constraints.
    Try `flutter pub outdated` for more information.
    Launching lib\main.dart on SM G986U in debug mode...
    Running Gradle task 'assembleDebug'...

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':shared_preferences_android:compileDebugJavaWithJavac'.
    > Could not resolve all files for configuration ':shared_preferences_android:androidJdkImage'.
    > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
    > Execution failed for JdkImageTransform: C:\Users\Hi\AppData\Local\Android\Sdk\platforms\android-34\core-for-system-modules.jar.
    > Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\Hi\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\Hi\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}

    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    > Get more help at https://help.gradle.org.

    BUILD FAILED in 58s
    Error: Gradle task assembleDebug failed with exit code 1



    Once i remove that dependency, the projects builds as normal

    I recently updated to the latest android studio version and that was when the issues started. Before that my project was building fine without any problems even with those mentioned packages. I then reset my pc and installed everything from scratch and i seem to be facing the same issue again. i also tried adding those problematic dependencies using terminal but it didnt solve the issue.

    Any help will be much appreciated

    This is my pubspec.yaml

    name: myportfolio
    description: "An annoying flutter project"
    publish_to: 'none' # Remove this line if you wish to publish to pub.dev

    version: 1.0.0+1

    environment:
    sdk: ^3.5.1

    dependencies:
    flutter:
    sdk: flutter
    provider: ^6.1.2
    glassmorphism: ^3.0.0
    glassmorphism_ui: ^0.3.0
    sliding_up_panel: ^2.0.0+1
    # webview_flutter: ^4.9.0
    ionicons: ^0.2.2
    toast: ^0.3.0
    cloud_firestore: ^5.4.4
    internet_connection_checker: ^1.0.0+1
    loading_indicator: ^3.1.1
    timeago: ^3.7.0
    flutter_bloc: ^8.1.6
    bloc: ^8.1.4
    firebase_core: ^3.6.0


    # The following adds the Cupertino Icons font to your application.
    # Use with the CupertinoIcons class for iOS style icons.
    cupertino_icons: ^1.0.8
    shared_preferences: ^2.3.2

    dev_dependencies:
    flutter_test:
    sdk: flutter

    flutter_lints: ^5.0.0

    flutter:

    uses-material-design: true

    Continue reading...

Compartilhe esta Página