首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >firebaseAppDistribution -没有方法的签名: build.android()适用于参数类型:(build_run_closure1)值:[build_run_closure1@x

firebaseAppDistribution -没有方法的签名: build.android()适用于参数类型:(build_run_closure1)值:[build_run_closure1@x
EN

Stack Overflow用户
提问于 2021-12-17 12:35:52
回答 1查看 653关注 0票数 3

我有一个电容应用程序,我正在尝试用Gradle实现Firebase分发(https://firebase.google.com/docs/app-distribution/android/distribute-gradle?authuser=1&apptype=aab),但是我被这个错误困住了:

代码语言:javascript
复制
No signature of method: build_clqfykx9rkn9m9ygw4eh6w1bu.android() is applicable for argument types: (build_clqfykx9rkn9m9ygw4eh6w1bu$_run_closure1) values: [build_clqfykx9rkn9m9ygw4eh6w1bu$_run_closure1@60526ded]

我已经完成了这个过程的所有步骤,我的build.gradle文件如下所示:

build.gradle:

代码语言:javascript
复制
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
        classpath 'com.google.gms:google-services:4.3.5'

        // Add the App Distribution Gradle plugin
        classpath 'com.google.firebase:firebase-appdistribution-gradle:2.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

apply from: "variables.gradle"

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

应用程序/build.gradle:

代码语言:javascript
复制
apply plugin: 'com.android.application'

// Apply the App Distribution Gradle plugin
apply plugin: 'com.google.firebase.appdistribution'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        applicationId "com.some.app"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName project.hasProperty('version') ? version : '1.0.0'
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        aaptOptions {
             // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
             // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
            ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
        }
    }
    flavorDimensions "environment"
    productFlavors {
        appA {
            dimension "environment"
            manifestPlaceholders = [displayName:"App A"]
        }
        appB {
            dimension "environment"
            applicationIdSuffix ".amigdala"
            manifestPlaceholders = [displayName:"App B"]
        }
    }
    signingConfigs {
        release {
            storeFile file("app-keystore.jks")
            storePassword System.getenv("KSTOREPWD")
            keyAlias "mykey"
            keyPassword System.getenv("KEYPWD")
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            // https://firebase.google.com/docs/app-distribution/android/distribute-gradle?authuser=1&apptype=aab
            firebaseAppDistribution {
                serviceCredentialsFile "./service-account-key-distribution.json"
                artifactType "AAB"
                archivePath System.getenv("ARCHIVE_PATH")
                releaseNotes "Change this before releasing in production!"
            }
        }
    }
}

repositories {
    flatDir{
        dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
    implementation project(':capacitor-android')
    testImplementation "junit:junit:$junitVersion"
    androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
    implementation project(':capacitor-cordova-android-plugins')
}

apply from: 'capacitor.build.gradle'

try {
    def servicesJSON = file('google-services.json')
    if (servicesJSON.text) {
        apply plugin: 'com.google.gms.google-services'
    }
} catch(Exception e) {
    logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}

当然,在我加入这部分之前,一切都很顺利:

代码语言:javascript
复制
 // https://firebase.google.com/docs/app-distribution/android/distribute-gradle?authuser=1&apptype=aab
            firebaseAppDistribution {
                serviceCredentialsFile "./service-account-key-distribution.json"
                artifactType "AAB"
                archivePath System.getenv("ARCHIVE_PATH")
                releaseNotes "Change this before releasing in production!"
            }

我在修改build.gradle文件方面非常新,所以我想这与语法有关,但我搞不懂。即使我做了一些像artifactType "AAB" -> artifactType="AAB"这样的小改动,我仍然从这个错误跳到了这个:Task 'appDistributionUploadRelease' not found in root project 'android'.

任何帮助或线索都会被接受,谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-13 17:12:47

没有签名的方法:build.android.当您的Gradle配置出现问题时将出现接缝,例如firebaseAppDistribution属性中缺少属性或文件路径错误。有一次我修复了在根项目'android‘中找不到任务' appDistributionUploadRelease’的问题,我(纯粹是运气)改变了appDistributionUploadAppARelease的appDistributionUploadRelease命令,解决了这个问题。任务似乎没有泛型命令,必须指定它的味道。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70393274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档