我正在尝试将我最近编写的Google端点(Python)中的类包含到我的Android项目(Android Studio - 最新版本,Gradle)中。服务器端已经测试并且可以正常工作。
由于我不熟悉Gradle,因此我遵循Google Developers上的文档进行操作。根据文档中的指示,在src下更改build.gradle文件如下:
build.gradle:
由于我不熟悉Gradle,因此我遵循Google Developers上的文档进行操作。根据文档中的指示,在src下更改build.gradle文件如下:
build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
maven {
url 'http://google-api-client-libraries.appspot.com/mavenrepo'
}
mavenCentral()
mavenLocal()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.2"
defaultConfig {
minSdkVersion 17
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:4.+'
compile('com.google.api-client:google-api-client:1.17.0-rc') {
// Exclude artifacts that the Android SDK/Runtime provides.
exclude('xpp3:xpp3')
exclude('org.apache.httpcomponents:httpclient')
exclude('junit:junit')
exclude('com.google.android:android')
}
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
// Exclude play services, since we're not using this yet.
exclude('com.google.android.google-play-services:google-play-services')
}
compile('com.google.http-client:google-http-client-android:1.17.0-rc') {
exclude('com.google.android:android')
}
// This is used by the Google HTTP client library.
compile('com.google.guava:guava:14.0.+')
}
Android Studio返回以下错误:
Gradle 'Project' project refresh failed:
Build script error, unsupported Gradle DSL method found: 'exclude()'!
Possible causes could be:
- you are using Gradle version where the method is absent
- you didn't apply Gradle plugin which provides the method
- or there is a mistake in a build script
Build file '/Project/Android/build.gradle' line: 44
: Gradle settings
exclude(group: '', module: '')
的教程可以告诉我?请告诉我。我不太清楚如何正确使用它,总是出现错误。 - Huy Tower