skip to Main Content

I am trying to run a flutter app I am writing on my device but when I try to run, I never get past the "assembleDebug" stage and get this message in the terminal:

Launching libmain.dart on sdk gphone64 x86 64 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':smart_auth'.
> Could not resolve all files for configuration ':smart_auth:classpath'.
   > Could not download gradle-4.1.3.jar (com.android.tools.build:gradle:4.1.3)
      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.3/gradle-4.1.3.jar'.
         > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.3/gradle-4.1.3.jar'.
            > Connect to dl.google.com:443 [dl.google.com/172.217.170.174] failed: Connection timed out: connect

   /* Many similar could not GET links */

   > Could not get unknown property 'android' for project ':smart_auth' of type org.gradle.api.Project.
   > Could not get unknown property 'android' for project ':smart_auth' of type org.gradle.api.Project.

* 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.

I had recently added the pinput package with smart_auth as one of its dependencies, causing the error. My flutter doctor had no issues. Flutter version is 3.7.7 and dart version is 2.19.4.

androidbuild.gradle:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

androidappbuild.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 GradleException("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 flutter.compileSdkVersion
  

    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"
        minSdkVersion 18
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

androidgradlewrappergradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-7.4-all.zip

androidgradle.properties:

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true

pubspec.yaml:

version: 1.0.0+1

environment:
  sdk: '>=2.18.6 <3.0.0'

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  get: ^4.6.1
  google_fonts: ^4.0.3
  flutter_screenutil: ^5.1.1
  flutter_dotenv: ^5.0.2
  get_storage: ^2.0.3
  persistent_bottom_nav_bar: ^5.0.2
  jiffy: ^6.1.0
  permission_handler: ^10.2.0
  mockito: ^5.1.0
  loader_overlay: ^2.0.6
  intl: ^0.18.0
  fluttertoast: ^8.2.1
  material_design_icons_flutter: ^6.0.7096
  url_launcher: ^6.1.10
  freezed_annotation: ^2.2.0
  json_annotation: ^4.8.0
  flutter_secure_storage: 7.0.1
  http: ^0.13.5
  flutter_svg: ^2.0.4
  cached_network_image: ^3.2.3
  internet_connection_checker: ^1.0.0+1
  simple_animations: ^5.0.0+3
  pinput: ^2.2.31

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0
  build_runner: ^2.1.10
  freezed: ^2.3.2
  json_serializable: ^6.6.1
  flutter_launcher_icons: ^0.12.0

2

Answers


  1. Chosen as BEST ANSWER

    The solution that worked out was updating Android Studio to the latest version. This upgrade the gradle version and solved the issue.


  2. I was also having the same issue of unable to located smart_auth. Tried several solutions but could not solve it. You get the error if you are running the code on an emulator. It does not show the error on a real device. Seems to be a bug.

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