Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ramon_E_
Beginner
167 Views

Weinre unsuccessful connection built apk

Hello Everyone,

I'm trying to use weinre to debug my third party plugins.  I had it successfully working previously but now it seems that every build I do crashes if I add the ip address target script.  The app will start on splash screen, turn white, and wait for several seconds then give me the alert "Application Error.  The connection to the server was unsuccessful. (file:///android_asset/www/index.html)"

I built a blank app with html5 + cordova then added my ipaddress script to that app and built the apk.  I still get the same result.  

The weird thing is if I leave the IP address script in the header and I run the 'simulate' tab.  Weinre can see it perfectly and shows up in the target section in the console.  It only disapproves when its the apk trying to call it.

Everyone of my apps that I have applied the script tag will crash now when I try to open the apk in my phone.  I don't know what I'm doing wrong and I've tried for a day or so to fix this issue.  Can anyone give me any tips as to why this is happening?

Thanks,

Ramon Escamilla

Tags (2)
0 Kudos
10 Replies
PaulF_IntelCorp
Employee
167 Views

Ramon -- I'm assuming you are trying to talk to a local weinre server that is running on your dev machine, because the XDK cloud-based weinre server has been retired.

When I've had troubles with weinre it is caused by where I place the weinre script tag within the app. Sometimes it works best if it is the very first script tag, and sometimes the very last. Have you tried relocating the script tag within the app?

PaulF_IntelCorp
Employee
167 Views

Another thing to check are your whitelist rules and CSP rules. The IP address of the machine that is hosting the weinre server needs to be part of the whitelist and/or CSP rule. Those rules are not relevant in the Simulate tab, only in a built app.

Ramon_E_
Beginner
167 Views

Paul,  I added a line to the header <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> all it did was skip over the weinre code.  Weinre still couldn't see my built apk.  I moved around the script tag but it didnt do anything.  I also added my ip address to the whitelist section and still nothing.  I have a feeling it has something to do with my build settings or my weinre.  

PaulF_IntelCorp
Employee
167 Views

Try leaving the CSP rule out and just use the whitelist rules. When you fill in your IP address in the whitelist rules, put it in both the <access> and <allow-navigation> fields, for example:

Screen Shot 2017-02-08 at 08.49.39 .png

Ramon_E_
Beginner
167 Views

Paul,

Still doesn't seem to work.  Do you think I should try to uninstall and reinstall intel xdk?

Thanks,

Ramon

PaulF_IntelCorp
Employee
167 Views

XDK doesn't have anything to do with access to your local weinre server (other than things like whitelist settings for a build). Are you able to connect to your local weinre server when your app is running inside of App Preview?

Ramon_E_
Beginner
167 Views

Paul,

When I click the simulate tab and I try run the app.  It gets seen by weinre and I can perform console.logs and see the elements.  However when I build the app and I install it onto my phone (samsung s5) it gives me the Application Error.  I don't know why weinre would be different.  I was reading through the weinre documentation and I saw this

VERY IMPORTANT! You should never leave a weinre script tag enabled in the index.html file of a published app. Doing so means that every instance of your app will attempt to contact your weinre server when it starts, resulting in a delayed or hung startup of your app (due to having to use the network to contact the weinre server), excessive use of your customer's mobile data and confusion.

I feel like this is probably whats happening to me, however Ive added the ip address so I don't know why its not connecting.  I'm currently at work but when I get home I'll trouble shoot some more.  

Anthony_H_Intel
Employee
167 Views

Hi Ramon, 

Is your phone connected to the same local wifi network as the weinre server is running on?
It might seem obvious, but I've wasted lots of time troubleshooting where the problem was that I forgot to switch my phone to wifi!

Tony

Ramon_E_
Beginner
167 Views

Tony,

Thanks for the suggestion.  After your reply I noticed my phone for some reason was joining my neighbors wifi rather than mine... ugh.. lol.  I just saw that it was connected never went in and checked whos network it was connecting too.  

Thanks,

Ramon Escamilla

Anthony_H_Intel
Employee
167 Views

Ramon,

Yep, I've had that happen to me as well, very annoying!  In my case it was an open wifi from a restaurant near my office.
Thanks for sharing your next steps!

So for anyone reading this in future, the correct troubleshooting steps for WEINRE connectivity are:

  1. Are you on wifi?
  2. Are you on the CORRECT wifi?

Tony

 

 

 

Reply