I'm using Parse api for my app and notice an issue that this api not working as experted. Here are my code:
ParseQuery<ParseObject> query = ParseQuery.getQuery("Group");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if(list!=null)
{
//...
}
}
});
This work good on android 4.0 but on android 2.3 this return ParseException:
com.parse.ParseRequest$ParseRequestException: i/o failure
01-06 01:08:18.965 1593-1593/my.package.name W/System.err﹕ at com.parse.ParseRequest.newTemporaryException(ParseRequest.java:372)
01-06 01:08:18.965 1593-1593/my.package.name W/System.err﹕ at com.parse.ParseRequest$2.then(ParseRequest.java:198)
01-06 01:08:18.965 1593-1593/my.package.name W/System.err﹕ at com.parse.ParseRequest$2.then(ParseRequest.java:190)
01-06 01:08:18.965 1593-1593/my.package.name W/System.err﹕ at bolts.Task$14.run(Task.java:796)
01-06 01:08:18.965 1593-1593/my.package.name W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
01-06 01:08:18.965 1593-1593/my.package.name W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
01-06 01:08:18.965 1593-1593/my.package.name W/System.err﹕ at java.lang.Thread.run(Thread.java:1027)
01-06 01:08:18.965 1593-1593/my.package.name W/System.err﹕ Caused by: javax.net.ssl.SSLHandshakeException: org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: current time: Sun Jan 06 01:08:18 GMT+00:00 1980, validation time: Tue Oct 22 12:00:00 GMT+00:00 2013
01-06 01:08:18.965 1593-1593/my.package.name W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:477)
01-06 01:08:18.975 1593-1593/my.package.name W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:328)
01-06 01:08:18.975 1593-1593/my.package.name W/System.err﹕ at android.net.SSLCertificateSocketFactory.verifyHostname(SSLCertificateSocketFactory.java:199)
01-06 01:08:18.975 1593-1593/my.package.name W/System.err﹕ at android.net.SSLCertificateSocketFactory.createSocket(SSLCertificateSocketFactory.java:259)
01-06 01:08:18.985 1593-1593/my.package.name W/System.err﹕ at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:375)
01-06 01:08:18.985 1593-1593/my.package.name W/System.err﹕ at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:164)
01-06 01:08:18.985 1593-1593/my.package.name W/System.err﹕ at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
01-06 01:08:18.985 1593-1593/my.package.name W/System.err﹕ at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
01-06 01:08:18.995 1593-1593/my.package.name W/System.err﹕ at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:359)
01-06 01:08:18.995 1593-1593/my.package.name W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
01-06 01:08:18.995 1593-1593/my.package.name W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
01-06 01:08:18.995 1593-1593/my.package.name W/System.err﹕ at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
01-06 01:08:18.995 1593-1593/my.package.name W/System.err﹕ at com.parse.ParseApacheHttpClient.executeInternal(ParseApacheHttpClient.java:95)
01-06 01:08:18.995 1593-1593/my.package.name W/System.err﹕ at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:147)
01-06 01:08:18.995 1593-1593/my.package.name W/System.err﹕ at com.parse.ParsePlugins$1.intercept(ParsePlugins.java:103)
01-06 01:08:18.995 1593-1593/my.package.name W/System.err﹕ at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:136)
01-06 01:08:19.005 1593-1593/my.package.name W/System.err﹕ at com.parse.ParseHttpClient.execute(ParseHttpClient.java:111)
01-06 01:08:19.005 1593-1593/my.package.name W/System.err﹕ at com.parse.ParseRequest$3.then(ParseRequest.java:187)
01-06 01:08:19.005 1593-1593/my.package.name W/System.err﹕ at com.parse.ParseRequest$3.then(ParseRequest.java:184)
01-06 01:08:19.005 1593-1593/my.package.name W/System.err﹕ at bolts.Task$14.run(Task.java:796)
01-06 01:08:19.005 1593-1593/my.package.name W/System.err﹕ at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
01-06 01:08:19.005 1593-1593/my.package.name W/System.err﹕ at bolts.Task.completeAfterTask(Task.java:787)
01-06 01:08:19.015 1593-1593/my.package.name W/System.err﹕ at bolts.Task.continueWithTask(Task.java:599)
01-06 01:08:19.015 1593-1593/my.package.name W/System.err﹕ at bolts.Task.continueWithTask(Task.java:610)
01-06 01:08:19.015 1593-1593/my.package.name W/System.err﹕ at bolts.Task$12.then(Task.java:702)
01-06 01:08:19.015 1593-1593/my.package.name W/System.err﹕ at bolts.Task$12.then(Task.java:690)
01-06 01:08:19.015 1593-1593/my.package.name W/System.err﹕ ... 4 more
01-06 01:08:19.015 1593-1593/my.package.name W/System.err﹕ Caused by: java.security.cert.CertificateException: org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: current time: Sun Jan 06 01:08:18 GMT+00:00 1980, validation time: Tue Oct 22 12:00:00 GMT+00:00 2013
01-06 01:08:19.025 1593-1593/my.package.name W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:161)
01-06 01:08:19.025 1593-1595/my.package.name D/dalvikvm﹕ GC_CONCURRENT freed 399K, 44% free 3521K/6215K, external 0K/0K, paused 6ms+10ms
01-06 01:08:19.035 1593-1593/my.package.name W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:664)
01-06 01:08:19.035 1593-1593/my.package.name W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)
01-06 01:08:19.035 1593-1593/my.package.name W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:474)
01-06 01:08:19.035 1593-1593/my.package.name W/System.err﹕ ... 29 more
01-06 01:08:19.035 1593-1593/my.package.name W/System.err﹕ Caused by: org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: current time: Sun Jan 06 01:08:18 GMT+00:00 1980, validation time: Tue Oct 22 12:00:00 GMT+00:00 2013
01-06 01:08:19.045 1593-1593/my.package.name W/System.err﹕ at org.bouncycastle.jce.provider.RFC3280CertPathUtilities.processCertA(RFC3280CertPathUtilities.java:1521)
01-06 01:08:19.045 1593-1593/my.package.name W/System.err﹕ at org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi.engineValidate(PKIXCertPathValidatorSpi.java:399)
01-06 01:08:19.045 1593-1593/my.package.name W/System.err﹕ at java.security.cert.CertPathValidator.validate(CertPathValidator.java:197)
01-06 01:08:19.045 1593-1593/my.package.name W/System.err﹕ at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:156)
01-06 01:08:19.045 1593-1593/my.package.name W/System.err﹕ ... 32 more
01-06 01:08:19.045 1593-1593/my.package.name W/System.err﹕ Caused by: java.security.cert.CertificateNotYetValidException: current time: Sun Jan 06 01:08:18 GMT+00:00 1980, validation time: Tue Oct 22 12:00:00 GMT+00:00 2013
01-06 01:08:19.055 1593-1593/my.package.name W/System.err﹕ at org.apache.harmony.security.provider.cert.X509CertImpl.checkValidity(X509CertImpl.java:178)
01-06 01:08:19.055 1593-1593/my.package.name W/System.err﹕ at org.bouncycastle.jce.provider.RFC3280CertPathUtilities.processCertA(RFC3280CertPathUtilities.java:1512)
01-06 01:08:19.055 1593-1593/my.package.name W/System.err﹕ ... 35 more
Please help me to fix this. Thanks so much
答案 0 :(得分:0)
此代码必须基于parse
的文档才适用于2.3可能你必须导入bolt-android.x.x.x jar文件....
和 像下面的代码一样测试
ParseQuery<ParseObject> query = ParseQuery.getQuery("Group");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if(e!=null)
{
//...
}
else
{
Log.d("Error",e.getMessage());
// r use Toast with e.getMessage()
}
}
});
你会得到解析错误的内容......
答案 1 :(得分:0)
尝试这种方式。
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Group");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if (e == null) {
// ...
// Success
if (list.size() > 0) {
// get array list more then zero
} else {
// not geting data
}
} else {
Log.e("Error ...... ", e.getMessage());
// r use Toast with e.getMessage()
}
}
});
检查您的班级名称。 或者还检查主活动上的解析密钥或客户端密钥。 在其他情况下你得到错误所以做评论。