我是使用离子1和cordova的新手,我试着安装cordova-plugin-fcm使用以下注释:
cordova plugin add cordova-plugin-fcm但是当我建造的时候:
ionic cordova run android我知道这个错误:
脚本'D:\net\netAppV2\platforms\android\cordova-plugin-fcm\netappv2-FCMPlugin.gradle‘行: 13
这是netappv2-FCMPlugin.gradle的内容
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin请任何人帮我解决这个问题。
谢谢。
发布于 2018-02-06 10:19:44
您可以通过以下方式解决这一问题:
1.从plugins文件夹打开您的plugin.xml的cordova-plugin。
2.查找+并替换11.0.1版本
3.然后移除并增加平台
4.然后建造
发布于 2019-04-06 20:07:15
我遇到了同样的问题,这是由play-services版本引起的。您可以通过@Mani使用临时修复,但是如果您需要的不是临时的,还应该做一些额外的解决方法:
1)创建带有before_prepare类型的钩子。这是JS文件,内容是:
// That hook needed for fixing ANDROID Gradle issues with multiple `google.android.gms` services versions
// details:
// https://github.com/phonegap/phonegap-plugin-push/issues/1718
const fs = require('fs');
const path = require('path');
const FCM_VERSION = '11.8.0';
// You can include more of each string if there are naming conflicts,
// but for the GMS libraries each should be unique enough.
// The full list of libraries is here:
// https://developers.google.com/android/guides/setup
const LIBRARIES = [
'play-services-analytics',
];
const createRegex = (item) => new RegExp(`${item}:.*`, 'ig');
const createReplace = (item) => `${item}:${FCM_VERSION}`;
module.exports = (ctx) => {
const Q = ctx.requireCordovaModule('q');
const deferred = Q.defer();
const gradle = path.join(ctx.opts.projectRoot, 'platforms', 'android', 'project.properties');
fs.readFile(gradle, 'utf8', (err, data) => {
if (err) {
return deferred.reject(err);
}
let result = data;
LIBRARIES.forEach((lib) => {
result = result.replace(createRegex(lib), createReplace(lib));
})
return fs.writeFile(gradle, result, 'utf8', (err) => {
if (err) {
deferred.reject(err);
}
deferred.resolve();
});
});
return deferred.promise;
};2)在android平台的配置中声明这个钩子
<hook type="before_prepare" src="hooks/google-services-versions-fix.js" />3)在android/project.properties中,查找所有具有+并与play-services相关的版本,如:cordova.system.library.7=com.google.android.gms:play-services-analytics:+
4)将此类依赖项添加到const LIBRARIES =部分。
这将更新所需的依赖关系,以适当的版本,并解决这样的问题!
https://stackoverflow.com/questions/48639868
复制相似问题