Can not run flutter project , file picker error - flutter

I have used file picker in my project , after upgrading my dependencies I can not run my project .
The error is given bellow :
/snap/flutter/130/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/../../../../lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so)
Failed to load module: /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so
Launching lib/main.dart on sdk gphone x86 in debug mode...
Warning: The plugin flutter_local_notifications requires Android SDK version 33.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
Warning: The plugin file_picker requires Android SDK version 33.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
Warning: The plugin url_launcher_android requires Android SDK version 33.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
/snap/flutter/130/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/../../../../lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so)
Failed to load module: /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so
/home/d0tb0t/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-5.2.5/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerDelegate.java:215: error: method getParcelableArrayList in class Bundle cannot be applied to given types;
return bundle.getParcelableArrayList("selectedItems", Parcelable.class);
^
required: String
found: String,Class<Parcelable>
reason: cannot infer type-variable(s) T
(actual and formal argument lists differ in length)
where T is a type-variable:
T extends Parcelable declared in method <T>getParcelableArrayList(String)
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':file_picker: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 4m 0s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
want to run my app without error

from i read from your error, you need to upgrade your android SDK to 33 from this
The plugin flutter_local_notifications requires Android SDK version 33.
The plugin url_launcher_android requires Android SDK version 33
change your android SDK to a higher version in your Android -> App -> Build.gradle
defaultConfig {
.....
minSdkVersion 19
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
and it should work properly now :)

Related

One or more plugins require a higher Android SDK version error

One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to D:\Flutter Projets\scheduler\android\app\build.gradle:
android {
compileSdkVersion 33
...
}
2
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\lijoj\Documents\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\Users\lijoj\Documents\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 7s
Exception: Gradle task assembleDebug failed with exit code 1
Go into the Android -> App -> build.gradle and set targetSdkVersion and compileSdkVersion to 33
Because You have used many plugins in your project and one of them is latest plugin, so latest plugin requires latest Android sdk platfrom.
In your IDE open folder android/app/build.gradle and search for compileSdkVersion(usually inside android attribute) and in from of that replace 'flutter.compileSdkVersion' with '33'.

Exception: Gradle task assembleDebug failed with exit code 1 flutter project

I am running one of my old flutter project in the latest version of android studios and I am facing the issue while running the project please can you help me with this.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.window:window-java:1.0.0-beta04.
AAR metadata file: C:\Users\disha.gradle\caches\transforms-2\files-2.1\625039eaad011f884ddd84f857a44b7f\jetified-window-java-1.0.0-beta04\META-
INF\com\android\build\gradle\aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.window:window:1.0.0-beta04.
AAR metadata file: C:\Users\User_Name.gradle\caches\transforms-2\files-2.1\a78fdf90e4c1f8464b19895cfb365f3f\jetified-window-1.0.0-beta04\META-INF\c
om\android\build\gradle\aar-metadata.properties.
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 8s
Running Gradle task 'assembleDebug'... 9.5s
Exception: Gradle task assembleDebug failed with exit code 1
Solution of the error
the error is kind of obvious , As the log says
"The minCompileSdk (31) is greater than this module's
compileSdkVersion (android-30)"
which means you are trying to run a project with a minimum android api version of 31 on the emulator or device with the android api version of 30 .
Solution 1 : Reduce the SDK version for the project (Which is not recommended because you have increased it for a reason )
Solution 2 : Change the emulator or the device for debug .
For more guides on android api version : check here
But you might run into more gradle failures , AS ALWAYS , hope not but if you did please make a new issue .
What you need to do is to update your build.gradle file in android/app folder.
Set the following to this values:
compileSdkVersion 31
minSdkVersion 19 or (Lower if you want to cater older versions)
targetSdkVersion 31

App requires Multidex support in flutter?

