当前位置: 首页 > 知识库问答 >
问题:

请帮助:评估项目“: app”时出现问题。>没有方法签名

羊舌迪
2023-03-14

我编辑了Flutter源代码,如作者的留档,但在构建APK文件时总是出现此错误:

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\MyProject\android\app\build.gradle' line: 34

* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_7lhgwn6g10f1dc3sk72t2tmig.android() is applicable for argument types: (build_7lhgwn6g10f1dc3sk72t2tmig$_run_closure2) values: [build_7lhgwn6g10f1dc3sk72t2tmig$_run_closure2@9578636]

* 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
Running Gradle task 'assembleRelease'... 2.787ms
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1

\android\app\build.gradle'中的第34行以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'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'kotlin-android'

android {

compileSdkVersion 33

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "my-package-name"
minSdkVersion 21
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
release {

signingConfig signingConfigs.release

minifyEnabled true
useProguard true

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

flutter {
source '../..'
}

dependencies {
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-core:17.3.0'
implementation 'com.google.firebase:firebase-messaging:20.2.4'
implementation 'com.android.support:multidex:1.0.3'
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation('androidx.work:work-runtime') {
version {
strictly '2.6.0'
}
}
}

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

颤振医生=

颤振版本

颤振3.1.0-9.0。通道开发前https://github.com/flutter/flutter.git框架•版本f28e570c8c(3周前)•2022-06-14 13:39:33-0500引擎•版本74ee6b5afd工具•Dart 2.18.0(版本2.18.0-165.1。beta)•DevTools 2.14.0

gradle--version

构建时间:2022-03-31 15:25:29UTC修订版:540473b8118064efcc264694cbcaa4b677f61041

静态编程语言: 1.5.31 Groovy: 3.0.9 Ant: Apache Ant(TM)1.10.11版2021年7月10日编译JVM:18.0.1.1(Oracle Corporation18.0.1.12-6)OS: Windows 10 10.0 amd64

你能帮助我吗?非常感谢你!

共有1个答案

唐涛
2023-03-14

请备份您的项目并使用此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 plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}


android {
    compileSdkVersion 31

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "package id here"
        multiDexEnabled true
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile file(keystoreProperties['storeFile'])
           storePassword keystoreProperties['storePassword']
       }
   }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies{
    
}

flutter {
    source '../..'
}

添加您的包裹id。然后进行清理。删除pub spec.lock文件。。运行flutter pub get并重试。

 类似资料:
  • 我已经用Flutter在VS代码上创建了一个应用程序,在我开始准备构建应用程序之前,没有任何问题。我开始将包名从“com.example.careona19”更改为“com.covid19rsa.app”,但随后开始出现以下错误:

  • 在使用gradle--stacktrace之后,我得到以下错误: 运行gradle后--信息 你知道这个问题怎么解决吗?

  • 评估项目': tflite'时出现问题。 没有方法的签名:build _ 29 ou 9 K6 cal 0 PML 6 qvuo 3 exmb 2 . Android()适用于参数类型:(build _ 29 ou 9 K6 cal 0 PML 6 qvuo 3 exmb 2 $ _ run _ closure 2)值:[build _ 29 ou 9 K6 cal 0 PML 6 qvuo 3

  • null 到目前为止,我试着: 升级和降级我的gradle,-清理和重建项目,-使缓存无效/重新启动,-注释掉新代码行, 编辑我的配置(没有太大变化) 如果我尝试另一个项目,我可以使用react-native来运行一个android应用程序,但这个项目引发了错误。需要注意的是,我不确定这是否重要,但这与AWS有关。

  • 当我试图运行我的应用程序时,我遇到了以下错误。 评估项目: app时出现问题。 提供的字符串模块表示法“commons io:common无法解析配置的所有依赖项”:app:debugRuntimeClasspath。s-io:2.6'无效。示例注释:“org。gradle:gradle核心:2.2','组织。mockito:mockito核心:1.9.5:javadoc'。 >

  • 当项目已经运行状态时,这个错误不会发生。但是第二天我试图运行同一个项目,然后这个错误就出现了。 失败:生成失败,出现异常。 > 其中:生成文件'D:\src\flatter。发布缓存\托管\发布。达特朗。org\firebase\u auth-3.2.0\android\build。格雷德尔热线:58 错误:评估项目时出现问题:firebase_auth。 无法从缓存加载脚本'D:\src\flu