无法获得类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler的对象的未知属性'FCM_VERSION'

时间:2018-09-20 13:02:35

标签: android cordova android-studio gradle

我正在使用Cordova在Android Studio中设置一个Android项目。

我的依赖项(\ platforms \ android \ build.gradle)中具有以下内容:

    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-v13:26.+"
    compile "me.leolin:ShortcutBadger:1.1.17@aar"
    compile "com.google.firebase:firebase-messaging:$FCM_VERSION"
    // SUB-PROJECT DEPENDENCIES END
}

当我尝试运行cordova build android时,出现以下错误:

  

无法获取类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler类型的对象的未知属性'FCM_VERSION

在项目根目录的config.xml中,有以下内容声明了theat变量:

 <plugin name="phonegap-plugin-push" spec="^2.1.3">
    <variable name="FCM_VERSION" value="11.6.2" />
</plugin>

终端中的完整错误消息:

ANDROID_HOME=C:\Users\Shabaz\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
Subproject Path: CordovaLib
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Users\Shabaz\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_20908j486irej0tvcnl5l4x1o.run(C:\wamp\www\acm-waste-track-cordova\platforms\android\build.gradle:142)

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\wamp\www\acm-waste-track-cordova\platforms\android\build.gradle' line: 259

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'FCM_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1.931 secs
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Build file 'C:\wamp\www\acm-waste-track-cordova\platforms\android\build.gradle' line: 259

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'FCM_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

有人知道这是怎么回事吗?

0 个答案:

没有答案