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

Flutter构建appbundle错误找不到参数的方法android扩展()

金坚
2023-03-14

我正在尝试使用flatter为Andriod应用程序构建一个发布应用程序包,

当我跑步时:

flutter build appbundle

我得到:

* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_9z8dp8vvjumdxnixrakr4imyg.android() is applicable for argument 
types: (build_9z8dp8vvjumdxnixrakr4imyg$_run_closure3) values: [buil
d_9z8dp8vvjumdxnixrakr4imyg$_run_closure3@775a0064]

我试图清理修复缓存,但它仍然不工作。弗利特医生很好。

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: 'org.jetbrains.kotlin.android.extensions'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"


androidExtensions {
    experimental = true
}

android {

    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.example.Application"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

    }
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile']
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release

        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:27.1.0')

    // Add the dependency for the Firebase SDK for Google Analytics
    // When using the BoM, don't specify versions in Firebase dependencies
    implementation 'com.google.firebase:firebase-analytics'

    // Declare the dependency for the Firebase Authentication library
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-auth'

    // Add the dependencies for any other desired Firebase products
    // https://firebase.google.com/docs/android/setup#available-libraries

    implementation 'com.facebook.android:facebook-login:[8.1)'
    implementation 'com.facebook.android:facebook-android-sdk:[5,6)'

    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.fragment:fragment:1.0.0'

}

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

Android\build.gradle文件:

buildscript {
    ext.kotlin_version = '1.3.50'

    repositories {
        google()
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.3.5'
        classpath 'com.android.tools.build:gradle:4.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()  // Google's Maven repository
        jcenter()
    }
}

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

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

Android\键。属性文件:

storePassword=123456789
keyPassword=123456789
keyAlias=upload
storeFile=C:\\Users\\User\\Documents\\Application\\upload-keystore.jks

满输出:

C:\Users\User\Documents\Application>flutter build appbundle
The plugin `flutter_open_whatsapp` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since
a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

Kotlin plugin should be enabled before 'kotlin-android-extensions'

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\User\Documents\Application\android\app\build.gradle' line: 41

* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_9z8dp8vvjumdxnixrakr4imyg.android() is applicable for argument types: (build_9z8dp8vvjumdxnixrakr4imyg$_run_closure3) values: [buil
d_9z8dp8vvjumdxnixrakr4imyg$_run_closure3@27144de8]

* 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 2s
Running Gradle task 'bundleRelease'...                           2,990ms
Gradle task bundleRelease failed with exit code 1

共有1个答案

万俟亦
2023-03-14

尝试在android studio中将/android目录作为一个项目打开,并在不使用flatter的情况下构建版本。

甚至可以尝试在项目中使用Java,看看它是否有效??

如果它有效,那么您的Kotlin版本可能会有一些问题。

 类似资料: