【问题标题】:How Do I resolve this error Could not get unknown property 'publishedGroupId' for project ':lokdonencrypt' of type org.gradle.api.Project."如何解决此错误无法为 org.gradle.api.Project 类型的项目 ':lokdonencrypt' 获取未知属性 'publishedGroupId'。”
【发布时间】:2021-03-26 11:24:37
【问题描述】:

我正在尝试将一个 android 库上传到 Jcenter,我已经成功创建了一个帐户,创建了一个 repo、包和版本。现在我正在修改模块的 build.gradle 文件,我不断收到这个错误

原因:groovy.lang.MissingPropertyException:无法为 org.gradle.api.Project 类型的项目“:lokdonencrypt”获取未知属性“publishedGroupId”。

我该如何解决这个问题

build.gradle(Module:lokencrypt)
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'



android {
    compileSdkVersion 29
    buildToolsVersion "30.0.2"

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "0.0.1"
        publishedGroupId "com.lokdonencryption.lokdonencryptionmodule:lokdonencrypt"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

   /* task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
        from androidJavadocs.destinationDir
        classifier = 'javadoc'
    }

    task androidSourcesJar(type: Jar) {
        from android.sourceSets.main.java.srcDirs
        classifier = 'sources'
    }*/


    ext {
        bintrayRepo = 'maven' // Name of the Bintray repo you created
        bintrayName = ' com.lokdonencryption.lokdonencryptionmodule:lokdonencrypt' // Bintray package name

        publishedGroupId = 'com.lokdonencryption.lokdonencryptionmodule:lokdonencrypt' // Group ID of the SDK which will be added in implementation line of gradle
        artifact = 'lokdonencrypt' // Artifact ID of the SDK which will be added in implementation line of gradle
        libraryVersion = '0.0.1' // Version of the library you created in Bintray

        libraryName = 'lokdonencrypt' // It is generally the module name
        libraryDescription = 'LokDon mobile encryption (ECSMID ) for developers'

        siteUrl = 'https://github.com/UncleSamTech/LokdonEncryptionModule'
        gitUrl = 'https://github.com/UncleSamTech/LokdonEncryptionModule.git'

        developerId = 'cbusiness'
        developerName = 'Lokdon'
        developerEmail = 'cbusinessforum@gmail.com'

        licenseName = 'The Apache Software License, Version 2.0'
        licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
        allLicenses = ["Apache-2.0"]

        //Bintray Credentials
        Properties properties = new Properties()
        properties.load(project.rootProject.file('local.properties').newDataInputStream())

        bintrayUsername = properties.getProperty('BINTRAY_USERNAME')
        bintrayUserOrg = properties.getProperty('BINTRAY_ORG')
        bintrayApiKey = properties.getProperty('BINTRAY_API_KEY')

       

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

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

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'commons-io:commons-io:+'
    implementation 'org.apache.commons:commons-io:1.3.2'

    implementation 'commons-codec:commons-codec:1.8'
    implementation 'com.amazonaws:aws-android-sdk-s3:2.7.+'
    implementation 'com.amazonaws:aws-android-sdk-cognito:2.7.+'
}

apply from: 'bintray.script'

build.gradle(Module:app)

    plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 29
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.lokdonencryption.lokdonencryptionmodule"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "0.0.1"
        //publishedGroupId "com.lokdonencryption.lokdonencryptionmodule:lokdonencrypt"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation project(":lokdonencrypt")
    implementation 'commons-io:commons-io:+'
    implementation 'commons-codec:commons-codec:1.8'
    implementation 'org.apache.commons:commons-io:1.3.2'
    implementation 'com.amazonaws:aws-android-sdk-s3:2.7.+'
    implementation 'com.amazonaws:aws-android-sdk-cognito:2.7.+'
//    implementation 'com.amazonaws.util.EncodingSchemeEnum.BASE64'


}

【问题讨论】:

    标签: android gradle sdk bintray jcenter


    【解决方案1】:

    好的,我正在回答我的问题。错误是抛出的异常,它是 MissingPropertyException,这意味着我没有添加属性

    解决方法是我将下面的这段代码复制到了错误的 build.gradle 文件中

    之前

    代码位于我创建的新模块的 build.gradle 文件中,如下所示

     ext {
            bintrayRepo = 'maven' // Name of the Bintray repo you created
            bintrayName = ' com.lokdonencryption.lokdonencryptionmodule:lokdonencrypt' // Bintray package name
    
            publishedGroupId = 'com.lokdonencryption.lokdonencryptionmodule:lokdonencrypt' // Group ID of the SDK which will be added in implementation line of gradle
            artifact = 'lokdonencrypt' // Artifact ID of the SDK which will be added in implementation line of gradle
            libraryVersion = '0.0.1' // Version of the library you created in Bintray
    
            libraryName = 'lokdonencrypt' // It is generally the module name
            libraryDescription = 'LokDon mobile encryption (ECSMID ) for developers'
    
            siteUrl = 'https://github.com/UncleSamTech/LokdonEncryptionModule'
            gitUrl = 'https://github.com/UncleSamTech/LokdonEncryptionModule.git'
    
            developerId = 'cbusiness'
            developerName = 'Lokdon'
            developerEmail = 'cbusinessforum@gmail.com'
    
            licenseName = 'The Apache Software License, Version 2.0'
            licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
            allLicenses = ["Apache-2.0"]
    
            //Bintray Credentials
            Properties properties = new Properties()
            properties.load(project.rootProject.file('local.properties').newDataInputStream())
    
            bintrayUsername = properties.getProperty('BINTRAY_USERNAME')
            bintrayUserOrg = properties.getProperty('BINTRAY_ORG')
            bintrayApiKey = properties.getProperty('BINTRAY_API_KEY')
    
           
    
        }
    

    解决它

    我只是简单的复制了一下,放到项目级模块的build.gradle文件中,错误就消失了。

    检查下面的快照并查看更改

    【讨论】:

      猜你喜欢
      • 2020-04-12
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-25
      • 2022-08-21
      • 1970-01-01
      • 2017-03-18
      相关资源
      最近更新 更多