我是Flutter的新手,我刚刚在GitHub上克隆了一个项目,我必须处理它。因此,在我的android studio中运行该项目时,会出现以下错误:
失败:生成失败,出现异常。
- 其中:构建文件"C:\用户\19ngu\AndroidStudioProjects\damufasta\android\app\build.gradle"行:29
- 出了什么问题:评估项目":app"时出现问题。
无法对空对象调用toInteger()方法
我已经解决了依赖关系,并按照检查其他响应的指示将项目SDK和模块指向最新的API。因此,我希望它能成功运行。
这是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 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 localProperties.getProperty('flutter.compileSdkVersion').toInteger()
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
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.damufasta"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
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"
}
2条答案
按热度按时间km0tfn4u1#
将最小sdk设置为21:
minSdkVersion = 21第44行构建版本.gradle
f0brbegy2#
如果发生这种情况,响应者提到的一个可能的问题是www.example.com文件中缺少minSdkVersion的值local.properties。
因此,首先检查这些值是否存在,如果不存在,则添加它们。
如果存在,则确保minSdkVersion为21。
这对我很有效。