我有一个带有两个模块的android项目(典型的前端应用程序和后端).我有三个build.gradle文件,每个模块一个,根目录一个.
我已经构建我的依赖关系的方式是通过提取所有的版本为独立的变量在根级别build.gradle这样
ext {
// SDK and tools
MIN_SDK_VERSION = 19
TARGET_SDK_VERSION = 23
COMPILE_SDK_VERSION = 23
BUILD_TOOLS_VERSION = '24'
// app dependencies
GOOGLE_API_CLIENT_VERSION = '1.19.0'
GOOGLE_PLAY_SERVICES_VERSION = '8.4.0'
ANDROID_SUPPORT_LIB_VERSION = '23.1.0'
[...]
// backend dependencies
[...]
}
Run Code Online (Sandbox Code Playgroud)
以后在我的说app build.gradle文件中使用
dependencies {
[...]
compile(group: 'com.google.oauth-client', name: 'google-oauth-client', version: rootProject.ext.GOOGLE_API_CLIENT_VERSION)
/////////////////////////////////
// Google Play Services explicit dependency
compile(group: 'com.google.android.gms', name: 'play-services-auth', version: rootProject.ext.GOOGLE_PLAY_SERVICES_VERSION)
compile(group: 'com.google.android.gms', name: 'play-services-plus', version: rootProject.ext.GOOGLE_PLAY_SERVICES_VERSION)
[...]
/////////////////////////////////
// Local Testing
testCompile(group: 'junit', …Run Code Online (Sandbox Code Playgroud) gradle android-build android-studio build.gradle android-gradle-plugin