简体   繁体   English

尝试运行 flutter 应用程序时,build.gradle 文件中出现错误

[英]When trying to run flutter application there is a Error in build.gradle file

In my first time, I have generated key.properties file and add to build.gradle file.我第一key.properties文件并添加到build.gradle文件中。 Then I tried to flutter run It's Not working.然后我尝试flutter run它不起作用。 在此处输入图像描述

My build.gradle file.我的build.gradle文件。

def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
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 28

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

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.calculator"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

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

}

flutter {
    source '../..'
}

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

localProperties is undefined. localProperties未定义。 Try this:尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 build.gradle 文件中添加 buildFeatures 时出错 - Error when adding buildFeatures in build.gradle file Android Studio build.gradle文件错误 - Android Studio build.gradle file error Flutter build.gradle 错误“构建因异常而失败。” - Flutter build.gradle Error " Build failed with an exception." 当我在 build.gradle 中打开 flutter 项目红线中的 android 文件夹时出错 - Get error when i open the android folder in flutter project red lines in build.gradle any idea Android Studio:尝试在 build.gradle 中实现 OKHTTP3 时收到错误 - Android Studio: I am receiving an error when trying to implement OKHTTP3 into the build.gradle 安装 Flutter 和 Dart 后 Build.Gradle 文件损坏 - Build.Gradle file broken after install of Flutter and Dart build.gradle 在 Visual Studio Code(Flutter) 中出错 - Error on build.gradle In Visual Studio Code(Flutter) Flutter sdk 未找到。 build.gradle中的GradleException错误 - Flutter sdk not found. The error in GradleException in the build.gradle 当我运行旧的android项目时,我从build.gradle收到一条错误消息 - When I run my old android project I get a error message from the build.gradle 我运行我的项目并在我的 build.gradle 文件中出现以下错误我该怎么办? - i run my project and get following error in my build.gradle file what should i do?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM