Error adding Flutter web-view plugin in version 1.20.4 - flutter

I would like to use flutter-web plugin in my app. However, I am getting the following SDK error when I add it to my YAML file. I just upgraded to 1.20.4
How do I fix this error?
The current Flutter SDK version is 1.20.4.
Because app depends on webview_flutter >=1.0.0 which requires Flutter SDK version >=1.22.0 <2.0.0, version solving failed.
pub get failed (1; Because app depends on webview_flutter >=1.0.0 which requires Flutter SDK version >=1.22.0 <2.0.0, version solving failed.)
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.49.2)
[✓] Connected device (1 available)
• No issues found!
This is the info in my pubspec.yaml file
environment:
sdk: ">=2.2.2 <3.0.0"

webview_flutter package need minSdkVersion 19 so you have to change the app level gradle
android {
defaultConfig {
// Required by the Flutter WebView plugin.
minSdkVersion 19
}
}
after upgrade your flutter using
flutter upgrade
and then import webview_flutter In your pubspec.yaml file
webview_flutter: ^1.0.0 because webview_flutter is stable in flutter 1.22 stable release.

I was facing the same problem but I did not know the path of that build.gradle so I found it after spending some time.
You have to edit the build.gradle file. In a flutter project, it is found at the path ./android/app/build.gradle.
The parameter that needs to be changed is, of course, minSdkVersion 16, bumping it up to what you need (in this case 19).
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.web_view_example"
minSdkVersion 19 //This is what you need to change.
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

For my case, I'm using linkedin_login: ^2.2.1 mean which LinkedIn lib also using webview (iOS is working) but Android it requires to downgrade minSDKVersion to 16. Please open android folder as Android Project in order to see like this. Hope it help you too.

Related

Flutter pub get version solving failed

I'm getting this issue with flutter pub get, tried to update the dart sdk, restart the pc to add the Dart sdk location back to the environment variables, delete the .git folder.
Running "flutter pub get" in calculator...
The current Dart SDK version is 2.13.4.
Because calculator depends on webview_flutter >=2.0.14 which requires SDK version >=2.14.0 <3.0.0, version solving failed.
pub get failed (1; Because calculator depends on webview_flutter >=2.0.14 which requires SDK version >=2.14.0 <3.0.0, version solving failed.)
exit code 1
Flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [version 10.0.19043.1288], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] VS Code (version 1.61.2)
[√] Connected device (3 available)
Dart Version:
Dart SDK version: 2.14.4 (stable) (Wed Oct 13 11:11:32 2021 +0200) on "windows_x64"
Change version of webview_flutter in pubspec.yaml to
webview_flutter: any
When you say you tried updating the Dart SDK, did you update your pubspec.yaml as well?
environment:
sdk: ">=2.14.0 <3.0.0"
Try deleting pubspec.lock and try again
try
flutter upgrade
it worked for me.
I solved the problem after updating Dart Sdk and restarting the pc.
Even after these two steps I still got the same error, so I put any in the package value in pubspec.yaml and before running flutter pub get, I turned off my antivirus.
just put your dependency without version
dependencies:
flutter:
sdk: flutter
file_picker: #put your conflicting dependency as without version

Flutter: no versions of permission_handler match >5.1.0+2 <6.0.0

After upgrading Flutter and Dart to the latest versions I also updated the dependencies of my app. Now, when I run flutter pub get I get the following error:
Because no versions of permission_handler match >5.1.0+2 <6.0.0 and permission_handler 5.1.0+2 depends on permission_handler_platform_interface ^2.0.2, permission_handler ^5.1.0+2 requires permission_handler_platform_interface ^2.0.2.
And because no versions of permission_handler_platform_interface match >2.0.2 <3.0.0 and permission_handler_platform_interface 2.0.2 depends on plugin_platform_interface ^1.0.2, permission_handler ^5.1.0+2 requires plugin_platform_interface ^1.0.2.
And because geolocator >=7.0.0 depends on geolocator_platform_interface ^2.0.0 which depends on plugin_platform_interface ^2.0.0, permission_handler ^5.1.0+2 is incompatible with geolocator >=7.0.0.
So, because MyApp depends on both geolocator ^7.0.1 and permission_handler ^5.1.0+2, version solving failed.
Running "flutter pub get" in flutter_app...
pub get failed (1; So, because MyApp depends on both geolocator ^7.0.1 and permission_handler ^5.1.0+2, version solving failed.)
I do not quite understand where the error is and what I can do to fix it. If there is any information missing, I will add it as soon as I can. Does anyone have an idea what I need to change in the dependencies?
Here is my flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.19042.804], locale de-DE)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] IntelliJ IDEA Ultimate Edition (version 2020.3)
[√] Connected device (3 available)
• No issues found!
That’s because this package doesn’t support null safety yet. I think you should rather create an issue on their GitHub repository instead of asking the question here.

