3

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

Phil LA
  • 163
  • 1
  • 2
  • 10

2 Answers2

0

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

  • As i posted this question i cant help you sorry. but in my case its not working..even with 192.168.2.1 instead of localhost:8080 as you mentioned – Phil LA Jul 22 '14 at 14:06
  • This worked for me when trying to debug iOS Chrome and not being able to find target(not connecting). I used `192.168.1.102:8080` instead of `localhost:8080`. IP address:`192.168.1.102` being my Mac's network address from System Preferences -> Network – nicholaswmin Nov 11 '15 at 16:59
0

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 *">

TaeKwonJoe
  • 1,077
  • 11
  • 24