skip to Main Content

I am using Flutter and on android folder I ran ./gradlew clean build

But I get the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':audio_session:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [androidx.fragment:fragment:1.7.1] /Users/username/.gradle/caches/transforms-3/0f117a371f06cfd8b338874039e78472/transformed/fragment-1.7.1/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 19,
                or use tools:overrideLibrary="androidx.fragment" 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.6.3/userguide/command_line_interface.html#sec:command_line_warnings

My AndroidManifest.xml file is as follows:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.xxxxxx">

    <!-- Application Configuration -->
    <application
        android:label="tonns"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">

        <!-- Main Activity Configuration -->
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:taskAffinity=""
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">

            <!-- Specifies an Android theme to apply while the Flutter UI initializes -->
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme"
            />

            <!-- Main intent filter for the app launch -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <!-- Deep Linking Configuration (App Links) -->
            <meta-data android:name="FlutterDeepLinkingEnabled" android:value="true" />
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="https"
                    android:host="xxxx.app"
                    android:pathPrefix="/infopage" />
            </intent-filter>
        </activity>

        <!-- Flutter meta-data (required) -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />

    </application>

    <!-- Permissions for Location, Camera, and Internet -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />

    <!-- Intent Queries (optional, for sharing text) -->
    <queries>
        <intent>
            <action android:name="android.intent.action.PROCESS_TEXT" />
            <data android:mimeType="text/plain" />
        </intent>
    </queries>

</manifest>

My build.grade in the app level is as follows:

plugins {
    id "com.android.application"
    // START: FlutterFire Configuration
    id 'com.google.gms.google-services'
    // END: FlutterFire Configuration
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

def keystorePropertiesFile = rootProject.file('key.properties') // Correct path here
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader("UTF-8") { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty("flutter.versionCode", "1") // Default to 1 if not found
def flutterVersionName = localProperties.getProperty("flutter.versionName", "1.0.0") // Default to 1.0.0 if not found

android {
    namespace = "app.tonns.trashcanfinder"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId = "app.tonns.trashcanfinder"
        minSdk = 23
        targetSdk = flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger() // Use version code from local.properties
        versionName flutterVersionName // Use version name from local.properties
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            // Optional: Enable code minification with Proguard (if needed)
            // minifyEnabled true
            // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

flutter {
    source = "../.."
}

When I click on the error link it’s as follows:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="androidx.fragment" >

    <uses-sdk android:minSdkVersion="19" />
</manifest>

Can someone please sugges how can I get rid of this error?

2

Answers


  1. In your app level build.gradle file change the minSdk or minSdkVersion to 19 or above in your defaultConfig.

    its best to limit minSdkVersion 22 or above

    If your project is new

    defaultConfig {
        applicationId = "com.example.com"
        minSdk = 19
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }
    

    or

    defaultConfig {
        applicationId "com.example.com"
        minSdkVersion 19
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    
    Login or Signup to reply.
  2. It seems you have no issue with the configurations within your build.gradle.

    So, I hope your gradle-wrapper.properties has:

    distributionUrl=https://services.gradle.org/distributions/gradle-8.4-all.zip
    

    You may use this command:

    ./gradlew wrapper --gradle-version 8.4 --distribution-type all
    

    Also, consider your other project’s build configuration is in the right setup.

    Then, perform File > Invalidate Caches in your Android Studio IDE. If you’re using VS Code. Save your changes, then try this first before you execute ./gradlew clean build

    flutter pub get
    flutter clean
    flutter pub cache repair
    

    then after that, you can now perform ./gradlew clean build command.

    I hope it helps!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search