ionic打包缺少config.xml文件

643 阅读1分钟
原文链接: blog.csdn.net


cp: copyFileSync: could not write to dest file (code=ENOENT):/Users/mehdigriche/work/cam1/test/platforms/android/res/xml/config.xml

Parsing /Users/mehdigriche/work/cam1/test/platforms/android/res/xml/config.xml failed (node:2306) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open '/Users/mehdigriche/work/cam1/test/platforms/android/res/xml/config.xml'

更改Api.js下的这段文件,改成下文,因为路径不对,我也不清楚为什么,有人知道的话,给我私聊,万分感谢。

this.locations = {
    root: self.root,
    www: path.join(self.root, 'assets/www'),
    res: path.join(self.root, 'res'),
    platformWww: path.join(self.root, 'platform_www'),
    configXml: path.join(self.root, 'app/src/main/res/xml/config.xml'),
    defaultConfigXml: path.join(self.root, 'cordova/defaults.xml'),
    strings: path.join(self.root, 'app/src/main/res/values/strings.xml'),
    manifest: path.join(self.root, 'app/src/main/AndroidManifest.xml'),
    build: path.join(self.root, 'build'),
    javaSrc: path.join(self.root, 'app/src/main/java/'),
    // NOTE: Due to platformApi spec we need to return relative paths here
    cordovaJs: 'bin/templates/project/assets/www/cordova.js',
    cordovaJsSrc: 'cordova-js-src'
};
我发生这个错误是因为我在插件中加入了第三方jar包,加入以后就可以打包成功了。

我在网上还看到过一个方法,我没成功,但有可能是解决的你的错误。

  1. Remove the platform: ionic cordova platform rm android
  2. Delete the following folders from your app folder: platforms, plugins & www
  3. Make sure your dependencies are available by running: npm install
  4. Add back the platform, this step will recreate the folders deleted in step 2 above: ionic cordova platform add android
  5. Finally, build your app: ionic cordova build android