我在使用maven编译项目时遇到了麻烦,我收到了这个错误:
* What went wrong:
Cannot convert the provided notation to a File or URI: [src/main/java, src].
The following types/formats are supported:
- A String or CharSequence path, e.g 'src/main/java' or '/usr/include'
- A String or CharSequence URI, e.g 'file:/usr/include'
- A File instance.
- A URI or URL instance.
我的build.gradle与我过去使用的相同,看起来:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.0'
}
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
android {
compileSdkVersion 19
buildToolsVersion = "21.1.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionName VERSION_NAME
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs 'src'
res.srcDirs 'res'
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildToolsVersion '21.1.0'
}
apply from: "../gradle-local-mvn-push.gradle"
dependencies {
}
当我尝试构建并上传到maven AAR库时会发生这种情况
../gradlew uploadArchives
答案 0 :(得分:2)
您是否拥有gradle-local-mvn-push.gradle脚本的代码?我有同样的问题,它来自我的maven脚本。
我通过替换:
解决了这个问题task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java
}
到
task sourcesJar(type: Jar) {
classifier = 'sources'
from 'src/main/java'
}