Flutter release apk size is very large in flutter sdk version 1.20

I am making a very simple app with 15 screens. And when i run this command flutter run --release. My release apk size is 26.2mb, which is very large.
My flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.2, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[✓] Android Studio (version 4.0)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
My pubspec.yaml file contain these dependencies:
cupertino_icons: ^0.1.3
flutter_svg: ^0.18.0
provider: any
image_picker: ^0.6.7+4
menu_button: ^1.2.1
pin_code_fields: ^5.0.1
flutter_pdfview:
path_provider:
http:
These files takes the more space. Is there any way that we can reduce the release apk size. For apps like this, the size is very large. In my previous flutter sdk version 1.17 the release apk size of 30 screen app is not more than 15 mb.
From your screenshot what is shown is the size of the appbundle (created for all android platforms) which is the total of all apk (for all android platform) and not size of a single platform apk. The reason is flutter run --release by default will build the appbundle which is the recommended way to build appbundle when you upload to playstore. Playstore will generate the apk for each device separately for download (arm64-v8, armeabi-v7a and x86_64).
So in your case, to generate a proper apk for size measurement, run:
flutter build apk --target-platform=<YOUR_TARGET_PLATFORM>
or this (will generate 2 APKs)
flutter build apk --split-per-abi
for more details please refer flutter.dev: Android App Size and flutter.dev:Build Modes

Dart SDK version mismatch while installing build_runner

I'm trying to add build_runner: ^1.10.2 to dev_dependencies in the pubspec.yaml file, but I am getting the following error:
The current Dart SDK version is 2.9.0.
Because project_name depends on build_runner >=1.10.2 which requires SDK version >=2.10.0-0.0 <3.0.0, version solving failed.
pub get failed (1; Because project_name depends on build_runner >=1.10.2 which requires SDK version >=2.10.0-0.0 <3.0.0, version solving failed.)
I checked the dart website and the latest version of Dart SDK is 2.9.0 while 2.10 is still in dev.
Here's my flutter doctor output:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.20.1, on Microsoft Windows [Version 10.0.18362.959], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 4.0)
[√] VS Code, 64-bit edition (version 1.39.2)
[√] Connected device (1 available)
• No issues found!
This is an issue with the latest releases of dart, analyzer, and flutter creating conflicts with each other, which you can read more about at this Github issue. There likely is no real issue with your configuration.
A temporary solution that I've seen is to use a dependency override of the analyzer:
dev_dependencies:
build_runner: ^1.10.0
dependency_overrides:
analyzer: 0.39.14
I encountered this problem after doing some cleaning up of my directories and having downloaded/installed the latest flutter. Bam. Then I realised that version of flutter sits by default on channel stable. After switching to master, it solved my problem, i.e.:
flutter channel master
flutter upgrade
As of September 28, 2020 the latest version of Flutter on stable channel no longer has this issue.
Use these commands to upgrade.
flutter channel stable
flutter upgrade

Flutter Android app crashes on startup with no errors

I have an Android app that was built with Flutter. I previously encountered this error
[Dependency failing: com.nimbusds:nimbus-jose-jwt:7.7 -> net.minidev:json-smart#[1.3.1,2.3]][1]
for which I applied this workaround:
// Bottom of android/app/build.gradle
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
It does not seem to be an ideal workaround but at least it bypasses the error.
The project has been migrated to AndroidX according to instructions.
However now on debug, the launch screen opens but the app crashes straight away. The only console errors are:
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Built build/app/outputs/apk/debug/app-debug.apk.
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.4 18E226, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.37.1)
[✓] Connected device (1 available)
pubspec.yaml packages:
cloud_firestore: ^0.12.9+2
dio: ^2.1.16
firebase_auth: ^0.14.0+5
firebase_core: ^0.4.0+9
firebase_messaging: ^5.1.4
firebase_storage: ^3.0.6
flutter_facebook_login: ^2.0.1
flutter_local_notifications: ^0.8.2
flutter_webview_plugin: ^0.3.7
google_maps_flutter: ^0.5.21
google_maps_webservice: ^0.0.14
google_places_picker: ^2.0.2+1
google_sign_in: ^4.0.7
geoflutterfire: ^2.0.3+5
page_transition: ^1.1.4
stripe_payment: ^0.2.1
How can I fix the startup crash?
You need to provide the error logs thrown from the app when it crashed. If you the issue only occur after migrating to AndroidX, I suggest regenerating the Android build after updating the Flutter SDK that you're using. Run flutter upgrade then delete the /android build folder. Regenerate the android build by running flutter create --platforms=android, then run flutter clean and flutter pub get to rebuild the indexes.