目前遇到一個套件衝突問題是,
當我同時使用 cordova-plugin-firebase & cordova-plugin-googleplus 的時候
google登入的功能會失效,popup視窗出不來,
但一旦我將cordova-plugin-firebase移除,google登入就恢復正常了!!
想請問有沒有人遇到類似的情況@@
目前遇到一個套件衝突問題是,
當我同時使用 cordova-plugin-firebase & cordova-plugin-googleplus 的時候
google登入的功能會失效,popup視窗出不來,
但一旦我將cordova-plugin-firebase移除,google登入就恢復正常了!!
想請問有沒有人遇到類似的情況@@
爬了一下cordova-plugin-googleplus的issues,有人在22天以前提出了問題並解答了
所以依照這個方式做就沒問題了!
https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/487
另外附上我使用的方式
首先在專案資料夾底下建立一個scripts的資料夾以及一個js檔案
內容如下(我忘記我從哪裡copy來的了)
#!/usr/bin/env node
// Define hook in your config:
// <platform name="android">
// <hook src="scripts/gms-gradle-fix.js" type="before_prepare" />
// </platform>
const fs = require('fs');
const path = require('path');
const FCM_VERSION = '+';
// 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-maps',
'play-services-location',
'play-services-auth',
'play-services-identity',
'firebase-messaging',
];
const createRegex = (item) => new RegExp(`${item}:.*`, 'ig');
const createReplace = (item) => `${item}:${FCM_VERSION}`;
module.exports = (ctx) => {
console.log('-----------------------------');
console.log('> Gradle - fix `play-services` versions');
const Q = ctx.requireCordovaModule('q');
const deferred = Q.defer();
const gradle = path.join(ctx.opts.projectRoot, 'platforms', 'android', 'project.properties');
console.log(gradle);
fs.readFile(gradle, 'utf8', (err, data) => {
if (err) {
console.log(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) {
console.log('error');
console.log('-----------------------------');
deferred.reject(err);
}
console.log('completed');
console.log('-----------------------------');
deferred.resolve();
});
});
return deferred.promise;
};
並且在config.xml裡加上before prepare的hook
<hook src="scripts/THE_FILE_NAME.js" type="before_prepare" />
如此一來就不用每次都要自己手動更改囉!