Details
-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
Windows 10, Cordova 6.3.0
-
Workaround Exists
Description
Hi,
I encountered a problem with the Aerogear Cordova Push plugin on Windows 10.
The dependencies to "com.google.gms:google-services" were added to the end of the "build.gradle" file in the android platform directory while it should be added to the dependecies section. It caused the build to fail later because the dependencies could not be found.
I finally found it was because of end of lines. The androidBeforeInstall.js script uses the os.EOL constant to split the build.gradle file in lines. On Windows10 it expects the end of line to be \n\r, but actually it is \n (maybe because of the way Cordova builds this file ?).
I suggest using the "readline" module. It looks more reliable to read lines.
var lineReader = readline.createInterface({ input : fs.createReadStream('platforms/android/build.gradle') }); lineReader.on("line", function(line) { fs.appendFileSync('./build.gradle', line.toString() + os.EOL); if (/.*\ dependencies \{.*/.test(line)) { fs.appendFileSync('./build.gradle', '\t\tclasspath "com.google.gms:google-services:3.0.0"' + os.EOL); fs.appendFileSync('./build.gradle', '\t\tclasspath "com.android.tools.build:gradle:1.2.3+"' + os.EOL); } });
I attached the completed script file to the issue.