2016-10-03 23 views
3

我在Android的Windows上使用此功能。当我添加cordova-plugin-fcm插件时,我无法再构建该项目。下面是我得到的错误:由于版本与Google gms服务的冲突,FCMPlugin构建失败

BUILD FAILED                      

Total time: 4.697 secs                   

Error: cmd: Command failed with exit code 1 Error output:           
FAILURE: Build failed with an exception.               

* What went wrong:                    
Execution failed for task ':processDebugGoogleServices'.           
> Please fix the version conflict either by updating the version of the google-services plugin (i 
nformation about the latest version is available at https://bintray.com/android/android-tools/com 
.google.gms.google-services/) or updating the version of com.google.android.gms to 9.2.0.   

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

下面是我的config.xml中的一个片段:

<plugin name="cordova-plugin-console" spec="~1.0.3"/> 
    <plugin name="cordova-plugin-facebook4" spec="~1.7.3"> 
    <variable name="APP_ID" value="XXX"/> 
    <variable name="APP_NAME" value="XXX"/> 
    </plugin> 
    <plugin name="cordova-plugin-whitelist" spec="~1.2.2"/> 
    <plugin name="cordova-plugin-statusbar" spec="~2.1.3"/> 
    <plugin name="cordova-plugin-splashscreen" spec="~3.2.2"/> 
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/> 
    <plugin name="cordova-plugin-camera"/> 
    <plugin name="cordova-plugin-geolocation" spec="https://github.com/apache/cordova-plugin-geolocation"/> 
    <plugin name="cordova-plugin-googlemaps" spec="https://github.com/phonegap-googlemaps-plugin/cordova-plugin-googlemaps"> 
    <variable name="API_KEY_FOR_ANDROID" value="XXXX"/> 
    <variable name="API_KEY_FOR_IOS" value="XXXX"/> 
    </plugin> 
    <plugin name="cordova-plugin-file-transfer" spec="~1.5.1"/> 
    <plugin name="cordova-plugin-file" spec="~4.2.0"/> 
    <plugin name="cordova-plugin-device" spec="~1.1.2"/> 

我已阅读并this帖子this related这表明加入这行来的build.gradle (这是由离子自动创建的):

apply plugin: 'com.google.gms.google-services'

我已经尝试将它添加到build-extras.gradle中,但没有运气。

在我build.graddle,我看这样行:

// PLUGIN GRADLE EXTENSIONS START 
apply from: "cordova-plugin-fcm/upfront-FCMPlugin.gradle" 
// PLUGIN GRADLE EXTENSIONS END 

以及这些行:

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.facebook.android:facebook-android-sdk:4.14.+" 
    compile "com.google.android.gms:play-services-maps:+" 
    compile "com.google.android.gms:play-services-location:+" 
    // SUB-PROJECT DEPENDENCIES END 
} 

我缺少什么,我怎么能解决这个问题?

+0

您是否找到了解决此问题的解决方案? – Astrowie

+1

@Astrowie:没有,但你可以使用这个插件,其他:https://www.npmjs.com/package/cordova-plugin-firebase – Ari

回答

0

我发生了一些奇怪的事情,当我删除谷歌地图插件,建立项目,并在我的设备上运行它,一切工作完美,所有地图加载得很好。

+0

它看起来不像答案 – Alexan

0

要解决此错误,转到项目 - >平台..>机器人 - > gradlefile并修改该行

buildscript { 
repositories { 
     jcenter() 
     mavenLocal() 
    } 
dependencies { 
    classpath 'com.android.tools.build:gradle:+' 
    classpath 'com.google.gms:google-services:3.0.0' //change this line 
} 

} // 应用插件:“com.google.gms 。谷歌的服务。 //类必须使用而不是ID(字符串)能够从非根gradle这个文件应用插件 应用插件:com.google.gms.googleservices.GoogleServicesPlugin

0

我碰到这个线程,以防万一这对任何人都有帮助,下面是我制作的一组文件和更改,以便我的Android客户端很好d建立良好。我与cordova-plugin-fcm和cordova-plugin-googleplus发生冲突。这里是一个

平台/机器人/的build.gradle

dependencies { 
    classpath 'com.android.tools.build:gradle:2.2.3' 
    // I added this: 
    classpath 'com.google.gms:google-services:3.1.0' 
} 

.. 

allprojects { 
    repositories { 
    // changed the + to 10.2.0 
    compile "com.google.android.gms:play-services-auth:10.2.0" 
    compile "com.google.android.gms:play-services-identity:10.2.0" 
    } 
} 

// at end of the promptForReleaseKeyPassword function, add this: 

def promptForReleaseKeyPassword() { 
    ... 
    apply plugin: 'com.google.gms.google-services' 
} 

机器人/ project.properties(变更+至10.2.0)

cordova.system.library.3=com.google.android.gms:play-services-auth:10.2.0 
cordova.system.library.4=com.google.android.gms:play-services-identity:10.2.0 

科尔多瓦-插件-FCM /移动FCMPlugin .gradle(这个文件是一个棘手的)

dependencies { 
    classpath 'com.android.tools.build:gradle:+' 
    classpath 'com.google.gms:google-services:3.1.0' 
} 

... 

// apply plugin: 'com.google.gms.google-services' moved into this postBuildExtras function. 
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file 
ext.postBuildExtras = { 
     apply plugin: com.google.gms.googleservices.GoogleServicesPlugin 
} 
3

我解决了它。

plugings:

https://github.com/mauron85/cordova-plugin-background-geolocation

https://github.com/fechanique/cordova-plugin-fcm

1)。删除平台:cordova platform rm android。 2)。修改:插件/科尔多瓦 - 插件-FCM/src目录/安卓/ FCMPlugin.gradle

取代:

apply plugin: com.google.gms.googleservices.GoogleServicesPlugin 

有:

ext.postBuildExtras = { 
    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin 
} 

3)添加平台:科尔多瓦平台添加机器人。

4)修改:平台/安卓/ project.properties

变化的 “+” 为 “11.4.2”:

com.google.firebase:firebase-core:+ 
com.google.firebase:firebase-messaging:+ 
com.google.android.gms:play-services-location:+ 

应该是这样的:

com.google.firebase:firebase-core:11.4.2 
com.google.firebase:firebase-messaging:11.4.2 
com.google.android.gms:play-services-location:11.4.2 

就这样 :)。

+0

太棒了,这么长时间以来一直在苦苦挣扎,你的解决方案就像一个魅力。谢谢! – artemisian