无法将提供的表示法转换为文件或URI

时间:2019-06-13 08:08:25

标签: android android-studio android-espresso android-databinding android-espresso-recorder

运行浓缩咖啡测试./gradlew connectedAndroidTest时出现以下错误

> Task :app:fixStackFramesLiveDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:fixStackFramesLiveDebugAndroidTest'.
> Cannot convert the provided notation to a File or URI: classes.jar (androidx.databinding:databinding-adapters:3.4.1).
  The following types/formats are supported:
    - A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
    - A String or CharSequence URI, for example 'file:/usr/include'.
    - A File instance.
    - A Path instance.
    - A Directory instance.
    - A RegularFile instance.
    - A URI or URL instance.

app/build.gradle包含以下内容

...
android {
  .....
  defaultConfig {
     ...
     testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     ...
  }
  dataBinding {
     enabled = true
  }
}
...

无论咖啡依赖项如何,我都会收到上述错误。有人可以帮忙解决此问题。我是android和espresso的新手。 我不确定是否错过了信息。如果需要,请告知。

2 个答案:

答案 0 :(得分:3)

在启用Gradle Kotlin DSL的Android Studio 4.0 Canary 4上,我得到了同样的错误:

Unable to resolve dependency for ':app@debug/compileClasspath': Cannot convert the provided notation to a File or URI: {dir=libs, include=[*.jar]}.

从以下位置更改构建脚本后

dependencies {
    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}

dependencies {
    implementation(fileTree(Pair("dir", "libs"), Pair("include", listOf("*.jar"))))
}

一切正常。 WTF。

答案 1 :(得分:1)

将gradle更新为3.4。+后,我遇到了这个错误。降级到3.3.2之后,我能够进行构建而没有任何问题。