How to fix Could not create task ':app:copyFlutterAssetsDebug'

25 Views Asked by At

After running flutter run i encountered the following:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/elkana/Dev/IdeaProjects/my_app/android/build.gradle' line: 13

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Could not create task ':app:copyFlutterAssetsDebug'.
> For input string: "7-rc-4"

* 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.7s
Error: Gradle task assembleDebug failed with exit code 1

This is the /android/app/build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

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')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "com.example.my_app"
    compileSdk flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.example.my_app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {}

I'm using Gradle 8.7-rc-4

------------------------------------------------------------
Gradle 8.7-rc-4
------------------------------------------------------------

Build time:   2024-03-20 14:03:34 UTC
Revision:     b9db7ce7ad5d1f2adf1928955ae926329262cf82

Kotlin:       1.9.22
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          11.0.22 (Ubuntu 11.0.22+7-post-Ubuntu-0ubuntu222.04.1)
OS:           Linux 6.5.0-26-generic amd64

And the following Flutter SDK:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.4, on Ubuntu 22.04.4 LTS 6.5.0-26-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2023.2)
[✓] IntelliJ IDEA Community Edition (version 2023.3)
[✓] VS Code (version 1.87.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

I have tried to switch the following flutter channel stable flutter pub upgrade flutter pub outdated and I got this

Changing current working directory to: /home/elkana/Dev/IdeaProjects/my_app
Showing outdated packages.
[*] indicates versions that are not the latest available.

Package Name  Current  Upgradable  Resolvable  Latest  

direct dependencies: all up-to-date.

dev_dependencies: all up-to-date.
all dependencies are up-to-date.
0

There are 0 best solutions below