I'm getting this error while building my app in Flutter. it seems the problem that the multidex is not enabled even though I did everything needed to enable it. this the error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeProjectDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Type androidx.activity.R$attr is defined multiple times: C:\Users\Abdul rehman\OneDrive\Desktop\CSC451\Capstone Project\harfanah\build\app\intermediates\project_dex_archive\debug\out\4b5c628c7fbb96e2839e63f71f8803802c039de25c33dd9c9475187dc45e6e1a_1.jar:classes.dex, C:\Users\Abdul rehman\OneDrive\Desktop\CSC451\Capstone Project\harfanah\build\app\intermediates\project_dex_archive\debug\out\9bd7ed05083b8d3edbf142363966d832d9f0694faefda4d175e3ad8ad18fc06d_1.jar:classes.dex
* 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 30s
[!] App requires Multidex support
Flutter multidex handling is disabled. If you wish to let the tool configure multidex, use the --mutidex flag.
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I have already checked all of the solutions.
enabled Multidex support and used the latest version:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.harfanahApplication.harfanah"
minSdkVersion 21
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
.
.
.
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation("androidx.multidex:multidex:2.0.1")
}
I also added these to gradle.properies
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
Still it is not working. any suggestions?
Have you tried "flutter clean" and then rebuild? You can let the Flutter CLI tool do it for you with "flutter build --multidex".
use flutter clean and
flutter pub get
then you will get a notification on whether you need to install it or not.
type y (yes) to it .then use flutter run
I had the same issue on a Mac M1(2021). To debug on an android device, I extended #AntEdode's solution a bit:
flutter build apk --multidex --debug
During build, the same error will pop up, however the SDK will now ask whether or not you want to install multidex:
[!] App requires Multidex support
Multidex support is required for your android app to build since the number of methods has exceeded 64k. You may pass the --no-multidex
flag to skip Flutter's multidex support to use a manual solution.
Flutter tool can add multidex support. The following file will be added by flutter:
android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java
Do you want to continue with adding multidex support for Android? [y|n]:
After confirmation - voila:
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
To run on your emulator:
flutter run --multidex

Flutter - Execution failed for task ':app:multiDexListDebug'

After adding the plugin webview_flutter_plus and after adding this line in android:usesCleartextTraffic="true" in your <project-directory>/android/app/src/main/AndroidManifest.xml under application
and Required Permissions line
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
I am facing the below error. Can anyone help me out to get this fixed?
Error :
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:multiDexListDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Type io.flutter.plugins.webviewflutter.WebViewFlutterPlugin is defined multiple times: C:\Users\Admin\Downloads\flow-0.1-master\build\webview_media\intermediates\runtime_library_classes\debug\classes.jar:io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.class, C:\Users\Admin\Downloads\flow-0.1-master\build\webview_flutter\intermediates\runtime_library_classes\debug\classes.jar:io/flutter/plugins/webviewflutter/WebViewFlutterPlugin.class
* 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 1m 47s
Exception: Gradle task assembleDebug failed with exit code 1
If your minSdkVersion is set to 21 or higher, multidex is enabled by default and you do not need the multidex support library.
Below 21 API
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation 'com.android.support:multidex:1.0.3' // add latest dependency
}
Have you tried enabling multiDex in android folder -> app folder -> build.gradle file?
defaultConfig {
multiDexEnabled true
}
this happens because the library you are using uses the same dependences.
in my case,i use package
flutter html : 1.0.0
youtube_player_flutter: ^6.1.0
and both packages use the same dependences, namely webview_flutter so that the error is
io.flutter.plugins.webviewflutter.WebViewFlutterPlugin
Solution
in VSCode Search (Ctrl+Shift + P)
in your error io.flutter.plugins.webviewflutter.WebViewFlutterPlugin search for keywords webview.
Find a library that uses the same dependences, then update to the latest package version.(Work for me)
This solution will keep the library you are using without deleting it.
flutter html : 1.0.0
youtube_player_flutter: ^7.0.0

Why did I get an error by adding TextToSpeech?

I tried to intigrate a text to speech Funktion in my (Flutter) app, but if I write flutter_tts: ^0.8.6 under dependencies:, how I saw it in a tutorial, I get an error.
That´s the Code in the pubspec.yaml:
dependencies:
flutter_tts: ^0.8.6
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
and this is the error:
C:\Users\...\Desktop\tts_app\android\app\src\debug\AndroidManifest.xml Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:flutter_tts] C:\Users\...\Desktop\tts_app\build\flutter_tts\intermediates\library_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.tundralabs.fluttertts" to force usage (may lead to runtime failures)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:flutter_tts] C:\Users\Simon\Desktop\App Entwickeln\Projekte\tts_app\build\flutter_tts\intermediates\library_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.tundralabs.fluttertts" to force usage (may lead to runtime failures)
* 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 3s
Finished with error: Gradle task assembleDebug failed with exit code 1
TTS Plugin needs your android version to be greater than API Level 21.
but in the
Android/app/build.gradle
file that value is still 16.
change it to 21 as following and you will be ok.
defaultConfig {
applicationId "com.example.eventtweb"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}