android - 构建我的Flutter应用程序时,GradleExeption失败

标签 android gradle flutter build.gradle

当我尝试构建要公开发布的应用程序时,我从应用程序级别build.gradle收到此错误。我收到以下错误:

Launching lib\main.dart on SM G973F in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "C:\Users\tbsvst18tedbom\AndroidStudioProjects\tab_truth_true\android\gradlew.bat" exited abnormally:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\tbsvst18tedbom\AndroidStudioProjects\tab_truth_true\android\app\build.gradle' line: 11

* What went wrong:
Could not compile build file 'C:\Users\tbsvst18tedbom\AndroidStudioProjects\tab_truth_true\android\app\build.gradle'.
> startup failed:
  build file 'C:\Users\tbsvst18tedbom\AndroidStudioProjects\tab_truth_true\android\app\build.gradle': 11: unable to resolve class GradleExeption 
   @ line 11, column 11.
         throw new GradleExeption("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
               ^

  1 error


* 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
  Command: C:\Users\tbsvst18tedbom\AndroidStudioProjects\tab_truth_true\android\gradlew.bat app:properties

Finished with error: Please review your Gradle project setup in the android/ folder.

这是应用程序级别的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 GradleExeption("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.0.0'
}

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 29

    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.tab.tab_truth_true"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    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"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-ads:18.3.0'
}

apply plugin: 'com.google.gms.google-services'  // Google Play services Gradle plugin

我已经尝试了一切,但所知却一无所获。请帮帮我。

最佳答案

您在Gradle文件中输入了错误,在Gradle文件的第11行将GradleExeption更改为GradleException

关于android - 构建我的Flutter应用程序时,GradleExeption失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58989900/

相关文章:

dart - 检查 ListView 是否在 flutter 中为空

android - QuickBlox WebRtc 视频聊天安卓

groovy - 为什么 Gradle 中的配置和依赖不是 ExtensionAware?

java - 如何在多模块 Gradle 项目中构建分发包?

java - Gradle - 使用插件将配置应用于所有项目

dart - flutter 打开/关闭wifi

安卓媒体播放器 : IllegalStateException when app closes/press back button

android - 如何将多个服务提供商集成到 Paypal 应用程序中?

android - Android中有什么方法可以获取设备虚拟键盘的高度

flutter - 如何创建返回小部件数组的函数