格拉德尔没有';t将android apk上传到nexus
我们开发了一个Android应用程序,我们希望在每次发布后将apk部署到我们的nexus服务器上 使用格拉德尔没有';t将android apk上传到nexus,android,gradle,nexus,Android,Gradle,Nexus,我们开发了一个Android应用程序,我们希望在每次发布后将apk部署到我们的nexus服务器上 使用/gradlew-i clean build uploadArchives我在gradle控制台上获得以下输出 :app:uploadArchives (Thread[Daemon worker,5,main]) started. :app:uploadArchives Putting task artifact state for task ':app:uploadArchives' into
/gradlew-i clean build uploadArchives
我在gradle控制台上获得以下输出
:app:uploadArchives (Thread[Daemon worker,5,main]) started.
:app:uploadArchives
Putting task artifact state for task ':app:uploadArchives' into context took 0.0 secs.
Executing task ':app:uploadArchives' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
Publishing configuration: configuration ':app:archives'
Publishing to org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer@5b0bf3bd
:app:uploadArchives (Thread[Daemon worker,5,main]) completed. Took 1.753 secs.
这是什么意思?上传失败了吗?或者没有要上传的apk
我在AndroidStudio中创建了一个简单的HelloWorld项目。我唯一改变的是uploadArchives方法。有人知道问题出在哪里吗
这是我的build.gradle
项目
// 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:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这里是我的build.gradle
应用程序模块
apply plugin: 'com.android.application'
apply plugin: 'maven'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.helloworld"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
uploadArchives {
repositories.mavenDeployer {
repository(url: nexusDeployUrl + 'releases/') {
authentication(userName: nexusDeployUser, password: nexusDeployPassword)
}
snapshotRepository(url: nexusDeployUrl + 'snapshots/') {
authentication(userName: nexusDeployUser, password: nexusDeployPassword)
}
pom.groupId = 'com.example'
pom.artifactId = 'helloworld'
pom.version = "${android.defaultConfig.versionName}"
}
}
还有我的gradle-wrapper.properties
#Wed Apr 11 12:44:57 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
附加信息:我们有另一个旧的android应用程序,我从中复制了uploadArtifacts方法。在该应用程序中,上传到nexus的操作没有问题。我能看到的唯一区别(而不是更大的build.gradle)是gradle版本(3.0.1和2.2.3)。但对我来说,不可能在两个项目中统一gradle版本。我们有一个解决方案,但我们不明白为什么这是必要的,我们不喜欢硬编码的文件名 我们刚刚添加了以下几行
def releaseFile = file("build/outputs/apk/release/app-release-unsigned.apk-release.apk")
artifacts {
archives releaseFile
}
这是一个有效的解决方案吗?有什么改进的想法吗?有相同的问题吗?你找到正确的解决方法了吗?就像我在回答中写的那样。这对我们来说很有效,我们不再花时间解决这个问题。我们需要在哪里添加这行。当我在apps build.gradle中添加此项时,它无法从我这里工作,我们直接将其添加到apps build.gradle中。gradle 4.1可以正常工作。android{…}def releaseFile=file(“build/outputs/apk/release/app release unsigned.apk release.apk”)工件{archives releaseFile}其中需要添加以下行