如何修复此“协议不支持的地址系列”错误?

时间:2010-09-29 16:24:48

标签: java android eclipse

我正在使用带有JDK 6的Eclipse 3.6.0。我的构建目标是Android 2.2。我正在Windows 7下开发。

我正在尝试获取如下所示的XML文件:

SAXParserFactory spf = SAXParserFactory.newInstance();
try {
    //get a new instance of parser
    SAXParser sp = spf.newSAXParser();

    //parse the file and also register this class for call backs
    sp.parse("http://ipaddress/my/valid/path.xml", this);
}catch(SAXException se) {
    se.printStackTrace();
}catch(ParserConfigurationException pce) {
    pce.printStackTrace();
}catch (IOException ie) {
    ie.printStackTrace();
}

但是我在调​​试器中收到了一个权限被拒绝错误(由套接字异常引起)。 除此之外,我也得到sntpclient error: address family not supported by protocol. 以下是详细日志:

09-29 16:13:40.181: WARN/System.err(304): java.io.IOException: Couldn't open http://213.137.198.141:8085/MarketDataServiceV3.asmx/GetIntraday?instrument=FSPAA.ST&from=2010-09-01&to=2010-09-20&authentication=D41D8CD98F00B204E9800998ECF8427E&nocache=true
09-29 16:13:40.200: WARN/System.err(304):     at org.apache.harmony.xml.ExpatParser.openUrl(ExpatParser.java:759)
09-29 16:13:40.210: WARN/System.err(304):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:291)
09-29 16:13:40.210: WARN/System.err(304):     at javax.xml.parsers.SAXParser.parse(SAXParser.java:392)
09-29 16:13:40.220: WARN/System.err(304):     at javax.xml.parsers.SAXParser.parse(SAXParser.java:268)
09-29 16:13:40.230: WARN/System.err(304):     at aiCharts.GettingStarted.MySAXParser.parseDocument(MySAXParser.java:45)
09-29 16:13:40.239: WARN/System.err(304):     at aiCharts.GettingStarted.DataFactory.getChartDataByWebService(DataFactory.java:30)
09-29 16:13:40.249: WARN/System.err(304):     at aiCharts.GettingStarted.GettingStartedActivity.onCreate(GettingStartedActivity.java:42)
09-29 16:13:40.249: WARN/System.err(304):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-29 16:13:40.260: WARN/System.err(304):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-29 16:13:40.270: WARN/System.err(304):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-29 16:13:40.279: WARN/System.err(304):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-29 16:13:40.279: WARN/System.err(304):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-29 16:13:40.289: WARN/System.err(304):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-29 16:13:40.289: WARN/System.err(304):     at android.os.Looper.loop(Looper.java:123)
09-29 16:13:40.301: WARN/System.err(304):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-29 16:13:40.301: WARN/System.err(304):     at java.lang.reflect.Method.invokeNative(Native Method)
09-29 16:13:40.320: WARN/System.err(304):     at java.lang.reflect.Method.invoke(Method.java:521)
09-29 16:13:40.320: WARN/System.err(304):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-29 16:13:40.331: WARN/System.err(304):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-29 16:13:40.339: WARN/System.err(304):     at dalvik.system.NativeStart.main(Native Method)
09-29 16:13:40.351: WARN/System.err(304): Caused by: java.net.SocketException: Permission denied
09-29 16:13:40.370: WARN/System.err(304):     at org.apache.harmony.luni.platform.OSNetworkSystem.createStreamSocketImpl(Native Method)
09-29 16:13:40.390: WARN/System.err(304):     at org.apache.harmony.luni.platform.OSNetworkSystem.createStreamSocket(OSNetworkSystem.java:186)
09-29 16:13:40.390: WARN/System.err(304):     at org.apache.harmony.luni.net.PlainSocketImpl.create(PlainSocketImpl.java:265)
09-29 16:13:40.399: WARN/System.err(304):     at java.net.Socket.checkClosedAndCreate(Socket.java:873)
09-29 16:13:40.409: WARN/System.err(304):     at java.net.Socket.connect(Socket.java:1020)
09-29 16:13:40.409: WARN/System.err(304):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:62)
09-29 16:13:40.419: WARN/System.err(304):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:88)
09-29 16:13:40.431: WARN/System.err(304):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHTTPConnection(HttpURLConnectionImpl.java:927)
09-29 16:13:40.441: WARN/System.err(304):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:909)
09-29 16:13:40.441: WARN/System.err(304):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:1152)
09-29 16:13:40.450: WARN/System.err(304):     at org.apache.harmony.xml.ExpatParser.openUrl(ExpatParser.java:757)
09-29 16:13:40.450: WARN/System.err(304):     ... 19 more
09-29 16:14:26.580: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol`

当我作为Java应用程序单独运行时,我可以解析该文件。我还允许清单中的互联网访问。清单条目是:

uses-permission android:name="INTERNET"

0 个答案:

没有答案