2016-06-09 44 views
0

如何使用原生HTML5地理位置或Android Cordova插件地理位置解決以下錯誤?如何解決android中的地理位置錯誤?

06-09 12:39:28.123 1552-1712/? D/WifiService: releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 [email protected]} 
 
06-09 12:39:33.126 1552-1711/? D/WifiService: acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 [email protected]} 
 
06-09 12:39:33.309 1826-2282/? W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 
 
06-09 12:39:33.309 1826-2282/? W/System.err:  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:328) 
 
06-09 12:39:33.309 1826-2282/? W/System.err:  at android.net.SSLCertificateSocketFactory.verifyHostname(SSLCertificateSocketFactory.java:198) 
 
06-09 12:39:33.309 1826-2282/? W/System.err:  at android.net.SSLCertificateSocketFactory.createSocket(SSLCertificateSocketFactory.java:443) 
 
06-09 12:39:33.310 1826-2282/? W/System.err:  at com.android.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:89) 
 
06-09 12:39:33.310 1826-2282/? W/System.err:  at com.android.okhttp.Connection.connect(Connection.java:143) 
 
06-09 12:39:33.310 1826-2282/? W/System.err:  at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:185) 
 
06-09 12:39:33.310 1826-2282/? W/System.err:  at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128) 
 
06-09 12:39:33.310 1826-2282/? W/System.err:  at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:341) 
 
06-09 12:39:33.310 1826-2282/? W/System.err:  at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330) 
 
06-09 12:39:33.315 1826-2282/? W/System.err:  at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248) 
 
06-09 12:39:33.316 1826-2282/? W/System.err:  at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433) 
 
06-09 12:39:33.317 1826-2282/? W/System.err:  at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:114) 
 
06-09 12:39:33.317 1826-2282/? W/System.err:  at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:245) 
 
06-09 12:39:33.317 1826-2282/? W/System.err:  at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218) 
 
06-09 12:39:33.317 1826-2282/? W/System.err:  at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java) 
 
06-09 12:39:33.317 1826-2282/? W/System.err:  at com.google.android.gms.http.GoogleHttpClient.a(SourceFile:948) 
 
06-09 12:39:33.317 1826-2282/? W/System.err:  at com.google.android.gms.http.GoogleHttpClient.a(SourceFile:766) 
 
06-09 12:39:33.317 1826-2282/? W/System.err:  at com.google.android.gms.http.GoogleHttpClient.execute(SourceFile:674) 
 
06-09 12:39:33.319 1826-2282/? W/System.err:  at com.google.android.gms.http.GoogleHttpClient.execute(SourceFile:658) 
 
06-09 12:39:33.319 1826-2282/? W/System.err:  at com.google.r.a.b.a.b.g(SourceFile:126) 
 
06-09 12:39:33.319 1826-2282/? W/System.err:  at com.google.r.a.b.a.b.c(SourceFile:172) 
 
06-09 12:39:33.319 1826-2282/? W/System.err:  at com.google.z.a.d.run(SourceFile:434) 
 
06-09 12:39:33.319 1826-2282/? W/System.err:  at com.google.z.a.c.c(SourceFile:230) 
 
06-09 12:39:33.319 1826-2282/? W/System.err:  at com.google.z.a.c.run(SourceFile:204) 
 
06-09 12:39:33.319 1826-2282/? W/System.err:  at com.google.r.a.c.b.run(SourceFile:96) 
 
06-09 12:39:33.323 1826-2282/? W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 
 
06-09 12:39:33.324 1826-2282/? W/System.err:  at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:318) 
 
06-09 12:39:33.324 1826-2282/? W/System.err:  at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:219) 
 
06-09 12:39:33.324 1826-2282/? W/System.err:  at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:115) 
 
06-09 12:39:33.324 1826-2282/? W/System.err:  at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:556) 
 
06-09 12:39:33.324 1826-2282/? W/System.err:  at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) 
 
06-09 12:39:33.324 1826-2282/? W/System.err:  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:324) 
 
06-09 12:39:33.324 1826-2282/? W/System.err: \t ... 24 more

我想使用 - navigator.geolocation.getCurrentPosition(的onSuccess,onError的,{enableHighAccuracy:真});或簡單的HTML5 -

 function getLocation() { 
 

 
      console.log("get geolocation..."); 
 
      if (navigator.geolocation) { 
 
       console.log("Possible..navigation..."); 
 
       navigator.geolocation.getCurrentPosition(showPosition, showError); 
 
      } else { 
 
       console.log("Geolocation is not supported by this browser."); 
 
      } 
 
     }

Bith不在的Nexus模擬器工作,華碩zenfone 5 - Android 4.4系統。

如何解決這個問題?

+0

您是否正確添加了插件? https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-geolocation/也是在設備中激活的地理位置?和應用的地理位置權限? – Del

+0

我如何添加它?我有 - 清單和插件清單中的cordova-plugin-geolocation中的 ?在config.xml中提及什麼? – Smitha

+0

如果你通過'cordova plugin add'來安裝它,它應該自己添加,如果你手動添加它,你必須添加它。 – Del

回答

0

我相信這個問題發生在設備位置/ GPS關閉時。爲確保GPS設備已打開,您可以使用gps dialog plugin

該插件顯示一個對話框,並在設備中禁用GPS時重定向至GPS設置。

還請你看看這個SO Post它可以提供更多的信息。

相關問題