如何解决android中的地理位置错误?

时间:2016-06-09 07:12:38

标签: android html5 cordova geolocation

如何在使用原生HTML5地理位置或Android Cordova插件地理位置时解决以下错误?



06-09 12:39:28.123 1552-1712/? D/WifiService: releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@a1995d8}
06-09 12:39:33.126 1552-1711/? D/WifiService: acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@a1995d8}
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: 	... 24 more




我正在尝试使用 - navigator.geolocation.getCurrentPosition(onSuccess,onError,{enableHighAccuracy:true});或简单的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模拟器,Asus zenfone 5 - android 4.4。

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我相信当设备位置/ GPS关闭时会发生此问题。要确保设备GPS已开启,您可以使用gps dialog plugin

在设备中禁用GPS时,此插件会显示一个对话框并重定向到GPS设置。

另请您查看可提供更多信息的SO Post