在我的手机上调试我的颤音应用程序时,我得到了以下错误
失败:生成失败,但有异常。
未指定compileSdkVersion。请把它添加到build.gradle
我的应用程序构建。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 FileNotFoundException("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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.wizzcrete"
minSdkVersion 23
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 '../..'
}我的android build.gradle文件如下:
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'我已经检查了我的SDK版本,它确实是30。我甚至尝试使用Android版本29,并在gradle中将编译和目标SDK版本更新为29,但这仍然不起作用。我的minSDK版本是23,为了在颤振中使用防火墙,最低23是必需的。我希望这些信息足以传达问题,有什么想法吗?
发布于 2021-08-28 13:13:30
解决了
问题是我没有将所有必要的防火墙依赖项添加到我的项目级gradle中。我添加的插件是在应用程序级别的级别,这是错误的,他们应该在项目级别的等级。此外,我还必须将缺少的依赖项(如firebase核心bom的实现以及防火墙和身份验证依赖项)添加到我的项目级别梯度中,如下所示:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:28.4.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore-ktx'
}我加入这个答案是为了帮助另一个迷失的灵魂,就像我一样,在这个问题上花了很多时间在6+上绞尽脑汁。总结一下:检查两个gradle文件中的依赖项,并确保所有这些都得到了解决。
https://stackoverflow.com/questions/68957163
复制相似问题