cordova platform add android not working while listing Android targets

后端 未结 12 1769
野趣味
野趣味 2020-11-29 16:48

I got problem when i want to add an android platform to my phoneGap application. I got this message in my CLI when i execute the command cordova platform add android :

12条回答
  •  既然无缘
    2020-11-29 17:19

    I had the same issue even though path variables were set exactly as per the instructions. After going through multiple files I finally got it resolved. For me (Windows 7 enterprise 64 bit) I had to modify check_reqs.js and create.js from "C:\Users\.cordova\lib\android\cordova\3.5.0\bin\lib\" folder to include absolute path for the android.bat. My android SDK is under "C:\Android\android-sdk".

    In check_reqs.js I modified

    child_process.exec('android list targets', function(err, stdout, stderr) {
    

    to

    child_process.exec('C:\\Android\\android-sdk\\tools\\android.bat list targets', function(err, stdout, stderr) {
    

    In create.js I modified the statement

    return exec('android update project --subprojects --path "' + projectPath + '" --target ' + target_api + ' --library "' + path.relative(projectPath, targetFrameworkDir) + '"');
    

    to

    return exec('C:\\Android\\android-sdk\\tools\\android.bat update project --subprojects --path "' + projectPath + '" --target ' + target_api + ' --library "' + path.relative(projectPath, targetFrameworkDir) + '"');
    

    Also do not forget those double "\\" in the absolute path

提交回复
热议问题