android - Flutter:我的android/app/build.gradle在Android Studio里面的文件下面有红线,但是看不出有什么问题
问题描述
Flutter:我的android/app/build.gradle在Android Studio里面的文件下面有红线,但是看不到文件里面有什么问题。
android/app/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 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: 'com.google.gms.google-services'
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.livecrawfishseafood.live_crawfish_seafood"
minSdkVersion 16
targetSdkVersion 28
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"
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
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'
}
解决方案
哦,是的,我也遇到过这个。就我而言,我只是替换了flutterRoot为null时引发的异常类型:
if (flutterRoot == null) {
//throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.!")
}
推荐阅读
- c++ - 从 (C) 头文件调用 C++ 函数会导致链接器错误
- android - 如何修复错误消息 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
- amazon-web-services - 使用 S3 CloudFront 和自定义域在 AWS 上反应 SPA - HTTP 301 不正确
- python - 使用 np.where 将两列中的值合并到第三列中,在 Python 中满足某些条件
- r - “非零退出状态”在 Mac 上从 GitHub 安装包
- docker-compose - 安装 docker-compose.yml 时出现错误
- sharepoint - SharePoint 2010 Foundation - 任务过期后出现工作流错误。可能是什么原因?
- security - 在组织之间共享 Terraform tfvar
- c# - 将多个步骤文件加载到模型中,但它们不可见
- html - SASS - 将 scss 文件引用到 main.scss 文件以更改 main.css