I am having trouble getting my android app connected to just some particular servlets running on my server. I am getting an UnknownHostException when trying to connect. I assure you I have used the
<uses-permission android:name="android.permission.INTERNET" />
in my Manifest file and have already gone through atleast 5 or 6 similar SO questions.
When I use the URL which is shown with the original exception, in a browser, the servlet page shows up just fine. (Even in the device's browser!)
Note:
I am running this on a physical device
This happens only when I try and connect to some servlets. Not all. (Talk about weird!)
I'll give the codes if you want it.
At last, this was a silly problem.
What I did was, I used just http:/ instead of http:// in front of the URL and when I pasted this in the browser, the browser auto-corrected it into http://. Changing that back to http:// fixed it!
I leaving this here hoping that this might reduce the hours of headache caused by this annoying problem and help someone.
Related
The Problem: Please see this link DropBox Image Link
I have gone through almost all answers. First of all I want to tell what I have already tried -
Wifi issue - I think, this is not my problem but for considering issue My phone and My Mac both are in same Wi-Fi.
I have also gone through this Issue On Github and All links commented by people in this issue. Because That is the exact problem I have.
Finally I tried , The code which is working in my genymotion android 4.4, I took appdebug.apk, put into my mobile xaiomi with android-4.4 and installed it manually . And uhhh... same thing. just white screen nothing else.
So Last thing i thought there may be some permission issues, So I checked out in my phone that "pop-up are blocked". So I un-blocked it manually and whoaaaa.. finally I got this Image Link
Now Please if someone have any solution which is not in Internet, Please provide. If issue will be solved, I will order a Pizza for you :).
When I run the following command meteor run android-device I app loads on the device, but I cannot login or perform any action, and I get the following error message :
I20160125-16:26:04.688(2) (android:http://meteor.local/:0) XMLHttpRequest cannot load http://192.168.20.41:3000/sockjs/info?cb=pp4d6iodxu. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://meteor.local' is therefore not allowed access. The response had HTTP status code 403.
My phone is in developer mode, and I'm debugging (or attempting to) via USB.
As I already mentioned, the app is loading, but I'm dead from there.
Try to add App.accessRule("*"); to /mobile-config.js
After trying a number of things, including setting up another demo app, multiple restarts, setting up browser policies and tons of access Rules etc, it finally began to work. The things I tried:
plenty of accessRules in the mobile config
Browser Policy Package with standard rules
temporarily setting environmental variables for root url etc.
So in order to figure out what specifically caused the issue I began to work backwards removing things, until I removed ALL OF IT. and then it still worked.
I have tried for two weeks to replicate the issue now, and everything is working smoothly. Putting this down to a random bug, in my system, there are definitely more than a few people that have hit it.
The only thing I think I could have missed is a package update, that patched some package in the dependency tree that caused the whole thing to bomb on mobile.
I am trying to call the localhost in my android application. But unfortunately it is not possible i used several methods like emulator local host
http://10.0.2.2/android/dbconnection.php
and then my network ip address
http://192.168.1.xx/android/dbconnection.php
also
http://localhost:8080/android/dbconnection.php
but nothing is connected to my localhost. For this purpose i refer some stackoverflow answers that is also not working
If you are using the emulator,
http://10.0.2.2:8080/android/dbconnection.php
should be the way to go. If that fails as well, check for typos in the address (maybe it's dbConnection.php), take a look at your log cat and also check if you have declared full internet access in your manifest.
I am also facing the same problem when i worked on localhost. i referred some stackoverflow answer finally i got the solution create a new emulator it works fine in the new emulator.
Sorry for the newbie question, but I spent the whole day trying to figure out why the target list remains empty.
This is what I've done so far:
Launched the Weinre host, bounded to my desktop ip adress
(192.168.0.38)
Checked it on Chrome : the host is bounded to
192.68.0.38:8080
Checked that the device is able to access to 192.168.0.38:8080/target/target-script-min.js#anonymous
White-listed both 192.168.0.38:8080 and 192.168.0.38 in config.xml
Added the script call in the index.html
Still the target list remains empty when I launch the app on the device from ADT...
What should I do next?
Thanks!
___ EDIT
I tried the demo, and it's working!
So what makes the difference between calling the script from a demo file, or from the application?
Turns out for me, the problem was that the mobile device silently switched over to another Wi-Fi network (than the one my computer was on), thus rendering the Weinre JS Script unreachable from within the app.
It's different than the issue described above (since, for Yako, the example scripts were working fine), but thought it could help somebody someday.
My issue was that I kept trying to access a page anchor. Apparently that doesn't work too well so I have to load the page first with no anchor, then add the anchor separately.
Finally, it's working!
It seems I only had to wait a little bit after app initalization!??
For all of you who still have to use weinre and have the same problem, I just want to share my mistake:
I did not whitelist my IP-address in the config.xml
maybe some of you have the same mistake.
i am developing phone-gap app in android. In app I am calling a servlet returning JSON. Under app code I am calling following method through javascript in index.html
JQuery.getJSON(servleturl,function(data){alert(data)});
When running in emulator the alert is getting displayed, but data is always null. However if i launch the index.html (main application file in phonegap) from browser, I am able to get Json.
same thing happens even if I use $ajax.
please help me and let me know what I am doing wrong.
A little bit later, but I had the same problem today, and I've solved it, so if you didn't sort this problem this would help.
So, the problem is not in JSON or in the phonegap, but it's in the AndroidManifest.xml file.
You should have a tag like this:
<uses-permission android:name="android.permission.INTERNET" />
this should allow your application to work with Internet. Without this connection to Internet from your application is forbidden. That tag need to be placed right after the start tag.
Check Phonegap sample manifest for full list of possible permissions.
hope this will help to someone.
I fixed up (read made the changes to get working under a newer version of node.js) a little tool called ibug that John Boxall wrote that I found useful for debugging on the phone (since there is no real way to do it except debug.log and looking at XCodes console window. Its basically a stripped down firebug lite, and its hosted on github as ibug. Hopefully it will help you figure out why things aren't working.