dart 找不到API类型的项目“:app”上参数[]的方法Properties(),Project

uwopmtnx  于 2023-04-27  发布在  其他
关注(0)|答案(3)|浏览(167)

我在Android Studio中更新Flutter后收到此错误,请帮助,我累了升级和降级Firebase Auth依赖Flutter医生命令显示没有错误,我还尝试更改类路径,但没有运气,但当我构建时,我总是收到此错误

FAILURE: Build failed with an exception.
[   +2 ms] * Where:
[        ] Build file 'C:\Users\Corsair\Desktop\Flutter_1_2\outdoor_1_2\android\app\build.gradle' line: 2
[        ] * What went wrong:
[        ] A problem occurred evaluating project ':app'.
[        ] > Could not find method Properties() for arguments [] on project ':app' of type org.gradle.api.Project.
[        ] * 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
[ +345 ms] Running Gradle task 'assembleDebug'... (completed in 2.4s)
[   +8 ms] "flutter run" took 3,413ms.
Gradle task assembleDebug failed with exit code 1

这是我的app/build.gradle

def localProperties =  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 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.outdoor_1_2"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    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 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    classpath 'com.google.gms:google-services:4.2.0'
}

apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

这是我的建筑.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        jcenter()
        google()
        maven { url 'https://maven.fabric.io/public' }

    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // Add the google services classpath
        classpath 'com.google.gms:google-services:4.3.0'
        // Add fabric classpath
        classpath 'io.fabric.tools:gradle:1.26.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的设置.gradle

include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins =  new Properties()
def pluginsFile =  new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
    pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

plugins.each { name, path ->
    def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
    include ":$name"
    project(":$name").projectDir = pluginDirectory
}
vlju58qv

vlju58qv1#

更改此:

def localProperties =  Properties()

变成这样:

def localProperties =  new Properties()
nzrxty8p

nzrxty8p2#

即使它看起来像一个错误,尝试将' new '放在Properties和GradleException前面,它也会工作(2021年8月)

ujv3wf0j

ujv3wf0j3#

您需要从更新build.gradle

def localProperties = Properties()

def localProperties = new Properties()

会解决你的问题。

相关问题