简体   繁体   中英

how to fix google play services version

Today when I was building a program, I get a problem. This problem is that:

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.

My code is:

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
}

If you can answer this problem, it will be perfect for me.

> Could not get unknown property 'GMS_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

As the error implies, GMS_VERSION may not be declared anywhere in the script. You should either declare GMS_VERSION variable or directly mention the version instead of using a variable.

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
}

or directly use the version

compile "com.google.android.gms:play-services-analytics:16.0.8"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM