无法发布工件'xxx.aar'(xxx.aar),因为它不存在

时间:2018-12-10 04:40:21

标签: android gradle maven-plugin

无法发布配置'存档',无法发布工件danlu-bluetooth.aar/Users/xxx/work/xxx/workplace/androidcode/libraray/xxx/bluetooth/xxx-bluetooth.aar),因为它不存在。

编译环境说明:

  1. 等级版本为4.10.2
  2. Android Gradle插件版本为3.2.1

Maven插件配置:

apply plugin: 'maven'
uploadArchives {
uploadArchives {
repositories {
    mavenDeployer {
        snapshotRepository(url: "${mvn.snapUrl}") {
            authentication(userName: "${mvn.name}", password: "${mvn.pass}")
        }

        repository(url: "${mvn.url}") {
            authentication(userName: "${mvn.name}", password: "${mvn.pass}")
        }

        pom.project {
            version getVersionName()
            artifactId getArtifactId()
            groupId "${mvn.groupId}"
            packaging "${mvn.packaging}"
            description getDesc()
        }
     }
 }


task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}
artifacts {
   archives file(getArtifactId() + ".aar")
    archives sourcesJar
}

错误日志:

Caused by: org.gradle.api.artifacts.PublishException: Could not publish configuration 'archives'
    at org.gradle.api.tasks.Upload.upload(Upload.java:67)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:801)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:768)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)

Caused by: org.gradle.api.artifacts.PublishException: Cannot publish artifact 'danlu-bluetooth.aar' (/Users/xxx/work/danlu/workplace/androidcode/libraray/xxx/bluetooth/danlu-bluetooth.aar) as it does not exist.
    at org.gradle.internal.component.external.ivypublish.DefaultArtifactPublisher.isValidToPublish(DefaultArtifactPublisher.java:117)
    at org.gradle.internal.component.external.ivypublish.DefaultArtifactPublisher.addConfigurations(DefaultArtifactPublisher.java:94)
    at org.gradle.internal.component.external.ivypublish.DefaultArtifactPublisher.toPublishMetaData(DefaultArtifactPublisher.java:83)
    at org.gradle.internal.component.external.ivypublish.DefaultArtifactPublisher.publish(DefaultArtifactPublisher.java:67)
    at org.gradle.api.internal.artifacts.ivyservice.IvyContextualArtifactPublisher$1.execute(IvyContextualArtifactPublisher.java:43)
    at org.gradle.api.internal.artifacts.ivyservice.IvyContextualArtifactPublisher$1.execute(IvyContextualArtifactPublisher.java:40)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:133)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:63)
    at 

1 个答案:

答案 0 :(得分:1)

artifacts {
   archives file(getArtifactId() + ".aar")
   archives sourcesJar
}

只需使用“ archives sourcesJar”。