Flutter Exception while using file picker package - flutter

Iam using these all packages to my flutter project
dependencies:
flutter:
sdk: flutter
upi_pay: ^0.2.4
google_fonts: ^1.1.0
file_picker: ^2.0.3
image_picker: ^0.6.0+9
qr_code_scanner: ^0.0.13
image_gallery_saver: ^1.5.0
permission_handler: ^5.0.1+1
flutter_full_pdf_viewer: ^1.0.6
fluttertoast: ^7.1.1
flutter_barcode_scanner: ^1.0.1
flutter_google_places: ^0.2.6
google_map_location_picker: ^3.3.5
flutter_local_notifications: ^1.4.4+1
While using this i got such an exception
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> File 'com.android.builder.files.ZipCentralDirectory#76fc0a16' was deleted, but previous version not found in cache
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> File 'com.android.builder.files.ZipCentralDirectory#2670b2c8' was deleted, but previous version not found in cache
* 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.
==============================================================================
If I removed file_picker: ^2.0.3 & flutter_full_pdf_viewer: ^1.0.6 from this project, I didn't get any of the exception. In same case if use this both packages(only) in new project no such exception is coming.
Please give a solution for this issue. Thanks in Advance!

flutter upgrade resolves this issue.

I have added file_picker 4.5.1. Below steps solved my issue
upgrade gradle version at build/gradle classpath
classpath 'com.android.tools.build:gradle:4.1.0'
upgrade distributionUrl at android>gradle>gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
Finally Invalidate caches and restart studio
You can also delete .gradle under Android folder.

Related

Flutter Error: cannot find symbol import com.google.firebase.firestore.TransactionOptions

Since the latest update to Cloud Firestore 3.4.3 I cannot build the Flutter app anymore.
/Applications/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/android/src/main/java/io/flutter/plugins/firebase/firestore/streamhandler/TransactionStreamHandler.java:13: error: cannot find symbol
import com.google.firebase.firestore.TransactionOptions;
^
symbol: class TransactionOptions
location: package com.google.firebase.firestore
/Applications/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3/android/src/main/java/io/flutter/plugins/firebase/firestore/streamhandler/TransactionStreamHandler.java:66: error: package TransactionOptions does not exist
new TransactionOptions.Builder().setMaxAttempts(maxAttempts).build(),
^
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 9s
Exception: Gradle task assembleDebug failed with exit code 1
Exited
I tried removing the folder /Applications/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.4.3 and performing flutter clean. Moreover I downgraded cloud_firestore to 3.3.0, but the folder was reinstalled with the same 3.4.3 version.
Any suggestion?
Here's everything I did to get that error gone.
Per this link:
flutter upgrade --force --verbose&&flutter update-packages --force-upgrade&&flutter pub upgrade --major-versions
Add to my main.dart:
import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart' show FirebaseAuthPlatform;
Run flutter pub get -- notice no improvement.
So, additionally, I upgrade my pubspec.yaml manually:
firebase_core: ^1.21.0
cloud_firestore: ^3.3.0
firebase_auth: ^3.6.4
firebase_auth_platform_interface: ^6.5.4
cloud_firestore_odm: ^1.0.0-dev.27
Run flutter pub upgrade && flutter pub get
Now it works.

I had an error when I ran my program while using Shared_Preferences Flutter

I wanted to use the latest version of Shared Preferences but when I ran pub get, it creates some error so I downgraded the plugin and the up b get works successfully but when I ran my app, this is what it said.
Launching lib\main.dart on INE LX2 in debug mode...
Running Gradle task 'assembleDebug'...
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/shared_preferences-0.5.12+4/lib/shared_preferences.dart:14:8: Error: Error when reading '../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/shared_preferences_windows-0.0.2+3/lib/shared_preferences_windows.dart': The system cannot find the path specified.
import 'package:shared_preferences_windows/shared_preferences_windows.dart';
^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/shared_preferences-0.5.12+4/lib/shared_preferences.dart:40:53: Error: Method not found: 'SharedPreferencesWindows'.
SharedPreferencesStorePlatform.instance = SharedPreferencesWindows();
^^^^^^^^^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\me\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\me\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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 2m 57s
Exception: Gradle task assembleDebug failed with exit code 1
This is my pubspec.yaml dependency:
dependencies:
flutter:
sdk: flutter
carousel_slider: ^2.3.1
assets_audio_player: ^2.0.13+1
hive: ^1.4.4+1
path_provider: ^1.6.27
hive_flutter: ^0.3.1
flip_card: ^0.4.4
speech_recognition: ^0.3.0+1
easy_localization: ^2.1.0
translator: ^0.1.2
permission_handler: ^3.1.0
swipedetector: ^1.2.0
shared_preferences: ^0.5.7+3
I used this plugin because I saw one problem that tackles this problem in another Stack overflow. But still it did not solve the problem.
I first use shared_preferences version 0.5.10 and I had the same error so I downgraded to ver 0.5.7+3 and I still have this error. What should I do? If ever you need additional info please let me know, thank you.

