找不到Gradle DSL方法:“ getMavenAccessKey()”

时间:2019-09-03 08:35:07

标签: android gradle

当我构建Project时,Android Studio会显示此问题: 找不到Gradle DSL方法:“ getMavenAccessKey()” 可能的原因: 项目'videoDownloader'可能正在使用不包含该方法的Android Gradle插件版本(例如,在1.1.0中添加了'testCompile')。

build.gradle(Module:videokit)

apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

repositories {
    mavenCentral()
}
group 'com.infullmobile.android'
version '1.1.2'

task sourceJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier "sources"
}

publishing {
    publications {
        maven(MavenPublication) {
            groupId project.group
            artifactId "videokit-release"
            version project.version

            artifact sourceJar
            artifact("$buildDir/outputs/aar/videokit-release.aar")

            pom.withXml {
                asNode().appendNode('description', 'Library for video processing based on FFmpeg.')
            }
        }
    }
    repositories {
        maven {
            name "iFMPrivateRelease"
            url "s3://maven-ifm-internal/private"
            credentials(AwsCredentials) {
                accessKey project.getMavenAccessKey()
                secretKey project.getMavenSecretKey()
            }
        }
        maven {
            name "iFMPublicRelease"
            url "s3://maven-ifm-internal/public"
            credentials(AwsCredentials) {
                accessKey project.getMavenAccessKey()
                secretKey project.getMavenSecretKey()
            }
        }
    }
}


ext {
    getMavenSecretKey = {
        return project.hasProperty('mavenSecretKey') ? project['mavenSecretKey'] : ""
    }
    getMavenAccessKey = {
        return project.hasProperty('mavenAccessKey') ? project['mavenAccessKey'] : ""
    }
}

task("publishIFMPrivate", dependsOn: "publishMavenPublicationToIFMPrivateReleaseRepository") {
    group "publishing"
    description "Uploads artifacts to inFullMobile private maven repository"
}

task("publishIFMPublic", dependsOn: "publishMavenPublicationToIFMPublicReleaseRepository") {
    group "publishing"
    description "Uploads artifacts to inFullMobile public maven repository"
}

android {
    compileSdkVersion compile_sdk_version
    buildToolsVersion build_tools_version

    defaultConfig {
        minSdkVersion min_sdk_version
        targetSdkVersion target_sdk_version
        versionCode version_code
        versionName version_name
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

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

    splits {
        abi {
            enable true
            reset()
            include 'x86', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
            universalApk true
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    testCompile 'org.mockito:mockito-core:1.10.19'
}

build.gradle(Project:MyApp)

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.2'
//        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://maven.google.com' }
    }
}

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

ext {
    min_sdk_version = 15
    target_sdk_version = 28
    compile_sdk_version = 28
    build_tools_version = "28.0.3"

    version_code = 6
    version_name = "1.3.3"

    firebase = "11.8.0"
    support_library_version = "27.0.2"

    var = [
            SupportV7     : "com.android.support:appcompat-v7:$support_library_version",
            CardviewV7    : "com.android.support:cardview-v7:$support_library_version",
            recyclerviewV7: "com.android.support:recyclerview-v7:$support_library_version"
    ]
}

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

这是所有错误信息:

Gradle DSL method not found: 'getMavenAccessKey()'
Possible causes:
The project 'videoDownloader' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.4.1 and sync project

The project 'videoDownloader' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file

The build file may be missing a Gradle plugin.
Apply Gradle plugin

0 个答案:

没有答案