I m new to phonegap.So i was trying to run Hello world html file in android emulator which comes with phonegap.But i m getting this error
Application Error
There was a network error.(file:///android_asset/www/index.html)
I checked HTML file by clicking run with browser in eclipse and its running good.But when it comes to run as Android application then it is giving error.
Before posting this question i Googled for solutions and there i got to know that we should enable permission for internet,but it is also done and also LAN is disabled as some one stated in this website as solution.And also i got to know that its problem with Android SDK and every phonegap user facing this problem.Is that true??
I m really good at HTML,CSS and Javascript.So i opt phonegap.But now i m very sad.
Last question.Will it give same problem if i use XCode for iPhone in Phonegap??
Regards
Devaraju
Try adding this permission too.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
This network error shows up for various reasons, but my guess is that your config.xml is looking for index.html and you have named your html page something else.
Related
I am creating an android app using Cordova with the Crosswalk webview and the dtworkshop-inappcrossbrowser plugin. The app is effectively wrapping a website.
On the website there is a form that allows you to upload a photo. The problem is that when I select the browse button I get the message "Choose an action" followed by "No apps can perform this action".
I am not totally sure how the upload button functions, but I know that it is not an input element because I experimented with an input and I know it works.
I read that it could be a permissions so I have added the following, but still no luck:
READ_EXTERNAL_STORAGE, INTERNET, WRITE_EXTERNAL_STORAGE, ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE, CAMERA, MANAGE_DOCUMENTS.
I have tested in the android chrome browser and everything works, so I know its related to the app.
I have created the same app for iOS and everything works. I know there are issues with the android webview hence the reason I am using the crosswalk plugin, thought these issues were going to be solved.
Any help advice about how I can get this working is much appreciated.
Hey I have found that editing the accept="" attribute to accept="image/" or accept="video/" fixed the problem. Also attribute such as .ext or more than one attribute i.e accept="image/, video/" though syntax wise are correct will throw the same error. Hope this helps
I had the same problem and it was due to the fact I was not including cordova.js as script in my index.html file.
So I simply added the following line to index.html and it was working fine.
<script type="text/javascript" src="cordova.js"></script>
I really need some help here...
I have developed a simple app using cordova and I wish to debug the app using weinre for further improvement.
The problem is when i host weinre client and access with browser to http://192.168.0.111:8080/client/#anonymous
the app does not show as a target in the client..
I have insert this script import line at the last part of my index.html
<script src="http://192.168.0.111:8080/target/target-script-min.js#anonymous"></script>
In config.xml, i put <access origin="*" />
and in AndroidManifest.xml, i put <uses-permission android:name="android.permission.INTERNET" />
I have also try to open my index.html with the browser of computer which hosting weinre and it's been indicate as a target. Which mean the code should be working fine.
I have also try to access http://192.168.0.111:8080 and the weinre info page is showing up. which mean the ip is correct and accessible from my handphone.
but I wonder why when i run the app, weinre dint show my app as a target. Do I miss out some important step to allow my app to be accessible?
Please help.
After all I still cannot identified the issue, it might be configuration issue and it might not... any suggestion or answer will be welcome.
and to provide solution for those who have similar situation as me, you can try this https://developer.chrome.com/devtools/docs/remote-debugging.
It's working fine for my case. Besides, it's much easier to setup and more familiar interface. You can even step through your js line by line just like what you can do with your pages.
for the moments, this is the best solution i can get.
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.
I am new to Android and I am trying a few small apps (like Compass). When I run the app in the emulator, it gives the message Unfortunately, Compass has Stopped.
I have no compile time errors.
How do I solve this, and what is causing this?
Thanks in advance.
I had the same error message and found that, in commenting out uses-permission nodes in AndroidManifest.xml I had commented out one that was needed. When I put it back in the app ran fine. I was able to reproduce the error. I needed:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
This was for a barebones index.html, single page app, that displays Hello World.
And the permission above was the only one I needed to do Run As/ Android Application and get it to run in an emulator.
HTH
You have posted no code so it's difficult to see what your problem is. However I had the same issue which has been sorted out here Unfortunately HelloListView has stopped
It probably due to the fact that you don't have accelerometer and magnetic field support.
Go to your AVD configuration and add the following hardware: Magnetic Field Support and accelerometer
First check your AndroidManifest.xml file and write activity tag
For example, you have DisplayMessageActivity.class and package is me.user_interface
tag is:
<activity android:name="me.user_interface.DisplayMessageActivity"/>
You can write this after </activity> tag in AndroidManifest.xml file. Check the path carefully.
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.