1
resposta

Erros: Properties e GradleException

Ao seguir o passo de fazer os importes no arquivo build.gradle a nível do app, aparecem os dois erros:

Cannot resolve symbol 'Properties' Cannot resolve symbol 'GradleException'

Segue o código do arquivo até essa parte:

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 30

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.crash"
    minSdkVersion 16
    targetSdkVersion 30
    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 { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation platform('com.google.firebase:firebase-bom:29.0.0') implementation 'com.google.firebase:firebase-analytics'

}

1 resposta

Olá, Mateus!

Os erros "Cannot resolve symbol 'Properties'" e "Cannot resolve symbol 'GradleException'" geralmente ocorrem quando as classes ou símbolos não estão sendo encontrados durante a compilação.

Uma possível solução para esse problema é verificar se você importou corretamente as classes necessárias no início do arquivo build.gradle. Certifique-se de que você tenha as seguintes importações:

import java.util.Properties
import org.gradle.api.GradleException

Se essas importações estiverem faltando, adicione-as no início do arquivo build.gradle, logo após a declaração do pacote.

import java.util.Properties
import org.gradle.api.GradleException

def localProperties = new Properties()
// Restante do código...

Certifique-se também de que você não tenha erros de digitação nos nomes das classes ou símbolos.

Espero que isso resolva o problema! Se ainda tiver alguma dúvida, estou à disposição. Bons estudos!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software