当我执行命令“gradle clean build upload --debug --stacktrace”时,apk构建正常(注意 - apk文件是在路径/ app / build / outputs / apk上生成的,名称为app-debug.apk 。名称不是myapp.apk),但uploadArchives失败,出现NullPointerException。完整的堆栈跟踪如下。我已经尝试了很多,但都是徒劳的。这是我在Android应用程序中的app.gradle app.gradle。
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.xxx.yyy"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
signingConfigs {
release {
storeFile file("../debug.keystore")
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
dependencies {
// All Compile time dependencies mentioned here
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'maven'
uploadArchives {
repositories.mavenDeployer {
repository(url:"http://localhost:4080/nexus/content/repositories/my-repository") {
authentication(userName: "admin", password: "admin123")
} snapshotRepository(url:"http://localhost:4080/nexus/content/repositories/my-repository") {
authentication(userName: "admin", password: "admin123")
}
pom.version = "1.0.0"
pom.artifactId = "myapp"
pom.packaging = 'apk'
pom.groupId = "com.xxx.yyy"
}
}
以下是例外日志
Here is the exception Trace :
[DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
[DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:uploadArchives'
[LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :app:uploadArchives FAILED
[INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :app:uploadArchives (Thread[Task worker Thread 3,5,main]) completed. Took 0.218 secs.
[DEBUG] [org.gradle.internal.operations.DefaultBuildOperationWorkerRegistry] Worker root.121 completed (0 in use)
[DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Task worker Thread 3,5,main]] finished, busy: 24.359 secs, idle: 2 mins 54.947 secs
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:uploadArchives'.
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not publish configuration 'archives'
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.lang.NullPointerException (no error message)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:uploadArchives'.
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.api.artifacts.PublishException: Could not publish configuration 'archives'
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.tasks.Upload.upload(Upload.java:66)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:632)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:615)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 20 more
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.NullPointerException
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.publisher.IvyBackedArtifactPublisher.validatePublishMetaData(IvyBackedArtifactPublisher.java:83)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.publisher.IvyBackedArtifactPublisher.publish(IvyBackedArtifactPublisher.java:61)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.IvyContextualArtifactPublisher$1.execute(IvyContextualArtifactPublisher.java:43)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.IvyContextualArtifactPublisher$1.execute(IvyContextualArtifactPublisher.java:40)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.IvyContextualArtifactPublisher.publish(IvyContextualArtifactPublisher.java:40)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.tasks.Upload.upload(Upload.java:64)
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 28 more
[ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
[LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger]
[LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED
[LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger]
[LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] Total time: 3 mins 30.474 secs