Android Studio 请帮助:评估项目':app'时发生问题,>没有方法签名

xmd2e60i  于 2022-11-25  发布在  Android
关注(0)|答案(3)|浏览(177)

我已经编辑了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'

Flutter医生=〉未发现问题!
Flutter--版本

Flutter 3.1.0-9.0.pre ·通道开发·https://github.com/flutter/flutter.git框架·修订版f28 e570 c8 c(3周前)· 2022-06-14 13:39:33 - 0500引擎·修订版74 ee 6 b5 afd工具· Dart 2.18.0(构建版本2.18.0-165.1.beta)·开发工具2.14.0

Gradle --版本

分级7.4.2

构建时间:2022年3月31日15:25:29 UTC修订时间:540473 b8118064电子表格
Kotlin:1.5.31 Groovy:3.0.9 Ant:Apache Ant(TM)版本1.10.11编译于2021年7月10日JVM:(18.0.1.1Oracle公司18.0.1.1+2-6)操作系统:Windows 10操作系统
你能帮我吗?非常感谢!

8e2ybdfx

8e2ybdfx1#

请备份您的项目并使用此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。然后执行flutter清理。删除发布规范.lock文件。运行flutter发布获取并重试。

wmvff8tz

wmvff8tz2#

在我的,这是由proguard问题引起的。

useProguard true

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

y4ekin9u3#

我有同样的问题后,更新flutter到3.3.9
但主要问题是Kotlin版本的更新(我将其升级到1. 7. 21)和更新kotlin gradle插件(新的7. 1. 2)
有一个关于useProfuard的小警告已弃用。从build.gradle中删除useProguard false后,一切都按预期运行

相关问题