Flutter CachedNetworkImage Could not resolve all artifacts for configuration ':path_provider:classpath'

After adding the CachedNetworkImage dependency to my Flutter project and trying to flutter run using vscode (& Intellij..) the following exception was thrown:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':path_provider'.
> Could not resolve all artifacts for configuration ':path_provider:classpath'.
> Could not find sdklib.jar (com.android.tools:sdklib:26.3.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/sdklib/26.3.0/sdklib-26.3.0.jar
> Could not find apkzlib.jar (com.android.tools.build:apkzlib:3.3.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/apkzlib/3.3.0/apkzlib-3.3.0.jar
> Could not find apksig.jar (com.android.tools.build:apksig:3.3.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/apksig/3.3.0/apksig-3.3.0.jar
> Could not get unknown property 'android' for project ':path_provider' of type org.gradle.api.Project.
* 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 17s
Exception: Gradle task assembleDebug failed with exit code 1
I got the following dependencies in the pubspec.yaml file:
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cached_network_image: ^2.5.0
cupertino_icons: ^1.0.0
curved_navigation_bar: ^0.3.7
flutter_launcher_icons: ^0.8.1
flutter_riverpod: ^0.12.4
http: ^0.12.2
material_floating_search_bar: ^0.2.6
shimmer: ^1.1.2
I'm using the latest pre-nullsafety versions, since I'm not ready for flutter 2.0 yet.
I don't think the blocked <dl.google.com> domain is the reason since I have the VPN on and can download the required jars externally..
If you got any insights on why I'm getting this error please share your ideas, I've been on it for the whole day :(
There are few possible solutions for this problem:
Do a flutter clean on the terminal then flutter pub get.
or remove the version on the package from cached_network_image: ^2.5.0 to cached_network_image:. Then do the 1st solution again (But try to avoid using this solution)
But if ever this 2 solutions would not work and you're goal is just caching images there is an alternative to this without using the CachedNetworkImage package.
NetworkImage class and Image.network() both do cached images.
Here's a link that might help you when you try Image.network()
: https://www.youtube.com/watch?v=7oIAs-0G4mw

Flutter Session (Could not get resource)

[Solved]
I went for an older version as jeugene suggested to solve the below problem. The unavailable version is "0.1.1", the version I used is "0.0.7".
I keep getting the bellow error every time I try using the flutter_session package on a project. I've been wondering if there's someone out there who has had my kind of problem and can propose a solution.
Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.3.21/kotlin-stdlib-1.3.21.jar'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.3.21/kotlin-stdlib-1.3.21.jar'. > jcenter.bintray.com: Temporary failure in name resolution > Could not get unknown property 'android' for project ':shared_preferences' of type org.gradle.api.Project. * 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 2m 10s Exception: Gradle task assembleDebug failed with exit code 1
My pubspec.yaml has these;
dependencies:
flutter:
sdk: flutter
flutter_svg: ^0.18.1
http: ^0.12.2
flutter_session: ^0.1.1
geolocator: ^6.0.0
geocoder: ^0.2.1
headup_loading: ^1.0.3
and I have these is the main.dart file;
import 'package:flutter_session/flutter_session.dart';
Is there something am doing wrong?
Is the spacing of the dependencies correct. Extra space can create errors in pubspec.yaml. Another possibility is that the specific version might not be available. Try older version of the same.

flutter project compilation failing with "Execution failed for task 'fluttertoast:compileDebugJavaWithJavac'" AndroidX

I am answering my own question here because I solved it after many hours of searching. This is NOT an already answered question, so please don't tag it as such. I wish it was, it would've saved me hours of frustration.
Flutter project is failing with this error. Fluttertoast error.
??: ?? ContextCompat
??: ? FluttertoastPlugin
2 ???
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':fluttertoast:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 26s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
The underlying issue is that the android.support.v4.Content.ContextCompat import in fluttertoastplugin.java can't resolve the symbol ContextCompat. This is a dependency issue.
The solution is to go to your flutter project's pubspec.yaml and find the fluttertoast dependency and update it to the latest version (currently ^3.1.0)
dependencies:
flutter:
sdk: flutter
dropdown_formfield: ^0.1.0
camera: ^0.5.2+1
fluttertoast: ^3.1.0 <----- THIS ONE
path_provider: ^1.1.0
video_player: ^0.10.1
latlong: ^0.6.1
google_maps_flutter: ^0.5.11+1
http: ^0.12.0
flutter_blue: ^0.5.0
flutter_bluetooth_serial: ^0.0.5
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
In my case. I updated all dependencies in pubspec.yaml and it worked.
In my case all I did was run
flutter clean
and rerun project and everything worked fine.