且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Ionic 2:在android设备上运行的应用程序无法调试

更新时间:2023-01-24 21:37:07



将以下添加到根项目目录中的package.json

 config:{
ionic_bundler:webpack,
ionic_source_map_type:#inline-source-map
} / code>

这是为了使webpack添加源映射inline
更改tsconfig.js行

 sourceMap:true,

 sourceMap:false 

这是禁用typescript创建源映射文件,因为这是由webpack完成。



工作得很好


Steps to reproduce: 1. Created new project from https://github.com/driftyco/ionic-starter-super 2. run `ionic run android`` 3. use chrome://inspect to debug

There is no ts and debug is not working - see attached

Here is what I'm using: Cordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.4 Ionic CLI Version: 2.1.18 Ionic App Lib Version: 2.1.9 Ionic App Scripts Version: 0.0.48 ios-deploy version: 1.9.0 ios-sim version: 5.0.13 OS: macOS Sierra Node Version: v6.9.2 Xcode version: Xcode 8.2.1 Build version 8C1002

I managed to find out what was causing the problem and how to solve it. The problem was that when you're remote debugging on an android device, Chrome debugger cannot access the source map file on the device. The solution/fix is to include the source map inline. To do this I:

added the below to package.json in the root project directory

"config": {
"ionic_bundler": "webpack",
"ionic_source_map_type": "#inline-source-map"
},

This is to make the webpack to add source maps inline changed tsconfig.js line

"sourceMap": true,

to

"sourceMap": false

This is to disable typescript to create source map file since this is done by webpack.

After this change everything seems to be working fine