ge widydr
ge widydr

Reputation: 72

unable to fix One or more plugins require a higher Android SDK version

I have an error in my file regarding the android version

One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to C:\Users\gewidydr\AndroidStudioProjects\carebuddy_version3\android\app\build.gradle:
android {
  compileSdkVersion 33
  ...
}

C:\Users\gewidydr\AndroidStudioProjects\carebuddy_version3\android\app\src\debug\AndroidManifest.xml Error:
    uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:images_picker] C:\Users\gewidydr\AndroidStudioProjects\carebuddy_version3\build\images_picker\intermediates\merged_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.chavesgu.images_picker" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:images_picker] C:\Users\gewidydr\AndroidStudioProjects\carebuddy_version3\build\images_picker\intermediates\merged_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.chavesgu.images_picker" 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 24s

┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────┐
│ The plugin images_picker requires a higher Android SDK version.                               │
│ Fix this issue by adding the following to the file                                            │
│ C:\Users\gewidydr\AndroidStudioProjects\carebuddy_version3\android\app\build.gradle:          │
│ android {                                                                                     │
│   defaultConfig {                                                                             │
│     minSdkVersion 21                                                                          │
│   }                                                                                           │
│ }                                                                                             │
│                                                                                               │
│ Note that your app won't be available to users running Android SDKs below 21.                 │
│ Alternatively, try to find a version of this plugin that supports these lower versions of the │
│ Android SDK.                                                                                  │
│ For more information, see:                                                                    │
│ https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration                 │
└───────────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1

but after I went to build.gradle and change the version this happens

C:\Users\gewidydr\AndroidStudioProjects\carebuddy_version3\android\app\src\debug\AndroidManifest.xml Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [:images_picker] C:\Users\gewidydr\AndroidStudioProjects\carebuddy_version3\build\images_picker\intermediates\merged_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.chavesgu.images_picker" to force usage (may lead to runtime failures)

this is the plugins in pubspec.yaml

dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  get: ^4.6.5
  connectivity_plus: ^2.3.6
  shared_preferences: ^2.0.15
  cached_network_image: ^3.2.1
  flutter_svg: ^1.1.6
  carousel_slider: ^4.0.0
  smooth_page_indicator: ^1.0.0+2
  flutter_svg_provider: ^1.0.3
  intl: ^0.17.0
  permission_handler: ^10.0.0
  images_picker: ^1.2.11

I don't know which plugin is doing this or if there is a way to replace it, I have tried upgrading flutter but that only crashes my android studio and emulator I was hoping i can try to fix this problem without deleting and redownloading android studio as it will take a while.

Upvotes: 2

Views: 3720

Answers (2)

Patrick
Patrick

Reputation: 165

Modify your build.gradle file to replace the minSdkVersion that is being supplied by flutter with a newer version:

 defaultConfig {
            minSdkVersion flutter.minSdkVersion /// remove this and replace with required version
                targetSdkVersion 33
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.lokalize_french_test"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    ```

Upvotes: 0

abhishek5646
abhishek5646

Reputation: 19

I have faced this issue for long time, now I have 100% working solution, just follow the steps:

  1. Open this directory flutter/packages/flutter_tools,(where you have installed flutter).
  2. check for flutter.gradle file, open it.
  3. Change the sdk level from this line static int minSdkVersion = 19 <-- Replace this 19 with version you want.
  4. Reload project or restart the Android Studio or Vs Code.

Upvotes: 1

Related Questions