首先贴上Log:
Error:(25, 0) Cannot convert the provided notation to an object of type Dependency: /HomePath/workspaceAppProject/WeatherWebService/app/libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar.
The following types/formats are supported:
- Instances of Dependency.
- String or CharSequence values, e.g. 'org.gradle:gradle-core:1.0'.
- Maps, e.g. [group: 'org.gradle', name: 'gradle-core', version: '1.0'].
- FileCollections, e.g. files('some.jar', 'someOther.jar').
- Projects, e.g. project(':some:project:path').
- ClassPathNotation, e.g. gradleApi().
Comprehensive documentation on dependency notations is available in DSL reference for DependencyHandler type.
出现了这个错误难免,我们看看Module的build.gradle文件下dependencies这个节点是如何写的:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile file('libs.ksoap2-android-assembly-3.4.0.jar')
}
在google了一通之后,找到了如下答案:
The dependency should read "compile files(...)", not "compile file(...)".
Also in the above you write the path as 'libs.achartengine-1.1.0.jar', this should be 'libs/achartengine-1.1.0.jar'
所以正确的写法应该是:
compile files('libs/ksoap2-android-assembly-3.4.0.jar')
参考链接:http://stackoverflow.com/questions/19176721/adding-a-library-android-studio