If you are starting a new fresh app, you need to create the Flutter App with
flutter create --androidx -i swift to add support for
androidx, otherwise it won’t work (see AndroidX Migration to migrate an existing app).
During the build, if Android fails with
Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library, it means that you need to update the
minSdkVersion of your
android/app/build.gradle file to at least
Also, you need to add
<uses-permission android:name="android.permission.INTERNET"/> in the
android/app/src/main/AndroidManifest.xml file in order to give minimum permission to perform network operations in your application.
flutter created your project prior to version
1.12, you need to make sure to update your project in order to use the new Java Embedding API! Take a look at the official Flutter wiki: Upgrading pre 1.12 Android projects. Also, you can refer to the #343 issue.
Remember to add
<meta-data> tag inside the
<application> tag of your
<meta-data android:name="flutterEmbedding" android:value="2" />
as mentioned in the 6th step of Full-Flutter app migration guide. Without this, the plugin will NOT work!!!
Also, note that to use the
InAppWebView widget on Android, it requires Android API 20+ (see AndroidView) or Android API 19+ if you enable the
useHybridComposition Android-specific option.
Starting with Android 9 (API level 28), cleartext support is disabled by default:
- Check the official Network security configuration - “Opt out of cleartext traffic” section.
- Also, check this StackOverflow issue answer: Cleartext HTTP traffic not permitted.
If you want to use the
ChromeSafariBrowser class on Android 11+ you need to specify your app querying for
android.support.customtabs.action.CustomTabsService in your
AndroidManifest.xml (you can read more about it here: https://developers.google.com/web/android/custom-tabs/best-practices#applications_targeting_android_11_api_level_30_or_above).
To use Material Components when the user interacts with input elements in the WebView, follow the steps described in the Enabling Material Components instructions.