1

I mistakenly deleted files on my pc to free up space but I don't know how it happened my flutter project started showing me a variety of errors. However, I have resolved most of the mistakes but some errors still persist. Please help me with this.

build.gradle

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

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

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

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 33
    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 {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.apitutorials"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        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
        }
    }

    buildscript {
        ext.kotlin_version = "1.6.0"
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }

}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    // classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    // classpath 'com.android.tools.build:gradle:4.1.0'
    
}

pubspec.yaml

name: apitutorials
description: A new Flutter project.

publish_to: 'none'
version: 1.0.0+1

environment:
  sdk: '>=2.18.6 <3.0.0'


dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  http: ^0.13.5
  modal_progress_hud_nsn: ^0.3.0-nullsafety-1
  image_picker: ^0.8.8
  # flutter_plugin_android_lifecycle: ^2.0.15

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:
 uses-material-design: true

Error


FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Flutter\Babbar\apitutorials\android\app\build.gradle' line: 28

* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_bfa8a7hzzhuxmyhtqs1bsth0p.android() is applicable for argument types: (build_bfa8a7hzzhuxmyhtqs1bsth0p$_run_closure2) values: [build_bfa8a7hzzhuxmyhtqs1bsth0p$_run_closure2@57e85a05]

* 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 1s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

First I updated sdk version to sdk33 then Kotlin version to 1.6.0

Link to my repo to view the changes. Repo.

0 Answers0