简体   繁体   English

通过wifi连接到android studio后,在android设备上测试应用程序时出错

[英]Error in testing application on android device after connecting to android studio via wifi

I did follow this Connect to wifi tutorial and i was able to connect my phone to my desktop through wifi(router) and i am able to test almost all application wirelessly except those require JSON parsing. 我确实遵循了此“ 连接到wifi”教程,并且能够通过wifi(路由器)将手机连接到桌面,并且能够无线测试几乎所有应用程序,除了那些需要JSON解析的应用程序。 I am using wamp server and it is running but i am getting forbidden error. 我正在使用wamp服务器,它正在运行,但是我收到了禁止的错误。

This is the error in logcat. 这是logcat中的错误。 Can anyone tell me how shall i get rid of this error?? 谁能告诉我如何摆脱这个错误? Also in my source code of the application, i did add the ip address of my desktop like this 192.168.0.105/test/stock.php instead of 10.10.0.2 同样在应用程序的源代码中,我确实添加了桌面IP地址,如192.168.0.105/test/stock.php而不是10.10.0.2。

My application works perfectly on the emulator but i am not able to run it on the device. 我的应用程序可以在模拟器上完美运行,但是我无法在设备上运行它。

04-25 20:07:11.172 11847-11874/com.e.myapplication I/System.out﹕ ERROR : Forbidden 04-25 20:07:11.172 11847-11874/com.e.myapplication I/System.out﹕ error 04-25 20:07:11.172 11847-11847/com.e.myapplication E/log_tag﹕ Error parsing data org.json.JSONException: Value error of type java.lang.String cannot be converted to JSONArray 04-25 20:07:11.172 11847-11874 / com.e.myapplication I / System.out:错误:禁止04-25 20:07:11.172 11847-11874 / com.e.myapplication I / System.out:错误04-25 20:07:11.172 11847-11847 / com.e.myapplication E / log_tag:解析数据org.json.JSONException:java.lang.String类型的值错误无法转换为JSONArray

Value error of type java.lang.String cannot be converted to JSONArray 类型为java.lang.String的值错误无法转换为JSONArray

means that you probably try to map something like this : 意味着您可能尝试映射以下内容:

name="value"

to an array. 到一个数组。

So your Json is wrongly formatted, you must have something like this : 因此,您的Json格式错误,您必须具有以下内容:

name=["value"]

Since your app works correctly in the emulator, it's probably a communication error. 由于您的应用程序可以在模拟器中正常运行,因此可能是通信错误。 The error you see is certainly the consequence of something else. 您看到的错误肯定是其他原因造成的。 Look at previous logs and log the json string you are trying to parse. 查看以前的日志并记录您要解析的json字符串。 (I'm pretty sure it is not at all what you expect) (我很确定这根本不是您所期望的)

I managed to solve the problem changing a setting in the Apache httpd.conf. 我设法解决了更改Apache httpd.conf中的设置的问题。

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

I changed it to 我将其更改为

Order Deny,Allow
Allow from all
Allow from 127.0.0.1

And now my mobile can access the web service. 现在,我的手机可以访问Web服务了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM