所以我正在尝试用Parse做一个项目,而且我的开始非常糟糕。 按照文档中的步骤操作后,我尝试执行任何请求(登录,对象创建),经过很长时间等待(总是超过10-15秒),我得到一个如下错误:
com.parse.ParseRequest$ParseRequestException: bad json response
Caused by: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
在浏览所有存在的问题和答案后,我发现这种情况通常有两个原因:
来自启动的链接缺少“/” 该应用程序没有连接
通过调试,我已经消除了这两种可能性,但我仍然发现自己陷入困境。 在这一点上的任何帮助非常感谢。
这一行下面是我的完整Logcat,前3行是我的日志,其余是错误生成的。
E/error: bad json response
E/error code =: 100
E/error toString: com.parse.ParseRequest$ParseRequestException: bad json response
W/System.err: com.parse.ParseRequest$ParseRequestException: bad json response
W/System.err: at com.parse.ParseRequest.newTemporaryException(ParseRequest.java:290)
W/System.err: at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:308)
W/System.err: at com.parse.ParseRESTUserCommand.onResponseAsync(ParseRESTUserCommand.java:126)
W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:137)
W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:133)
W/System.err: at bolts.Task$15.run(Task.java:917)
W/System.err: at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
W/System.err: at bolts.Task.completeAfterTask(Task.java:908)
W/System.err: at bolts.Task.continueWithTask(Task.java:715)
W/System.err: at bolts.Task.continueWithTask(Task.java:726)
W/System.err: at bolts.Task$13.then(Task.java:818)
W/System.err: at bolts.Task$13.then(Task.java:806)
W/System.err: at bolts.Task$15.run(Task.java:917)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
W/System.err: at java.lang.Thread.run(Thread.java:762)
W/System.err: Caused by: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173)
W/System.err: at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:298)
W/System.err: ... 14 more
感谢您的时间。
答案 0 :(得分:0)
将此添加到您的构建依赖项:compile 'com.parse:parseinterceptors:0.0.2'
然后像这样初始化解析:
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId(appId)
.clientKey("")
.server(serverUrl)
.addNetworkInterceptor(new ParseLogInterceptor())
.build()
);
使用该日志输出,您可能会发现它正在使用错误的服务器URL或错误的应用程序ID进行初始化。如果没有,您将在日志中获得完整的HTML响应,这可以让您更好地了解正在发生的事情。