3
votes

I try to enable weinre for debugging however the problem is that weinre finds no target.

Here is what I do:

  1. installed weinre via nodejs command: npm install weinre -g

  2. connect my android device( Huawaei smartphone ) via USB cable and enable debugging mode on the android phone.

  3. start weinre, command: weinre --boundHost 192.168.2.1

The index.html looks like this:

<!doctype html>
 <html>
  <head>
   <title>tittle</title>

    <!-- Weinre testing for remote debug with physical device -->
     <script src="http://192.168.2.1:8080/target/target-script-min.js#anonymous"></script>  

    <script>window.location='./main.html';</script>
   <body>
   </body>
 </html>

on the config.xml i add

 <access origin="http://192.168.2.1:8080/*" />

finally on the main.html ( which is the real starting page ) i add:

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
  • Then i zip all the files the App needs and upload it to phonegap build. after phonegap build all aplications i scan the bardcode with the mobile devices. Now the device starts to download the app.

I start the app on the device. And visit the site

http://192.168.2.1:8080/client/#anonymous

=> The applications start as it ment to be but the site weinre-server shows "Target: NONE"

Am i missing something? I tried this process on firefox and chrome. I am pretty sure the mobile device does not use the 'same localhost' as my desktop pc.

the weinre server properties are:

enter image description here

2
got any solution for this?HardikT

2 Answers

0
votes

I met the same question,because I use the "localhost:8080/target/target-script-min.js#anonymous" rather than the real IP when importing the script. when I used real ip,the target was found

0
votes

The correct whitelist configuration is <content src="http://192.168.2.1:8080/*" />

Also if you have a Content-Security-Policy meta tag, you will need to set default-src * or at least add http://* like so per this phonegap framework doc. <meta http-equiv="Content-Security-Policy" content="default-src * ; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *; media-src *; img-src * 'self' data: file: cdvfile: http: https:; frame-src http: https: gap: cdvfile:; connect-src *">

<meta http-equiv="Content-Security-Policy" content="default-src 'self' http://*; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *; media-src *; img-src * 'self' data: file: cdvfile: http: https:; frame-src http: https: gap: cdvfile:; connect-src *">