今天,当我在构建程序时,遇到了一个问题。这个问题是:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\Mert\Desktop\FireBase\platforms\android\build.gradle' line: 254
* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'GMS_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
我的代码是:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.android.support:support-v4:24.1.1+"
compile "com.google.android.gms:play-services-analytics:$GMS_VERSION"
compile "com.android.support:support-v4:$ANDROID_SUPPORT_V4_VERSION"
// SUB-PROJECT DEPENDENCIES END
}
如果您能回答这个问题,那对我来说将是完美的。
答案 0 :(得分:1)
> Could not get unknown property 'GMS_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
正如错误所暗示的,GMS_VERSION可能未在脚本中的任何地方声明。您应该声明GMS_VERSION变量,或者直接提及版本,而不要使用变量。
dependencies {
def GMS_VERSION = "16.0.8"
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.android.support:support-v4:24.1.1+"
compile "com.google.android.gms:play-services-analytics:$GMS_VERSION"
compile "com.android.support:support-v4:$ANDROID_SUPPORT_V4_VERSION"
// SUB-PROJECT DEPENDENCIES END
}
或直接使用版本
compile "com.google.android.gms:play-services-analytics:16.0.8"