解决 ionic打包apk 报错 Unexpected token e in JSON at position 0

D:\project\app_jianshang>ionic cordova run android
√ Creating .\www directory for you - done!
SyntaxError: Unexpected token e in JSON at position 0

at JSON.parse (<anonymous>)
at Object.getNativeTargets (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\lib\native-run.js:109:44)

开始以为是config.xml和androidManifest.xml中的配置多了特殊字符引起的错误

加上--verbose执行

D:\project\app_jianshang>ionic cordova run android --verbose
  ionic:lib Terminal info: { ci: false, shell: 'C:\\Windows\\system32\\cmd.exe', tty: true, windows: true } +0ms
  ionic:lib CLI global options: { _: [ 'cordova', 'run', 'android' ], help: null, h: null, verbose: true, quiet: null, interactive: true, color: true, confirm: null, json: null, project: null, '--': [] } +7ms
  ionic:lib:project Project type from config: @ionic/angular (angular) +0ms
  ionic:lib:project Project details: { configPath: 'D:\\project\\app_jianshang\\ionic.config.json', errors: [], context: 'app', type: 'angular' } +2ms
  ionic Context: { binPath: 'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath: 'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\ionic', execPath: 'D:\\project\\app_jianshang', version: '5.4.16' } +0ms
  ionic:lib:integrations:cordova:config Loading Cordova Config (config.xml: 'D:\\project\\app_jianshang\\config.xml', package.json: 'D:\\project\\app_jianshang\\package.json') +0ms
SyntaxError: Unexpected number in JSON at position 4

at JSON.parse (<anonymous>)
at Object.getNativeTargets (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\lib\native-run.js:109:44)
  ionic SyntaxError: Unexpected number in JSON at position 4
  ionic     at JSON.parse (<anonymous>)
  ionic     at Object.getNativeTargets (C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\lib\native-run.js:109:44) +17s

将文件还原之后 重启了vscode

在执行ionic cordova run android --verbose

我们可以看到 Unexpected number in JSON at position 4

有无法解析的数字在第4个位置

使用beyondcompare或者比较工具比较config.xml 以及 package.json 还有androidManifest.xml这几个文件值

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值