当我尝试运行artifactoryPublish
任务时出现以下错误:
Deploying artifact: https://some-url/TestApp.apk
Error during extraction:
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':sdk-test-application:debugCompileClasspath'.
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.wrapException(ErrorHandlingConfigurationResolver.java:96)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.access$000(ErrorHandlingConfigurationResolver.java:45)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver$ErrorHandlingResolvedConfiguration.getResolvedArtifacts(ErrorHandlingConfigurationResolver.java:298)
at org.jfrog.gradle.plugin.artifactory.extractor.GradleBuildInfoExtractor.calculateDependencies(GradleBuildInfoExtractor.java:331)
at org.jfrog.gradle.plugin.artifactory.extractor.GradleBuildInfoExtractor.extractModule(GradleBuildInfoExtractor.java:296)
at org.jfrog.gradle.plugin.artifactory.extractor.GradleBuildInfoExtractor.extract(GradleBuildInfoExtractor.java:119)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.prepareAndDeploy(DeployTask.java:148)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.collectProjectBuildInfo(DeployTask.java:50)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.taskAction(DeployTask.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:788)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:755)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.internal.component.AmbiguousVariantSelectionException: More than one variant of project :sdk matches the consumer attributes:
- Configuration ':sdk:debugApiElements' variant android-aidl:
- Found artifactType 'android-aidl' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
- Required org.jetbrains.kotlin.platform.type 'androidJvm' and found compatible value 'androidJvm'.
- Configuration ':sdk:debugApiElements' variant android-classes:
- Found artifactType 'android-classes' but wasn't required.
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
- Required org.jetbrains.kotlin.platform.type 'androidJvm' and found compatible value 'androidJvm'.
这些是我尝试过的其他先前建议的解决方案,但没有用。
Build error after upgrading Gradle to version 4
建议的解决方案问题: 我没有使用com.google.gms:google-services。
建议的解决方案问题: 如果我使用默认配置,并且根据https://github.com/gradle/gradle/issues/5953#issuecomment-404514591,似乎不建议将配置设置为default,则模块有问题。将所有jcenter()方法移至其块内的底部也无济于事。
Android Studio 3.0 Compile Issue (Cannot choose between Configurations)
建议的解决方案问题: 我正在使用4.6版
build.gradle
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.dokka-android'
apply plugin: 'de.undercouch.download'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply plugin: 'ivy-publish'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName sdkVersion
buildConfigField "String", "WRAPPER_URL", "\"https://some-url/index.html?branch=master\""
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += "src/test/kotlin"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/kdoc"
includeNonPublic = false
}
kotlin {
experimental {
coroutines "enable"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.30.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.24.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.google.code.gson:gson:2.8.5'
testImplementation "org.robolectric:robolectric:4.0-alpha-3"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation "io.mockk:mockk:1.8.6"
}
publishing {
publications {
sdkRelease(MavenPublication) {
groupId "com.example.test”
artifactId "sdk"
version sdkVersion
afterEvaluate {
artifact("$buildDir/outputs/aar/$archivesBaseName" + "-release.aar") {
builtBy assembleRelease
}
}
pom.withXml {
final dependenciesNode = asNode().appendNode('dependencies')
ext.addDependency = { Dependency dep, String scope ->
if (dep.group == null || dep.version == null || dep.name == null || dep.name == "unspecified")
return // ignore invalid dependencies
final dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name)
dependencyNode.appendNode('version', dep.version)
dependencyNode.appendNode('scope', scope)
}
configurations.implementation.getAllDependencies().each { dep -> addDependency(dep, "compile") }
}
}
}
repositories {
maven {
name = "mavenPublic"
url = 'https://some-url/artifactory/sdk-releases'
credentials {
username = ‘some-username’
password = ‘some-password’
}
}
}
}
artifactoryPublish {
publications(publishing.publications.sdkRelease)
properties = ['product.type': 'aar']
}
build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'ivy-publish'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.playground.test”
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "ORDER_API_URL", "\"http://some-url.net/api/\""
}
debug {
buildConfigField "String", "ORDER_API_URL", "\"https://some-url.net/api/\""
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
}
artifactoryPublish.dependsOn('assembleDebug')
publishing {
publications {
app(IvyPublication) {
def branch = System.env.'BRANCH_NAME' ?: ''
if (branch.startsWith('develop')) {
organisation = “example/develop"
} else if (branch.startsWith('master')) {
organisation = "example/release"
} else if (branch.startsWith('release')) {
organisation = "example/staging"
} else {
organisation = "example/feature"
}
def date = new Date()
module = "app/" + date.format('yyyy-MM-dd')
revision = date.format("HHmm") + "-" + git.shortHash() + "-" + "debug"
project.afterEvaluate {
artifact("$buildDir/outputs/apk/debug/$archivesBaseName" + "-debug.apk") {
name "TestApp"
extension "apk"
type "text"
}
}
}
}
}
artifactoryPublish {
publications(publishing.publications.app)
properties = ['product.type': 'app']
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation project(':sdk')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation "com.squareup.retrofit2:retrofit:2.4.0"
implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0"
implementation "com.squareup.retrofit2:converter-gson:2.4.0"
implementation "io.reactivex.rxjava2:rxandroid:2.0.2"
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'com.google.dagger:dagger:2.16'
implementation 'com.github.ar-android:AndroidSvgLoader:1.0.1'
kapt 'com.google.dagger:dagger-compiler:2.16'
kapt "android.arch.lifecycle:compiler:1.1.1"
testImplementation 'junit:junit:4.12'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0'
testImplementation "org.robolectric:robolectric:4.0-alpha-2"
testImplementation 'org.json:json:20180130'
}
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.jfrog.artifactory'
apply from: 'git.gradle'
ext {
// Format as major.minor[.bugfix][-label]
sdkVersion = "0.1.0"
}
buildscript {
ext.kotlin_version = '1.3.0'
ext.dokka_version = '0.9.17'
ext.gradle_download_version = '3.4.3'
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${dokka_version}"
classpath "de.undercouch:gradle-download-task:${gradle_download_version}"
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1'
}
}
allprojects {
repositories {
mavenCentral()
google()
maven { url 'https://jitpack.io' }
jcenter()
}
}
artifactory {
contextUrl = 'https://some-url.net/artifactory/'
publish {
repository {
repoKey = ‘some-repoKey’
username = ‘some-username’
password = ‘some-password’
ivy {
artifactLayout = "[organization]/android/[module]/[revision]/[artifact].[ext]"
}
}
defaults {
publishArtifacts = true
publishIvy = false
properties = [
'git.branch' : 'develop',
'git.commit_author' : git.author(),
'git.commit_hash' : git.shortHash(),
'git.commit_message' : git.message(),
'product.integration': ‘example’,
'product.platform' : 'android']
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
您如何解决此问题?